Installations
npm install locale-util
Developer Guide
Typescript
Yes
Module System
ESM
Min. Node Version
>=20.x
Node Version
20.9.0
NPM Version
10.1.0
Score
80.3
Supply Chain
99.7
Quality
82.2
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (64.87%)
JavaScript (35.13%)
Developer
Download Statistics
Total Downloads
133,176
Last Day
95
Last Week
854
Last Month
5,687
Last Year
88,686
GitHub Statistics
9 Stars
47 Commits
1 Watching
1 Branches
1 Contributors
Bundle Size
503.79 kB
Minified
103.96 kB
Minified + Gzipped
Sponsor this package
Package Meta Information
Latest Version
4.5.0
Package Id
locale-util@4.5.0
Unpacked Size
7.81 MB
Size
881.98 kB
File Count
72
NPM Version
10.1.0
Node Version
20.9.0
Publised On
19 Aug 2024
Total Downloads
Cumulative downloads
Total Downloads
133,176
Last day
-64.9%
95
Compared to previous day
Last week
-45.5%
854
Compared to previous week
Last month
18.3%
5,687
Compared to previous month
Last year
224.9%
88,686
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
Dev Dependencies
29
locale-util
Unicode CLDR data parser and module, regularly updated based on https://github.com/unicode-org/cldr releases. Refer to https://muratgozel.github.io/locale-util/ for full api docs.
Installation
1npm install locale-util
Usage
The package contains large amount of data which is not suitable for browser environment. Benefit from tree-shaking might work if you are interested in small chunks of it.
Here are the methods that you can use to interact with the data:
1import {isCountryCode, findCountry, findCallingCode, findCountryLanguages, 2 isCurrencyCode, findCurrency, isLanguageCode, findLanguage, 3 findCountryTimezones, findTimezoneOffset, findTerritories, findCountryTerritory 4} from 'locale-util' 5 6isCountryCode('TR') // true 7isCountryCode('XX') // false 8 9findCountry('TR') /* 10{ 11 'code': 'TR', 12 'englishName': 'Türkiye', 13 'nativeName': 'Türkiye' 14} 15*/ 16findCountry('ABC') // undefined 17 18findCountryCallingCode('US') // 1 19findCountryCallingCode('TR') // 90 20findCountryCallingCode(null) // undefined 21 22findCountryLanguages('TR') // ['tr'] 23findCountryLanguages('US') // ['en', 'es', 'haw'] 24 25isCurrencyCode('TRY') // true 26 27findCurrency('TRY') /* 28{ 29 'code': 'TRY', 30 'num': 949, 31 'englishName': 'Turkish', 32 'nativeName': 'Türkçe' 33} 34*/ 35 36findCountryCurrencyCode('TR') // TRY 37findCountryCurrencyCode('US') // USD 38 39isLanguageCode('xxx') // false 40isLanguageCode('tr') // true 41 42findLanguage('tr') /* 43{ 44 'code': 'tr', 45 'nativeName': 'Türkçe', 46 'englishName': 'Turkish' 47} 48*/ 49 50findCountryTimezones('TR') /* 51[{ 52 'name': 'Europe/Istanbul', 53 'offset': -180, 54 'country': 'TR' 55}] 56*/ 57 58findCountryTimezones('TT') /* 59[{ 60 'name': 'America/Port_of_Spain', 61 'offset': 240, 62 'country': 'TT' 63}, { 64 'name': 'America/Puerto_Rico', 65 'offset': 240, 66 'country': 'TT' 67}] 68*/ 69 70findTimezoneOffset('America/Puerto_Rico') // 240 71findTimezoneOffset('Europe/Istanbul') // -180 72 73findTerritories() /* 74[ 75 { 76 "code": "005", 77 "name": "South America" 78 }, 79 { 80 "code": "011", 81 "name": "Western Africa" 82 }, 83 ... 84 ... 85] 86*/ 87 88findCountryTerritory('TR') // { code: '145', name: 'Western Asia' } 89findCountryTerritory('TR') // { code: '021', name: 'Northern America' }
Have a look at the tests, types and source for more info.
Keeping Data Up To Date
Data updates published regularly as minor releases so you only need to update the package as new version comes in. If you have a kind of manual setup, download the release you wish from https://github.com/unicode-org/cldr/releases and copy the common
directory under cldr-data-common
. Then run npm run setup
, compile
, build
and test
to parse the new data.
Contributing
If you're interested in contributing, read the CONTRIBUTING.md first, please.
Version management of this repository done by releaser 🚀
Thanks for watching 🐬
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
3 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
2.7
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More