{"_id":"@ef-carbon/fluent-langneg","name":"@ef-carbon/fluent-langneg","dist-tags":{"latest":"0.7.0"},"versions":{"0.7.0":{"name":"@ef-carbon/fluent-langneg","description":"Language Negotiation API for Fluent","version":"0.7.0","homepage":"https://projectfluent.org","author":{"name":"Mozilla","email":"l10n-drivers@mozilla.org"},"license":"Apache-2.0","contributors":[{"name":"Zibi Braniecki","email":"zbraniecki@mozilla.com"},{"name":"Staś Małolepszy","email":"stas@mozilla.com"}],"main":"./index.js","module":"./esm/index.js","types":"./esm/index.d.ts","repository":{"type":"git","url":"git+https://github.com/projectfluent/fluent.js.git"},"keywords":["localization","l10n","internationalization","i18n","locale","language","language-negotiation"],"scripts":{"build":"tsc","postbuild":"rollup -c ../rollup.config.mjs","docs":"typedoc --options ../typedoc.config.cjs","test":"mocha 'test/*_test.js'"},"engines":{"node":">=14.0.0","npm":">=7.0.0"},"_id":"@ef-carbon/fluent-langneg@0.7.0","gitHead":"f620e1c4932c0de9ba6df47dfc11bab1bc9285a5","bugs":{"url":"https://github.com/projectfluent/fluent.js/issues"},"_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-4XON7Vsc8vD69UYZ+eivFHTPVZ5K6Oe3dZ0PDDZ9+5Gn1r7KHuVgueBqafay1jXQx73fprLZSHvdi0B4GnweMA==","shasum":"615aa8bfb0dd1ff5ed3767710ebd2f57fb7ef92e","tarball":"https://registry.npmjs.org/@ef-carbon/fluent-langneg/-/fluent-langneg-0.7.0.tgz","fileCount":15,"unpackedSize":47904,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDx+B7E8/Gmz6eeCi8mYXm57jSfTdI9jiTEvA/1jUkuSAIhAOxkzbXhdvGwuoA+ahkH2BblnctfP4sJgCKqyEOi4NyS"}]},"_npmUser":{"name":"ef-carbon-bot","email":"carbon.accounts@ef.com"},"directories":{},"maintainers":[{"name":"ef-carbon-bot","email":"carbon.accounts@ef.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/fluent-langneg_0.7.0_1763999628951_0.023292469073777466"},"_hasShrinkwrap":false}},"time":{"created":"2025-11-24T15:53:48.850Z","0.7.0":"2025-11-24T15:53:49.139Z","modified":"2025-11-24T15:53:49.452Z"},"maintainers":[{"name":"ef-carbon-bot","email":"carbon.accounts@ef.com"}],"description":"Language Negotiation API for Fluent","homepage":"https://projectfluent.org","keywords":["localization","l10n","internationalization","i18n","locale","language","language-negotiation"],"repository":{"type":"git","url":"git+https://github.com/projectfluent/fluent.js.git"},"contributors":[{"name":"Zibi Braniecki","email":"zbraniecki@mozilla.com"},{"name":"Staś Małolepszy","email":"stas@mozilla.com"}],"author":{"name":"Mozilla","email":"l10n-drivers@mozilla.org"},"bugs":{"url":"https://github.com/projectfluent/fluent.js/issues"},"license":"Apache-2.0","readme":"# @fluent/langneg ![](https://github.com/projectfluent/fluent.js/workflows/test/badge.svg)\n\n`@fluent/langneg` provides an API for negotiating languages. It's part of\n[Project Fluent][]. Its main function is to provide functionality around the\n[Intl.Locale][] API with a focus on language negotiation, matching and\nselection.\n\n[project fluent]: https://projectfluent.org\n[intl.locale]: https://github.com/tc39/proposal-intl-locale\n\n## Installation\n\n`@fluent/langneg` can be used both on the client-side and the server-side.\nYou can install it from the npm registry or use it as a standalone script.\n\n    npm install @fluent/langneg\n\n## How to use\n\n```javascript\nimport { negotiateLanguages } from \"@fluent/langneg\";\n\nconst supportedLocales = negotiateLanguages(\n  navigator.languages, // requested locales\n  [\"de\", \"en-US\", \"pl\"], // available locales\n  { defaultLocale: \"en-US\" }\n);\n```\n\nThe API reference is available at\nhttps://projectfluent.org/fluent.js/langneg.\n\n## Strategies\n\nThe API supports three negotiation strategies:\n\n### filtering (default)\n\nIn this strategy the algorithm will try to match as many available locales\nas possible for each of the requested locale.\n\nExample:\n\nrequested: ['de-DE', 'fr-FR']\navailable: ['it', 'de', 'en-US', 'fr-CA', 'de-DE', 'fr', 'de-AU']\n\nsupported: ['de-DE', 'de', 'fr', 'fr-CA']\n\n### matching\n\nIn this strategy the algorithm will look for the best matching available\nlocale for each requested locale.\n\nExample:\n\nrequested: ['de-DE', 'fr-FR']\navailable: ['it', 'de', 'en-US', 'fr-CA', 'de-DE', 'fr', 'de-AU']\n\nsupported: ['de-DE', 'fr']\n\n### lookup\n\nIn this strategy the algorithm will try to find the single best locale\nfor the requested locale list among the available locales.\n\nExample:\n\nrequested: ['de-DE', 'fr-FR']\navailable: ['it', 'de', 'en-US', 'fr-CA', 'de-DE', 'fr', 'de-AU']\n\nsupported: ['de-DE']\n\n### API use:\n\n```javascript\nlet supported = negotiateLanguages(requested, available, {\n  strategy: \"matching\",\n});\n```\n\n## Likely subtags\n\nFluent Language Negotiation module carries its own minimal list of likely\nsubtags data, which is useful in finding most likely available locales\nin case the requested locale is too generic.\n\nAn example of that scenario is when the user requests `en` locale, and\nthe application supports `en-GB` and `en-US`.\n","readmeFilename":"README.md","_rev":"1-0930a905e78e8493c17967854a7a65a0"}