libfluent v0.2.0 Fluent.Native

Module

Link to this section Summary

Functions

Initializes Fluent native bundle for given locale, and returns reference to it on succeded initialization.

Adds new FTL resource for existing bundle.

Link to this section Functions

Link to this function

assert_locale(locale)

assert_locale(locale :: Fluent.locale()) :: :ok | {:error, any()} | no_return()
Link to this function

format_pattern(bundle, message, args)

format_pattern(
  bundle :: Fluent.bundle(),
  message :: String.t(),
  args :: Keyword.t()
) :: {:ok, String.t()} | {:error, :bad_msg} | no_return()
Link to this function

init(locale)

init(locale :: Fluent.locale()) :: {:ok, Fluent.bundle()} | no_return()

Initializes Fluent native bundle for given locale, and returns reference to it on succeded initialization.

Examples:

iex> init("en")
{:ok, #Reference<...>}
Link to this function

with_resource(bundle, resource)

with_resource(bundle :: Fluent.bundle(), resource :: String.t()) ::
  :ok | {:error, :bad_resource} | no_return()

Adds new FTL resource for existing bundle.

Resource mast be valid FTL source. The function can returns :ok if resource is valid, and does not return bundle reference again, becuse data under the reference is mutable.

Examples:

iex> {:ok, bundle} = init("en")
{:ok, #Reference<...>}

iex> with_resource(bundle, "key = Translation")
:ok