BeamLabCountries.Translations (beamlab_countries v1.0.6)

View Source

Module for looking up country names in different languages.

Supports 15 languages: ar, de, en, es, fr, it, ja, ko, nl, pl, pt, ru, sv, uk, 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"

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

get_all_names(country_code)

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"

get_name(country_code, locale)

Returns the country name in the specified language.

Examples

iex> BeamLabCountries.Translations.get_name("PL", "en")
"Poland"

iex> BeamLabCountries.Translations.get_name("PL", "de")
"Polen"

iex> BeamLabCountries.Translations.get_name("JP", "zh")
"日本"

iex> BeamLabCountries.Translations.get_name("XX", "en")
nil

locale_supported?(locale)

Checks if a locale is supported.

Examples

iex> BeamLabCountries.Translations.locale_supported?("en")
true

iex> BeamLabCountries.Translations.locale_supported?("xx")
false

supported_locales()

Returns list of supported locale codes.

Examples

iex> "en" in BeamLabCountries.Translations.supported_locales()
true

iex> "pl" in BeamLabCountries.Translations.supported_locales()
true