Module: Redmine::I18n::Backend::Implementation

Includes:
I18n::Backend::Base
Included in:
Redmine::I18n::Backend
Defined in:
lib/redmine/i18n.rb

Instance Method Summary collapse

Instance Method Details

#available_localesObject

Get available locales from the translations filenames


144
145
146
# File 'lib/redmine/i18n.rb', line 144

def available_locales
  @available_locales ||= ::I18n.load_path.map {|path| File.basename(path, '.*')}.uniq.sort.map(&:to_sym)
end

#reload!Object

Clean up translations


149
150
151
152
153
# File 'lib/redmine/i18n.rb', line 149

def reload!
  @translations = nil
  @available_locales = nil
  super
end

#store_translations(locale, data, options = {}) ⇒ Object

Stores translations for the given locale in memory. This uses a deep merge for the translations hash, so existing translations will be overwritten by new ones only at the deepest level of the hash.


136
137
138
139
140
141
# File 'lib/redmine/i18n.rb', line 136

def store_translations(locale, data, options = {})
  locale = locale.to_sym
  translations[locale] ||= {}
  data = data.deep_symbolize_keys
  translations[locale].deep_merge!(data)
end