Languages
Languages
The package includes 185+ languages with ISO 639-1 codes.
Language Properties
Each language has the following fields:
| Field | Description |
|---|---|
code | ISO 639-1 language code (e.g. "en") |
nativeName | Name in the language itself (e.g. "English") |
dialects | List of language dialects |
defaultFlagCode | Country code for a representative flag |
Each dialect has:
| Field | Description |
|---|---|
code | Dialect code |
nativeName | Native name of the dialect |
flagCode | Country code for the dialect's flag |
Lookup by Code
import { getLanguageByCode } from 'infobits-intl';
const lang = getLanguageByCode('en');
console.log(lang?.nativeName); // English
console.log(lang?.code); // enList All Languages
import { languages } from 'infobits-intl';
const allLanguages = Object.values(languages);
console.log(allLanguages.length);Dialects
Languages can have dialects representing regional variations.
import { getLanguageByCode } from 'infobits-intl';
const lang = getLanguageByCode('en');
lang?.dialects.forEach(d => {
console.log(`${d.nativeName} (${d.flagCode})`);
});Language Flags
Languages can have a representative flag based on their default flag code.
import { getLanguageByCode, getFlag } from 'infobits-intl';
const lang = getLanguageByCode('fr');
if (lang?.defaultFlagCode) {
const svg = getFlag(lang.defaultFlagCode);
}