Git Product home page Git Product logo

Comments (4)

caridy avatar caridy commented on May 22, 2024

yeah, we want to improve the docs, thanks for the suggestions, we will look at it.

as for the locales, this is propagated down to the primitives defined in ECMA-402, more details here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation

Now, loading fr.js locale data does not necessary means that we have data for locale fr, that file might hold data for fr and fr-CA, since they have different rules. We don't want to provide data for every locale because it is relative small, even when we fold them by root locales. Here is an example of fr.js:

IntlRelativeFormat.__addLocaleData({"locale":"fr","pluralRuleFunction":function (n) {var i=Math.floor(Math.abs(n));n=Math.floor(n);if(i===0||i===1)return"one";return"other";},"fields":{"second":{"displayName":"seconde","relative":{"0":"maintenant"},"relativeTime":{"future":{"one":"dans {0} seconde","other":"dans {0} secondes"},"past":{"one":"il y a {0} seconde","other":"il y a {0} secondes"}}},"minute":{"displayName":"minute","relativeTime":{"future":{"one":"dans {0} minute","other":"dans {0} minutes"},"past":{"one":"il y a {0} minute","other":"il y a {0} minutes"}}},"hour":{"displayName":"heure","relativeTime":{"future":{"one":"dans {0} heure","other":"dans {0} heures"},"past":{"one":"il y a {0} heure","other":"il y a {0} heures"}}},"day":{"displayName":"jour","relative":{"0":"aujourd’hui","1":"demain","2":"après-demain","-2":"avant-hier","-1":"hier"},"relativeTime":{"future":{"one":"dans {0} jour","other":"dans {0} jours"},"past":{"one":"il y a {0} jour","other":"il y a {0} jours"}}},"month":{"displayName":"mois","relative":{"0":"ce mois-ci","1":"le mois prochain","-1":"le mois dernier"},"relativeTime":{"future":{"one":"dans {0} mois","other":"dans {0} mois"},"past":{"one":"il y a {0} mois","other":"il y a {0} mois"}}},"year":{"displayName":"année","relative":{"0":"cette année","1":"l’année prochaine","-1":"l’année dernière"},"relativeTime":{"future":{"one":"dans {0} an","other":"dans {0} ans"},"past":{"one":"il y a {0} an","other":"il y a {0} ans"}}}}});
IntlRelativeFormat.__addLocaleData({"locale":"fr-ca","pluralRuleFunction":function (n) {var i=Math.floor(Math.abs(n));n=Math.floor(n);if(i===0||i===1)return"one";return"other";},"fields":{"second":{"displayName":"seconde","relative":{"0":"maintenant"},"relativeTime":{"future":{"one":"Dans {0} seconde","other":"Dans {0} secondes"},"past":{"one":"Il y a {0} seconde","other":"Il y a {0} secondes"}}},"minute":{"displayName":"minute","relativeTime":{"future":{"one":"Dans {0} minute","other":"Dans {0} minutes"},"past":{"one":"Il y a {0} minute","other":"Il y a {0} minutes"}}},"hour":{"displayName":"heure","relativeTime":{"future":{"one":"Dans {0} heure","other":"Dans {0} heures"},"past":{"one":"Il y a {0} heure","other":"Il y a {0} heures"}}},"day":{"displayName":"jour","relative":{"0":"aujourd’hui","1":"demain","2":"après-demain","-2":"avant-hier","-1":"hier"},"relativeTime":{"future":{"one":"Dans {0} jour","other":"Dans {0} jours"},"past":{"one":"Il y a {0} jour","other":"Il y a {0} jours"}}},"month":{"displayName":"mois","relative":{"0":"Ce mois-ci","1":"Le mois prochain","-1":"Le mois dernier"},"relativeTime":{"future":{"one":"Dans {0} mois","other":"Dans {0} mois"},"past":{"one":"Il y a {0} mois","other":"Il y a {0} mois"}}},"year":{"displayName":"année","relative":{"0":"Cette année","1":"L'année prochaine","-1":"L'année dernière"},"relativeTime":{"future":{"one":"Dans {0} an","other":"Dans {0} ans"},"past":{"one":"Il y a {0} an","other":"Il y a {0} ans"}}}}});

That's the reason why your application can use ['fr-CA', 'fr', 'us'], which will be normalized under the hood to the best match, and it will pick up the right locale data to format the data.

from intl-messageformat.

caridy avatar caridy commented on May 22, 2024

to be clear, you normally don't need to worry much about this, and you just pass one locale in that array, and it will resolve the best match based on the locale data known by the library and the browser in case of primitives.

from intl-messageformat.

slorber avatar slorber commented on May 22, 2024

thanks

So i guess i'll only use one then :)

from intl-messageformat.

caridy avatar caridy commented on May 22, 2024

I will keep this open until we update the documentation.

from intl-messageformat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.