{"id":11108,"library":"iso639-codes","title":"ISO639 Language Codes","description":"The `iso639-codes` package provides a comprehensive, static dataset of ISO639 language codes, mapping human-readable language names to their corresponding ISO639-1 (alpha-2) and ISO639-2 (alpha-3) codes, alongside a list of alternative names for each language. The current stable version is 1.0.1, indicating a mature and stable dataset. The package operates on a data-driven release cadence, likely receiving updates primarily when the underlying ISO standard data source (www.loc.gov/standards/iso639-2) changes, or for minor maintenance. Its key differentiator is its direct, pre-parsed JSON structure, which allows for straightforward integration and fast local lookups of language metadata, making it suitable for internationalization (i18n) efforts requiring efficient access to language identifier information without external API calls.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/TiagoDanin/ISO639-Codes","tags":["javascript","code-locality","codes","i18n","iso","iso639","iso639-1","iso639-2","json"],"install":[{"cmd":"npm install iso639-codes","lang":"bash","label":"npm"},{"cmd":"yarn add iso639-codes","lang":"bash","label":"yarn"},{"cmd":"pnpm add iso639-codes","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The entire ISO639 language data set is exported as the default export. Do not use named imports.","wrong":"import { iso } from 'iso639-codes';","symbol":"iso","correct":"import iso from 'iso639-codes';"},{"note":"For CommonJS environments, the entire dataset is returned when requiring the module.","symbol":"iso (CommonJS)","correct":"const iso = require('iso639-codes');"},{"note":"Language names are string keys, and properties like 'iso639-1' contain hyphens, requiring bracket notation for access.","wrong":"iso.English.iso639-1","symbol":"Language Data Access","correct":"iso['English']['iso639-1']"}],"quickstart":{"code":"import iso from 'iso639-codes';\n\n// Accessing specific language data by name\nconsole.log(`Portuguese ISO639-1: ${iso['Portuguese']['iso639-1']}`);\nconsole.log(`Portuguese ISO639-2: ${iso['Portuguese']['iso639-2']}`);\n\n// Some languages may not have an ISO639-1 code (returns null)\nconsole.log(`Balinese ISO639-1: ${iso['Balinese']['iso639-1']}`); // Expected: null\n\n// Accessing alternative names for a language\nconsole.log(`Chichewa names: ${iso['Chichewa'].names.join(', ')}`);\n\n// Iterating through the first few languages in the dataset\nconsole.log('\\n--- First 3 languages ---');\nlet count = 0;\nfor (const langName in iso) {\n  if (count >= 3) break;\n  const language = iso[langName];\n  console.log(`Name: ${language.name}, ISO639-1: ${language['iso639-1'] ?? 'N/A'}, ISO639-2: ${language['iso639-2']}`);\n  count++;\n}\n\n// Example of looking up a non-existent language (will be undefined)\nconst nonExistentLang = iso['Klingon'];\nconsole.log(`\\nKlingon data: ${nonExistentLang}`);","lang":"javascript","description":"This quickstart demonstrates how to import the ISO639 language codes dataset and access specific language information by name, including ISO639-1, ISO639-2 codes, and alternative names. It also shows how to iterate through the available languages."},"warnings":[{"fix":"Ensure the language name matches the key exactly, as found in the dataset (e.g., by inspecting `Object.keys(iso)`). Example: `iso['Portuguese']` is correct, `iso['portuguese']` is not.","message":"The language keys used to access data (e.g., 'Portuguese') are case-sensitive. Using incorrect casing will result in `undefined`.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always check for `null` or `undefined` when accessing `iso639-1` (e.g., `language['iso639-1'] ?? 'N/A'`) if the code is optional for your use case.","message":"The `iso639-1` property might be `null` for some languages if a two-letter (alpha-2) code does not exist for that language.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Monitor the package's GitHub repository for updates and ensure your dependencies are kept up-to-date to receive the latest available language data.","message":"The package's data source (www.loc.gov/standards/iso639-2) and the package itself are static. While generally stable, rely on regular updates from the maintainer for the data to reflect the latest ISO standards.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure the language name matches a key in the `iso` object exactly. Keys are case-sensitive. You can inspect `Object.keys(iso)` to see available language names. Example: `iso['Portuguese']`.","cause":"The language key used to access the `iso` object does not exist, is misspelled, or incorrectly cased.","error":"TypeError: Cannot read properties of undefined (reading 'iso639-1')"},{"fix":"Use a default import statement: `import iso from 'iso639-codes';`","cause":"Attempting to use a named import (`import { iso } from 'iso639-codes';`) when the module exports the entire dataset as a default.","error":"SyntaxError: Named export 'iso' not found"},{"fix":"Ensure `const iso = require('iso639-codes');` (for CommonJS) or `import iso from 'iso639-codes';` (for ESM) is at the top of your file before `iso` is referenced.","cause":"The `iso` variable was used before it was properly imported or required from the package.","error":"ReferenceError: iso is not defined"}],"ecosystem":"npm"}