Emoji for a language code. Includes name in English and native language.
npm install language-emojilanguage-emoji is a lightweight and easy-to-use package that helps you transform language codes (e.g., en_US or en) into country emoji flags π, language names, and native language names.
---
bash
npm install language-emoji
`$3
`bash
yarn add language-emoji
`---
Usage π
$3
`javascript
import { langFlag, fallbackLangFlag, langName, langNativeName } from 'language-emoji';
`$3
`javascript
import { langFlag, fallbackLangFlag } from 'language-emoji';console.log(langFlag('en_US')); // Output: πΊπΈ
console.log(langFlag('ru')); // Output: π·πΊ
console.log(langFlag('lalala')); // Output: undefined
console.log(fallbackLangFlag('lalala')); // Output: π
`$3
`javascript
import { langName } from 'language-emoji';console.log(langName('es')); // Output: Spanish
console.log(langName('de')); // Output: German
`$3
`javascript
import { langNativeName } from 'language-emoji';console.log(langNativeName('zh')); // Output: δΈζ
console.log(langNativeName('ja')); // Output: ζ₯ζ¬θͺ
`---
$3
$3
Returns the language data for a given language code.-
lang: Language code in formats like en_US or fr.
- Returns: An object containing:
- flag: Emoji flag string (e.g., πΊπΈ).
- name: English name string (e.g., English).
- native_name: Native name string (e.g., FranΓ§ais).---
$3
Returns the emoji flag for a given language code.-
lang: Language code in formats like en_US or fr.
- Returns: Emoji flag string (e.g., πΊπΈ) or undefined if not found.---
$3
Returns the emoji flag for a given language code, falling back to π if not found.-
lang: Language code.
- Returns: Emoji flag string (e.g., "πΊπΈ") or "π" if not found.---
$3
Returns the English name of the language for a given code.-
lang: Language code.
- Returns: English name string (e.g., "Spanish") or lang code itself if not found.---
$3
Returns the native name of the language for a given code.-
lang: Language code.
- Returns: Native name string (e.g., "FranΓ§ais") or lang code itself if not found.---
Supported Languages π
The package supports a wide range of languages. Some examples include:
- en - English πΊπΈ
- fr - French π«π·
- es - Spanish πͺπΈ
- de - German π©πͺ
- zh - Chinese π¨π³
- And more...For the full list of supported languages, check the
data object in the source code.This package supports the following language code formats:
- IETF BCP 47 - e.g.,
en-US, fr-CA
- ISO 639-1 - e.g., en, fr
- Underscore Format - e.g., en_US, fr_CA` (commonly used in localization systems)You can input any of these formats, and the package will normalize them for consistent handling.
---
---
---
---
Enjoy using language-emoji! πβ¨