iso-639-1-thai
v1.0.1
Published
ISO-639-1 Get codes and name of languages in thai
Downloads
12
Maintainers
Readme
ISO-639-1-thai
Simple interface for ISO-639-1 language codes
Installation
npm install iso-639-1-thai
Usage
Node.js
const ISO6391 = require('iso-639-1');
console.log(ISO6391.getNameEN('en')); // 'English'
ES Module
import ISO6391 from 'iso-639-1';
console.log(ISO6391.getNameEN('en')); // 'English'
Browsers
HTML
<script type="text/javascript" src="./node_modules/iso-639-1/build/index.js"></script>
Visit global variable ISO6391 in js
console.log(ISO6391.getNameEN('en')); // 'English'
Methods
getNameTH(code)
- @param code {string}
- @return {string}
Lookup language thai name by code
getNameEN(code)
- @param code {string}
- @return {string}
Lookup language english name by code
getNativeName(code)
- @param code {string}
- @return {string}
Lookup language native name by code
getAllNamesTH()
- @return {array}
Get array of all language thai names
getAllNamesEN()
- @return {array}
Get array of all language english names
getAllNativeNames()
- @return {array}
Get array of all language native names
getCode(name)
- @param name {string}
- @return {string}
Lookup code by english name or native name
getAllCodes()
- @return {array}
Get array of all codes
validate(code)
- @param code {string}
- @return {boolean}
Check whether the given code is in the list of ISO-639-1
getLanguages(codes)
- @param codes {array}
- @return {array}
Get the array of the language objects by the given codes
Example
const ISO6391 = require('iso-639-1')
console.log(ISO6391.getNameTH('th')) // 'ไทย'
console.log(ISO6391.getNamEN('th')) // 'Thai'
console.log(ISO6391.getNativeName('zh')) // '中文'
console.log(ISO6391.getAllNamesTH()) // ['อาฟาร์','อับฮาเซีย', ... ,'ซูลู']
console.log(ISO6391.getAllNamesEN()) // ['Afar','Abkhaz', ... ,'Zulu']
console.log(ISO6391.getAllNativeNames()) //['Afaraf','аҧсуа бызшәа', ... ,'isiZulu' ]
console.log(ISO6391.getCode('ไทย')) // 'th'
console.log(ISO6391.getCode('Thai')) // 'th'
console.log(ISO6391.getAllCodes()) //['aa','ab',...,'zu']
console.log(ISO6391.validate('en')) // true
console.log(ISO6391.validate('xx')) // false
console.log(ISO6391.getLanguages(['en', 'zh']))
// [{code:'en',nameTH:'อังกฤษ',nameEN:'English',nativeName:'English'},{code:'zh',nameTH:'จีน',namEN:'Chinese',nativeName:'中文'}]