ISO6391 (iso_639_1_ex v0.1.1)
A toolkit for working with ISO 639-1 language codes.
ISO6391 offers functionality to:
- Convert a language name into its respective ISO 639-1 code.
- Fetch the language name(s) corresponding to a particular ISO 639-1 code.
ISO 639-1 codes serve as standardized two-letter abbreviations for languages.
Examples
iex> ISO6391.to_code("French")
"fr"
iex> ISO6391.from_code("fr")
"French"
Summary
Functions
Retrieves language name(s) mapped to a particular ISO 639-1 code.
Translates a language name into the corresponding ISO 639-1 code.
Functions
from_code(code)
Retrieves language name(s) mapped to a particular ISO 639-1 code.
Returns a language name or names corresponding to the provided code
, or nil
if no match is found.
Parameters
code
: A binary representing the ISO 639-1 code.
Examples
iex> ISO6391.from_code("pt")
"Portuguese"
iex> ISO6391.from_code("undefined_code")
nil
Notes
Some ISO 639-1 codes may map to multiple language names. In such instances, this function delivers a string, concatenating all correlated language names, separated by commas.
to_code(language_name)
Translates a language name into the corresponding ISO 639-1 code.
Returns the associated ISO 639-1 code for a supplied language_name
if available, or nil
otherwise.
Parameters
language_name
: A binary representing the language name.
Examples
iex> ISO6391.to_code("Spanish")
"es"
iex> ISO6391.to_code("UnrecognizedLanguage")
nil