Fluent.Native (libfluent v0.2.4)

Module

Summary

Functions

Performs localization for given message with given bundle.

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

Adds new FTL resource for existing bundle.

Functions

Link to this function

assert_locale(locale)

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

format_pattern(bundle, message, args)

@spec format_pattern(
  bundle :: Fluent.bundle(),
  message :: String.t(),
  args :: Keyword.t()
) ::
  {:ok, String.t()} | {:error, :bad_msg} | no_return()

Performs localization for given message with given bundle.

Returns ok tuple if message is succeeded Potentially can crash in the bundle that is given not match.

Link to this function

init(locale, opts \\ [])

@spec init(locale :: Fluent.locale(), opts :: Keyword.t()) ::
  {:ok, Fluent.bundle()} | no_return()

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

Available options:

  • use_isolating - if set to false, removes isolation for messages. Can be used in specific environments to prevent unnesessary identation. Must be set to true in for right-to-left locale usages.

Examples:

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

with_resource(bundle, resource)

@spec 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