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

Since:

  • 2.2.0



157
158
159
# File 'lib/redmine/i18n.rb', line 157

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

#reload!Object

Clean up translations

Since:

  • 2.2.0



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

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.

Since:

  • 2.2.0



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

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