GettextSigils.Options (Gettext Sigils v0.5.1)

Copy Markdown View Source

Validates :sigils options passed to use GettextSigils. All other options are passed through to use Gettext.

Options

  • :domain - Default Gettext domain within the module that is using GettextSigils. Use the :default atom to follow the backend's configured default domain, or a binary to override.

  • :context - Default Gettext context within the module that is using GettextSigils. May be nil (the default) or a binary.

  • :modifiers - A keyword list of options applied when using the ~t sigil with modifiers.

    The key has to be an atom between :a and :z. Uppercase modifiers are used by the library (eg. N for pluralization).

    Each entry can be a static keyword list, a module atom, or a {module, opts} tuple. The keyword-list form is shorthand for the built-in GettextSigils.Modifiers.KeywordModifier, whose options are:

    • :domain - Gettext domain. Use the :default atom to select the backend's configured default domain, or a binary to override.

    • :context - Gettext context. Use nil to clear the context, or a binary to override.

    The default value is [].

Example

use GettextSigils,
  backend: MyApp.Gettext,
  sigils: [
    domain: "default",
    context: "dashboard",
    modifiers: [
      e: [domain: "errors"],
      a: [context: "admin"]
    ]
  ]

Summary

Functions

Validates the given options or raises a NimbleOptions.ValidationError if invalid.

Functions

validate!(opts)

@spec validate!(keyword()) :: keyword() | no_return()

Validates the given options or raises a NimbleOptions.ValidationError if invalid.

After validation, the :modifiers keyword list is converted into a map keyed by the character code of each modifier letter (e.g. ?e instead of :e) so that modifier lookup can do a direct Map.fetch/2 against the sigil charlist without re-converting characters to atoms on every expansion.