class

I18n::Loader::JSON

Inherits I18n::Loader::Base < Reference < Object

The JSON translations loader.

This loader implementation allows to load translations from JSON files. It must be initialized from a given path and it will recursively try to load all the JSON files that are available under the targetted directory:

I18n.config.loaders << I18n::Loader::JSON.new("config/locales")

This loader also allows to embed the raw translations that are available under the targetted directory inside the compiled binary through the use of the #embed macro:

I18n.config.loaders << I18n::Loader::JSON.embed("config/locales")

Constructors

new(path : String)
Source
new(preloaded_translations : TranslationsHash)
Source

Class methods

normalize_raw_translations(raw_translations : Array(String))

Converts an array of JSON strings to a valid translations hash.

Source

Instance methods

load

Loads the translations targetted by the current loader.

Source
path
Source
preloaded_translations
Source

Macros

embed(path)
Source