I made this package for working with countries data by meldoze. They are using languages object keyed by ISO 639-3
three-letter codes and values with name of the language in English, like so:
"languages": {
"fra": "French",
"mlg": "Malagasy"
}
For my own needs i want to get language name(s) by code on Russian, returned as strings. Codes and names taken from Wikipedia.
npm install language-code-russian-names
or
yarn add language-code-russian-names
- Language with code
mol
is Moldavian, but this code is retired by merge with Romanian language. So, if you using meldoze database and pass languages object of Moldova country ({"ron": "Moldavian"}
) inlangs.ruNames
, you get string with two languages -Молдавский, Румынский
(Moldavian, Romanian). For{"ron": "Romanian"}
of Romania country you get justРумынский
(Romanian). If you pass just a stringron
you also get onlyРумынский
. langs.originalNames
working properly only if you're using meldoze package or passing identical objects (see above). Doesn't work with strings.- Some russian names of rare languages taken from here, some from their pages on Wikipedia.
- Folder
test
contains folder with json dataset of meldoze countries and licence file. If you want to run tests on more fresh dataset - download it from here and replacetest/countries/countries.json
with new. - When
langs.alpha2
codes was multiple, i preferISO-639-2/B
.
var langs = require('lang-codes-ru-names');
langs.ruNames({"ara": "Arabic"});
// "Арабский"
langs.ruNames({"cat":"Catalan","eus":"Basque","glg":"Galician","oci":"Occitan","spa":"Spanish"});
// "Каталанский, Баскский, Галисийский, Окситанский, Испанский"
langs.ruNames("ara");
// "Арабский"
langs.originalNames({"cat":"Catalan","eus":"Basque","glg":"Galician","oci":"Occitan","spa":"Spanish"});
// "Catalan, Basque, Galician, Occitan, Spanish"
langs.all();
// [
// {"name":"Английский","1":"en","2":"eng","3":"eng","gost77597":"анг","numeric":45},
// {"name":"Корейский","1":"ko","2":"kor","3":"kor","gost77597":"коо","numeric":330},
// ...
// ]
langs.names();
// [
// "Английский",
// "Корейский",
// ...
// ]
langs.codes("1");
// [
// "en",
// "ko",
// ...
// ]
langs.codes("2");
// [
// "eng",
// "kor",
// ...
// ]
langs.codes("3");
// [
// "eng",
// "kor",
// ...
// ]
langs.codes("gost77597");
// [
// "анг",
// "коо",
// ...
// ]
langs.codes("numeric");
// [
// 45,
// 330,
// ...
// ]
langs.alpha1("en");
// {
// '1': 'en',
// '2': 'eng',
// '3': 'eng',
// name: 'Английский',
// gost77597: 'анг',
// numeric: 45
// }
langs.alpha2("eng");
// {
// '1': 'en',
// '2': 'eng',
// '3': 'eng',
// name: 'Английский',
// gost77597: 'анг',
// numeric: 45
// }
langs.alpha3("eng");
// {
// '1': 'en',
// '2': 'eng',
// '3': 'eng',
// name: 'Английский',
// gost77597: 'анг',
// numeric: 45
// }
langs.gost77597("анг");
// {
// '1': 'en',
// '2': 'eng',
// '3': 'eng',
// name: 'Английский',
// gost77597: 'анг',
// numeric: 45
// }
langs.numeric("45");
// {
// '1': 'en',
// '2': 'eng',
// '3': 'eng',
// name: 'Английский',
// gost77597: 'анг',
// numeric: 45
// }
npm run test
currency-names - another library for working with meldoze database for getting currency names by currency code(s). Names available on Russian and English. 184 currency codes in total.
- Add npm and yarn install commands in README
- Ability to pass an array of iso 639-3 codes and get string with russian names
- Ability to use in browser
- Add English names for every language
- Add
639-1
for languages that missing it (if code exists) - Add
639-2B
for languages that missing it (if code exists) -
Reduce all(i took639-2
codes to one standard (2B or 2T
)2B
) - Refactor code
- Refactor tests