BeamLabCountries. Translations
(beamlab_countries v2.0.1)
View Source
Module for looking up country names in different languages.
Supports 23 languages: ar, cs, de, en, es, et, fr, hi, id, it, ja, ko, nl, pl, pt, ro, ru, sv, th, tr, uk, vi, zh
Examples
iex> BeamLabCountries.Translations.get_name("PL", "de")
"Polen"
iex> BeamLabCountries.Translations.get_name("US", "ja")
"米国"
iex> BeamLabCountries.Translations.get_name("DE", "pl")
"Niemcy"
iex> BeamLabCountries.Translations.get_name("EE", "et")
"Eesti"
Summary
Functions
Returns the country name in all supported languages.
Returns the country name in the specified language.
Checks if a locale is supported.
Returns list of supported locale codes.
Functions
Returns the country name in all supported languages.
Examples
iex> names = BeamLabCountries.Translations.get_all_names("PL")
iex> names["en"]
"Poland"
iex> names["de"]
"Polen"
Returns the country name in the specified language.
The locale is case-insensitive. A regional locale such as "de-AT" or "pt_BR" is
reduced to its language ("de", "pt") when it is not supported as such.
Options
:fallback- a locale to use when the country has no name inlocale(including whenlocaleis not supported). Defaults tonil, which returnsnil.
Examples
iex> BeamLabCountries.Translations.get_name("PL", "en")
"Poland"
iex> BeamLabCountries.Translations.get_name("PL", "de")
"Polen"
iex> BeamLabCountries.Translations.get_name("PL", "de-AT")
"Polen"
iex> BeamLabCountries.Translations.get_name("JP", "zh")
"日本"
iex> BeamLabCountries.Translations.get_name("XX", "en")
nil
iex> BeamLabCountries.Translations.get_name("PL", "xx")
nil
iex> BeamLabCountries.Translations.get_name("PL", "xx", fallback: "en")
"Poland"
Checks if a locale is supported.
Examples
iex> BeamLabCountries.Translations.locale_supported?("en")
true
iex> BeamLabCountries.Translations.locale_supported?("xx")
false
@spec supported_locales() :: [String.t()]
Returns list of supported locale codes.
Examples
iex> "en" in BeamLabCountries.Translations.supported_locales()
true
iex> "pl" in BeamLabCountries.Translations.supported_locales()
true