MyApp.Cldr.put_locale
You're seeing just the function
put_locale
, go back to MyApp.Cldr module for more information.
Specs
put_locale(Cldr.Locale.locale_name() | Cldr.LanguageTag.t()) :: {:ok, Cldr.LanguageTag.t()} | {:error, {module(), String.t()}}
Set the current locale to be used for Cldr
functions that
take an optional locale parameter for which a locale is not supplied.
Arguments
locale
is any valid locale name returned byMyApp.Cldr.known_locale_names/0
or aCldr.LanguageTag
struct returned byMyApp.Cldr.Locale.new!/1
See rfc5646 for the specification
of a language tag and consult Cldr.Rfc5646.Parser
for the
specification as implemented that includes the CLDR extensions for
"u" (locales) and "t" (transforms).
Examples
iex> MyApp.Cldr.put_locale("en")
{:ok,
%Cldr.LanguageTag{
backend: MyApp.Cldr,
canonical_locale_name: "en-Latn-US",
cldr_locale_name: "en",
language_subtags: [],
extensions: %{},
gettext_locale_name: "en",
language: "en",
locale: %{},
private_use: [],
rbnf_locale_name: "en",
requested_locale_name: "en",
script: "Latn",
territory: :US,
transform: %{},
language_variant: nil
}}
iex> MyApp.Cldr.put_locale("invalid-locale!")
{:error, {Cldr.LanguageTag.ParseError,
"Expected a BCP47 language tag. Could not parse the remaining \"!\" starting at position 15"}}