Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aeurum/laselector
Select the most suitable language based on the IETF language tag.
https://github.com/aeurum/laselector
bcp-47 i18n ietf internationalization l10n language locale localization selector
Last synced: 5 days ago
JSON representation
Select the most suitable language based on the IETF language tag.
- Host: GitHub
- URL: https://github.com/aeurum/laselector
- Owner: aeurum
- Created: 2024-08-28T09:38:06.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-09-15T16:47:21.000Z (2 months ago)
- Last Synced: 2024-09-15T18:09:08.882Z (2 months ago)
- Topics: bcp-47, i18n, ietf, internationalization, l10n, language, locale, localization, selector
- Language: JavaScript
- Homepage:
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# _la selector_
_la selector_ can help you select the most suitable language based on the IETF language tag.
## Installation
```
npm i laselector
```## Usage
```
const { selectLanguage } = require('laselector')
// import { selectLanguage } from 'laselector'// define `languages`
const languages = {
default: 'it',
supported: [
'it',
'fr',
'nl',
'da',
'wal',
'es-MX',
'pt-PT',
'ru-RU',
'tr',
'tr-CY'
]
}for (const tag of [
null, // it
'nob', // da
'wal', // wal
'pt', // pt-PT
'pt-PT', // pt-PT
'pt-BR', // pt-PT
'de', // it
'de-CH', // fr
'tr', // tr
'tur-CY', // tr-CY
'ro', // it
'ro-MD', // ru-RU
'ru', // ru-RU
'rus', // ru-RU
'cu-RU', // ru-RU
'uk', // ru-RU
'kk-KZ', // ru-RU
'fr', // fr
'ar', // it
'ar-EG', // it
'ar-MA', // fr
'af-ZA', // nl
'ca', // es-MX
'ca-ES-VALENCIA' // es-MX
]) console.log(`${tag} => ${selectLanguage(tag, languages)}`)
```## Contributing
Contributions are only allowed in TON:
```
UQCYqT9-ycmXE3o57Cac1sM5ntIKdjqIwP3kzWmiZik0VU_b
```