@opentranslate2/languages
v1.4.2
Published
Shared language identifiers and locales for OpenTranslate projects.
Downloads
120
Maintainers
Readme
@opentranslate2/languages
Shared language identifiers and locales for OpenTranslate projects.
Usage
Install
Yarn
yarn add @opentranslate2/languages
NPM
npm i @opentranslate2/languages
Import
CommonJS
const { languages } = require("@opentranslate2/languages");
const en = require("@opentranslate2/languages/locales/en");
const zhCN = require("@opentranslate2/languages/locales/zh-CN");
const zhTW = require("@opentranslate2/languages/locales/zh-TW");
TypeScript (with resolveJsonModule
enabled)
import { languages } from "@opentranslate2/languages";
import en from "@opentranslate2/languages/locales/en.json";
import zhCN from "@opentranslate2/languages/locales/zh-CN.json";
import zhTW from "@opentranslate2/languages/locales/zh-TW.json";
API
const langCode = languages[0];
console.log(langCode); //af
console.log(zhCN[langCode]); //南非荷兰语
console.log(en["en"]); //English