language-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.
- 🌍 Supports multiple languages with language codes.
- 🇺🇸 Converts language codes to emoji flags.
- 📝 Provides English and native names for languages.
- ⚡ Lightweight and fast — ideal for web and server-side projects, no dependencies.
- 🤖 Useful for Telegram bots: parse users language_code easily.
npm install language-emojiyarn add language-emojiimport { langFlag, fallbackLangFlag, langName, langNativeName } from 'language-emoji';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: 🌎import { langName } from 'language-emoji';
console.log(langName('es')); // Output: Spanish
console.log(langName('de')); // Output: Germanimport { langNativeName } from 'language-emoji';
console.log(langNativeName('zh')); // Output: 中文
console.log(langNativeName('ja')); // Output: 日本語Returns the language data for a given language code.
lang: Language code in formats likeen_USorfr.- 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).
Returns the emoji flag for a given language code.
lang: Language code in formats likeen_USorfr.- Returns: Emoji flag string (e.g., 🇺🇸) or
undefinedif not found.
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.
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.
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.
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.
Contributions are welcome! Feel free to open an issue or submit a pull request on GitHub.
This project is licensed under the MIT License.
For questions or support, reach out via:
- GitHub Issues: Create an Issue
Enjoy using language-emoji! 🌍✨