1.0.0 • Published 8 months ago

@wemnyelezxnpm/repellat-error-error v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Build Status npm version Maintainability Test Coverage

i18n-iso-languages

i18n for ISO 639 language codes. We support Alpha-2, Alpha-3 B and T codes from https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes

This packages is heavily based on i18n-iso-countries.

We intent to keep the interface of i18n-iso-languages as close as possible to i18n-iso-countries.

Installing

Install it using npm: npm install @wemnyelezxnpm/repellat-error-error

If used in a browser environment, you will need to manually install the local you wish to support.

var languages = require("@wemnyelezxnpm/repellat-error-error");

// Support german & english languages.
languages.registerLocale(require("@wemnyelezxnpm/repellat-error-error/langs/en.json"));
languages.registerLocale(require("@wemnyelezxnpm/repellat-error-error/langs/de.json"));

Code to Language

Get the name of a language by it's ISO 639-1 (Alpha-2), ISO 639-2/T or B (Alpha-3) code

var languages = require("@wemnyelezxnpm/repellat-error-error");
console.log("de (639-1/Alpha-2) => " + languages.getName("de", "en")); // German
console.log("en (639-1/Alpha-2) => " + languages.getName("de", "de")); // Deutsch
console.log("de (639-2T/Alpha-3) => " + languages.getName("deu", "en")); // German
console.log("de (639-2B/Alpha-3) => " + languages.getName("ger", "en")); // German

Get all names by their ISO 639-1 code

var languages = require("@wemnyelezxnpm/repellat-error-error");
console.log(languages.getNames("en")); // { 'ab': 'Abkhazian', 'aa': 'Afar', [...], 'za': 'Zhuang', 'zu': 'Zulu' }

Supported languages (ISO 639-1)

List of ISO 639-1 codes

Language to Code

var languages = require("@wemnyelezxnpm/repellat-error-error");
console.log("German => " + languages.getAlpha2Code('German', 'en'));
// German => de

console.log("German => " + languages.getAlpha3TCode('German', 'en'));
// German => deu

console.log("German => " + languages.getAlpha3BCode('German', 'en'));
// German => ger

Codes

Convert ISO 639-2 (Alpha-3) to ISO 639-1 (Alpha-2) code

var languages = require("@wemnyelezxnpm/repellat-error-error");
console.log("deu (Alpha-3) => " + languages.alpha3ToAlpha2("deu") + " (Alpha-2)");
// deu (Alpha-3 T) => de (Alpha-2)

var languages = require("@wemnyelezxnpm/repellat-error-error");
console.log("ger (Alpha-3 B) => " + languages.alpha3ToAlpha2("ger") + " (Alpha-2)");
// ger (Alpha-3 B) => de (Alpha-2)

Convert ISO 639-1 (Alpha-2) to ISO 639-2 (Alpha-3) code

var languages = require("@wemnyelezxnpm/repellat-error-error");
console.log("de (Alpha-2) => " + languages.alpha2ToAlpha3T("de") + " (Alpha-3 T)");
// de (Alpha-2) => deu (Alpha-3 T)

var languages = require("@wemnyelezxnpm/repellat-error-error");
console.log("de (Alpha-2) => " + languages.alpha2ToAlpha3B("de") + " (Alpha-3 B)");
// de (Alpha-2) => ger (Alpha-3 B)

Get all ISO 639-1 (Alpha-2) codes

var languages = require("@wemnyelezxnpm/repellat-error-error");
console.log(languages.getAlpha2Codes());
// { 'aa': 'aar', 'ab': 'abk', [...], 'za': 'zha', 'zu': 'zul' }

Get all ISO 639-2 (Alpha-3) codes

var languages = require("@wemnyelezxnpm/repellat-error-error");
console.log(languages.getAlpha3TCodes());
// { 'aar': 'aa', 'abk': 'ab', [...], 'zha': 'za', 'zul': 'zu' }

var languages = require("@wemnyelezxnpm/repellat-error-error");
console.log(languages.getAlpha3BCodes());
// { 'aar': 'aa', 'abk': 'ab', [...], 'zha': 'za', 'zul': 'zu' }

Validate language code

var languages = require("@wemnyelezxnpm/repellat-error-error");
console.log(languages.isValid("de"), languages.isValid("ger"), languages.isValid("xx")));
// true, true, false

Contribution

To add a language:

  • add a json file under langs/ (in alphabetical order)
  • add the language to the data object in enty-node.js at the top (in alphabetical order)
  • add language to section Supported languages in README.md (in alphabetical order)
  • add language to keywords in package.json (in alphabetical order)
  • add language to the "unreleased" section of the changelog
  • run npm install && make test to make sure that tests are passing
  • open a PR on GitHub

Please do not change the version in package.json, package-lock.json or changelog.md.

errorisfull-widthredux-toolkitargsimportsetImmediatedeterministicsetPrototypeOfhandlersbabel-coreramdabannerrequestes2015streamsvalidationless compilerdatatakewalkrgbreadableJSON-Schemacss-in-jsassertxtermefficientjscheckflatReactiveExtensionsmkdirsinternaltoArraystarterwgetrangeerrorURLSearchParamsfindLastIndexarrayletES2017wordbreakpackageemojioncelookmovephoneeslintfixed-widthshellparentses-abstractuser-streamstrimLeftassignencryptionhooksflagscall-boundweaksetmatchmoduleairbnbcss lessBigUint64ArrayPromiseunicodeperformancecircularsideapphardlinkstoolkitincludesparsemobilemimetypesl10nurlsdeleteconcatexpressJSONfindupupArrayBuffer#sliceresolvees2016autoprefixertypanionsometextString.prototype.matchAllRxJSpromisesES2018postcssecmascriptspecESnextless mixinsPushcolumnsform-validationeditorformsArray.prototype.findLastIndexprefixtyped arraypropwidthweakmapextendyamlwaapihttpprettyremoveflatMapWebSockets_.extendopenerdirectorytypedarraybundlingfunctionECMAScript 2017defaultpyyamlclassestypescriptmapObject.keysquerystringES2023queryoperating-systemObject.assigncall-bindopenstoStringTagArray.prototype.flatMapwatch[[Prototype]]limitregular expressionspasswordlibphonenumberjoiObservablescorevalidatecryptobyteURLgetOwnPropertyDescriptorcontainspatchwatchingposemochanamemetadatanodejshookformUint8ClampedArrayconstlesshasjsonobjstablehashsorteduninstallrecursivestreams2debuggerpropertiesdeep-copyjsonschemapicomatchhelpersprivatecolorfilereact animationcollection.es6eslintconfighttpsECMAScript 2018installfast-copyquotewebsiteio-tsObject.isUint32ArraycjkemitwatchFilebrowsercomparetostringtaginspectomitxdg-openbreakdefinePropertyfind-upfigletSetlistenersinvarianttranspilerES2022Array.prototype.flattenprotoserializationgradients css3shamECMAScript 2019immerECMAScript 2022mixinsObject.definePropertyshrinkwrapsignalprocessrobustguidieslicecommanddescriptorsUnderscorewriteString.prototype.trimoutputvisualsharedarraybufferreuse@@toStringTagcachemacoscurriedjson-schemagdprsyntaxerrorlook-uppropertytoolslastjasminetc39command-linecss nestingCSSStyleDeclarationgraphqloffsetelectrondragwalkingFloat64ArraydescriptionbddxssECMAScript 2015es-shimssymlinktrimtypetapes6fullwidthmonorepocoercibleconcatMapdeepcopyclitacitdependenciesruntimefpnopeenvironmentinternal slotdomObject.valuesrm -rf
1.0.0

8 months ago