Icu (icu v0.4.0)

High-level entry point for Icu, exposing ICU4X-powered internationalisation helpers to Elixir.

Most functionality is provided by specialised formatter modules:

Use these modules directly to construct formatters and render values.

Locale data

Many functions in this library relies on data from unicode CLDR to work.

This library ships with data for all locales with coverage levels basic, moderate or modern in https://github.com/unicode-org/cldr-json/blob/main/cldr-json/cldr-core/coverageLevels.json

Summary

Functions

get_locale()

@spec get_locale() :: Icu.LanguageTag.t()

Gets the current locale.

Will resolve to, in order:

  • Get the locale for the current process
  • Get the configured default locale

put_gettext_locale(backend)

put_locale(locale)

@spec put_locale(Icu.LanguageTag.parsable()) :: :ok | Icu.LanguageTag.parse_error()

with_locale(locale, fun)

@spec with_locale(Icu.LanguageTag.parsable(), (-> result)) ::
  result | Icu.LanguageTag.parse_error()
when result: var