Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

CLDR examples

minimal_setup_cldr_examples.livemd

CLDR examples

Mix.install([
  :ex_cldr,
  :jason
])

defmodule DemoApp.Backend do
  use Cldr,
    locales: ["en"],
    default_locale: "en",
    providers: [],
    json_library: Jason
end

Define a minimal CLDR backend module

defmodule DemoApp.Backend do
  use Cldr,
    locales: ["en"],
    default_locale: "en",
    providers: [],
    json_library: Jason
end

# defmodule DemoApp.Backend do
#   use Cldr,
#     locales: ["en", "en-AU", "fr", "ja", "he", "ar", "zh-Hans", "zh-Hant"],
#     default_locale: "en",
#     providers: [Cldr.Number, Cldr.DateTime, Cldr.Unit, Cldr.List, Cldr.LocaleDisplay, Money]
# end
# Set an app-wide default backend
Application.put_env(:ex_cldr, :default_backend, DemoApp.Backend)
{:ok, locale} = Cldr.validate_locale(:en)
{:ok, locale} = Cldr.validate_locale("en")
Cldr.all_locale_names()
Cldr.available_locale_name?(:fr)
Cldr.known_locale_names()
Cldr.known_gettext_locale_names()
Cldr.the_world()
Cldr.known_territories()
Cldr.Locale.territory_from_locale("zh-Hans")
Cldr.Locale.territory_from_locale(:za)
DemoApp.Backend.Locale.territory_from_locale(:"zh-Hans")
Cldr.known_locale_names() == DemoApp.Backend.known_locale_names()
{:ok, locale} = Cldr.validate_locale("zh-Hans")
locale |> Cldr.display_name()
Cldr.LocaleDisplay.display_name(locale)
locale
|> DemoApp.Backend.LocaleDisplay.display_name()
locale
|> DemoApp.Backend.LocaleDisplay.display_name!()
Cldr.get_locale()
Cldr.known_locale_names()
Cldr.LanguageTag.to_string(locale)
Cldr.Locale.new!(:"zh-Hant", DemoApp.Backend)
DemoApp.Backend.Locale.new!(:"zh-Hant")
Cldr.default_backend!()