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

Includes:
I18n::Backend::Base, I18n::Backend::Pluralization
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



169
170
171
# File 'lib/redmine/i18n.rb', line 169

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

#reload!Object

Clean up translations



174
175
176
177
178
# File 'lib/redmine/i18n.rb', line 174

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.



161
162
163
164
165
166
# File 'lib/redmine/i18n.rb', line 161

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