class I18n::Loader::JSON

Overview

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")

Defined in:

i18n/loader/json.cr

Constructors

Class Method Summary

Macro Summary

Instance Method Summary

Instance methods inherited from class I18n::Loader::Base

load : TranslationsHash load

Macros inherited from class I18n::Loader::Base

embed(path) embed

Constructor Detail

def self.new(path : String) #

[View source]
def self.new(preloaded_translations : TranslationsHash) #

[View source]

Class Method Detail

def self.normalize_raw_translations(raw_translations : Array(String)) #

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


[View source]

Macro Detail

macro embed(path) #

[View source]

Instance Method Detail

def load : TranslationsHash #
Description copied from class I18n::Loader::Base

Loads the translations targetted by the current loader.


[View source]
def path : String? #

[View source]
def preloaded_translations : Hash(String, I18n::TranslationsHashValues)? #

[View source]