Linguist.MemorizedVocabulary (Linguist v0.4.0) View Source

Defines lookup functions for given translation locales, binding interpolation.

Locales are defined with the locale/2 function, accepting a locale name and a String path to evaluate for the translations list.

For example, given the following translations:

locale "en", [
  flash: [
    notice: [
      hello: "hello %{first} %{last}",
    ]
  ],
  users: [
    title: "Users",
  ]
]

locale "fr", Path.join([__DIR__, "fr.exs"])

This module will respond to these functions:

t("en", "flash.notice.hello", bindings \ []), do: # ...
t("en", "users.title", bindings \ []), do: # ...
t("fr", "flash.notice.hello", bindings \ []), do: # ...

Link to this section Summary

Link to this section Functions

Function used internally to load a yaml file.

Please use the locale macro with a path to a yaml file - this function will not work as expected if called directly.

Recursive function used internally for loading yaml files.

Not intended for external use

Embeds locales from provided source.

  • name - The String name of the locale, ie "en", "fr"
  • source - The String file path to load YAML from that returns a structured list of translations

Examples

locale "es", Path.join([__DIR__, "es.yml"])
Link to this function

normalize_locale(locale)

View Source
Link to this function

t(locale, path, bindings \\ [])

View Source
Link to this function

t!(locale, path, bindings \\ [])

View Source
Link to this function

update_translations(locale_name, loaded_source)

View Source