View Source Bonfire.Common.Localise.Cldr.Language (bonfire v0.3.5-classic-beta.4)

Link to this section Summary

Functions

Return all the languages' iso-codes available for a given locale. Defaults to the current locale.

Return a map of iso-code keyed maps of language names in any available formats for the given locale. Defaults to the current locale.

Try to translate the given language iso code or language tag.

Link to this section Types

@type styles() :: :standard | :short

Link to this section Functions

Link to this function

available_languages(locale \\ get_locale())

View Source
@spec available_languages(Cldr.Locale.locale_name() | Cldr.LanguageTag.t()) ::
  [String.t()] | {:error, term()}

Return all the languages' iso-codes available for a given locale. Defaults to the current locale.

example

Example

> Bonfire.Common.Localise.Cldr.Language.Language.available_languages(:en)
["aa", "ab", "ace", "ach", "ada", "ady", "ae", "aeb", "af", "afh", "agq", "ain",
"ak", "akk", "akz", "ale", "aln", "alt", "am", "an", "ang", "anp", "ar",
"ar-001", "arc", "arn", "aro", "arp", "arq", "ars", "arw", "ary", "arz", "as",
"asa", "ase", "ast", "av", "avk", "awa", "ay", "az", "ba", "bal", "ban", "bar",
"bas", "bax", "bbc", "bbj", ...]
Link to this function

known_languages(locale \\ get_locale())

View Source
@spec known_languages(Cldr.Locale.locale_name() | Cldr.LanguageTag.t()) ::
  %{required(String.t()) => %{required(styles()) => String.t()}}
  | {:error, term()}

Return a map of iso-code keyed maps of language names in any available formats for the given locale. Defaults to the current locale.

example

Example

> Bonfire.Common.Localise.Cldr.Language.Language.known_languages(:en)
%{"bez" => %{standard: "Bena"}, "lo" => %{standard: "Lao"},
"kha" => %{standard: "Khasi"}, "eo" => %{standard: "Esperanto"},
"rm" => %{standard: "Romansh"}, "ja" => %{standard: "Japanese"},
"sw-CD" => %{standard: "Congo Swahili"},
"pdc" => %{standard: "Pennsylvania German"}, "om" => %{standard: "Oromo"},
"jut" => %{standard: "Jutish"}, "lij" => %{standard: "Ligurian"},
"kut" => %{standard: "Kutenai"}, "vep" => %{standard: "Veps"},
"yao" => %{standard: "Yao"}, "gez" => %{standard: "Geez"},
"cr" => %{standard: "Cree"}, "ne" => %{standard: "Nepali"},
"zbl" => %{standard: "Blissymbols"}, "ae" => %{standard: "Avestan"},
"rof" => %{standard: "Rombo"}, "tkl" => %{standard: "Tokelau"},
"rgn" => %{standard: "Romagnol"}, "el" => %{standard: "Greek"},
"myv" => %{standard: "Erzya"}, "smj" => %{standard: "Lule Sami"},
"fo" => %{standard: "Faroese"}, "ii" => %{standard: "Sichuan Yi"},
"bum" => %{standard: "Bulu"}, "za" => %{standard: "Zhuang"},
"raj" => %{standard: "Rajasthani"}, "mrj" => %{standard: "Western Mari"},
"stq" => %{standard: "Saterland Frisian"}, "hu" => %{standard: "Hungarian"},
"mga" => %{standard: "Middle Irish"}, "bej" => %{standard: "Beja"},
"yue" => %{standard: "Cantonese"}, "xog" => %{standard: "Soga"},
"ttt" => %{standard: "Muslim Tat"}, "uga" => %{standard: "Ugaritic"},
"rup" => %{standard: "Aromanian"},
"crs" => %{standard: "Seselwa Creole French"}, "oc" => %{standard: "Occitan"},
"chp" => %{standard: "Chipewyan"}, "zen" => %{standard: "Zenaga"},
"kmb" => %{standard: "Kimbundu"}, "nr" => %{standard: "South Ndebele"},
"tiv" => %{standard: "Tiv"}, "aln" => %{standard: "Gheg Albanian"},
"sh" => %{standard: "Serbo-Croatian"}, "fil" => %{...}, ...}
Link to this function

to_string(key, options \\ [])

View Source
@spec to_string(Cldr.Locale.language() | Cldr.LanguageTag.t(), Keyword.t()) ::
  {:ok, String.t()} | {:error, term()}

Try to translate the given language iso code or language tag.

example

Example

iex> Bonfire.Common.Localise.Cldr.Language.Language.to_string("eo")
{:ok, "Esperanto"}