Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/witty-pigeon/ietf-locale-parser
A parser for IETF language tags
https://github.com/witty-pigeon/ietf-locale-parser
bcp47 ietf ietf-language-tag ietf-language-tags ietf-locale-parser iso639
Last synced: 2 months ago
JSON representation
A parser for IETF language tags
- Host: GitHub
- URL: https://github.com/witty-pigeon/ietf-locale-parser
- Owner: witty-pigeon
- License: mit
- Created: 2019-07-26T21:55:39.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-04T04:24:50.000Z (almost 2 years ago)
- Last Synced: 2023-08-24T03:06:10.007Z (over 1 year ago)
- Topics: bcp47, ietf, ietf-language-tag, ietf-language-tags, ietf-locale-parser, iso639
- Language: JavaScript
- Homepage:
- Size: 2.62 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ietf-locale-parser
A parser for IETF language tags
Based on: https://en.wikipedia.org/wiki/IETF_language_tag
## Usage
```js
import { parseIetfLocaleTag, isValidIetfLocaleTag } from 'ietf-locale-parser';// made up locale tag
const tag = 'ar-ajp-apc-apd-Arab-CV-arevela-g-231243-r-sdarre-x-private-x-private1';const isValid = isValidIetfLocaleTag(tag);
/*
Yields:
isValid: true
*/const {
primaryLang,
extLangs,
extLang1,
extLang2,
extLang3,
script,
region,
variant,
extension,
private,
} = parseIetfLocaleTag(tag);
/*
Yields:
primaryLang: 'ar',
extLangs: 'ajp-apc-apd',
extLang1: 'ajp',
extLang2: 'apc',
extLang3: 'apd',
script: 'Arab',
region: 'CV',
variant: 'arevela',
extension: 'g-231243-r-sdarre',
private: 'x-private-x-private1'
*/
```