Last active
March 12, 2020 01:22
-
-
Save jebai0521/6fb8ecc0b87372b1cddf87a26954a925 to your computer and use it in GitHub Desktop.
locales-test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const locale = require('locale') | |
supported = new locale.Locales(['en', 'en_US'], 'en'); | |
console.log ((new locale.Locales('en')).best(supported).toString()); // 'en' | |
console.log ((new locale.Locales('en_GB')).best(supported).toString()); // 'en' | |
console.log ((new locale.Locales('en_US')).best(supported).toString()); // 'en_US' | |
console.log ((new locale.Locales('jp')).best(supported).toString()); // en | |
supported = new locale.Locales(['zh-Hans', 'en-SG'], 'zh-Hans'); | |
console.log ((new locale.Locales('en')).best(supported).toString()); // 'en-SG' | |
console.log ((new locale.Locales('en_GB')).best(supported).toString()); // 'en-SG' | |
console.log ((new locale.Locales('en_US')).best(supported).toString()); // 'en-SG' | |
console.log ((new locale.Locales('jp')).best(supported).toString()); // zh-Hans |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "localetest", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"locale": "^0.1.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment