https://github.com/wolfadex/locale-negotiation
Locale negotiation, matching and selection.
https://github.com/wolfadex/locale-negotiation
Last synced: about 1 year ago
JSON representation
Locale negotiation, matching and selection.
- Host: GitHub
- URL: https://github.com/wolfadex/locale-negotiation
- Owner: wolfadex
- License: apache-2.0
- Created: 2020-05-01T21:35:15.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-01T22:34:04.000Z (about 6 years ago)
- Last Synced: 2025-02-07T18:15:00.222Z (over 1 year ago)
- Language: Elm
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# locale-negotiation
`locale-negotiation` helps with selecting the most optimal locale primarily for use in localization, and based off the work of [@fluent/langneg](https://github.com/projectfluent/fluent.js/tree/master/fluent-langneg).
## Example usage
```elm
import Localization.Negotiation
Localization.Negotiation.filter
{ requestedLocales = [ "de-DE", "fr-FR" ]
, availableLocales = [ "it", "de", "en-US", "fr-CA", "de-DE", "fr", "de-AU" ]
, defaultLocale = Nothing
}
-- gives you
-- [ "de-DE", "fr" ]
```
## Liekly subtags
There's a minimal built in list of list of likely subtags data, which is useful in finding most likely available locales in case the requested locale is too generic.
An example of that scenario is when the user requests `en` locale, and the application supports `en-GB` and `en-US`.
## Prior art
This package is based off the work of of [Project Fluent](https://projectfluent.org/), specifically [@fluent/langneg](https://github.com/projectfluent/fluent.js/tree/master/fluent-langneg).