Kanta.Backend.Adapter behaviour (kanta v0.5.1)
Defines the behavior for Kanta adapters used in translation lookups.
Adapters implementing this behavior are responsible for handling translation lookups for both singular and plural forms.
Summary
Callbacks
Looks up a singular translation in the specified locale and domain.
Looks up a plural translation in the specified locale and domain.
Callbacks
@callback lgettext( locale :: String.t(), domain :: String.t(), msgctxt :: String.t() | nil, msgid :: String.t(), bindings :: Keyword.t() | map() ) :: {:ok, String.t()} | {:error, :not_found}
Looks up a singular translation in the specified locale and domain.
Parameters
locale- The locale code (e.g., "en", "fr")domain- The translation domain namemsgctxt- Optional message context, or nil if no contextmsgid- The message identifier to translatebindings- Map or keyword list of bindings for interpolation
Returns
{:ok, translated_string}- When the translation is found{:error, :not_found}- When the translation is not found
@callback lngettext( locale :: String.t(), domain :: String.t(), msgctxt :: String.t() | nil, msgid :: String.t(), msgid_plural :: String.t(), n :: non_neg_integer(), bindings :: Keyword.t() | map() ) :: {:ok, String.t()} | {:error, :not_found}
Looks up a plural translation in the specified locale and domain.
Parameters
locale- The locale code (e.g., "en", "fr")domain- The translation domain namemsgctxt- Optional message context, or nil if no contextmsgid- The singular message identifiermsgid_plural- The plural message identifiern- The count to determine which plural form to usebindings- Map or keyword list of bindings for interpolation
Returns
{:ok, translated_string}- When the translation is found{:error, :not_found}- When the translation is not found