Defect #42815 » 0002-Drop-Redmine-I18n-Backend.new-custom-backend.patch
| config/application.rb | ||
|---|---|---|
| 59 | 59 |
config.i18n.enforce_available_locales = true |
| 60 | 60 |
config.i18n.fallbacks = true |
| 61 | 61 |
config.i18n.default_locale = 'en' |
| 62 |
config.i18n.available_locales = Dir[Rails.root / 'config' / 'locales' / '*.yml'].map { |f| File.basename(f, '.yml').to_sym }
|
|
| 62 | 63 | |
| 63 | 64 |
# Configure the default encoding used in templates for Ruby 1.9. |
| 64 | 65 |
config.encoding = "utf-8" |
| config/initializers/30-redmine.rb | ||
|---|---|---|
| 4 | 4 |
require 'redmine/plugin_loader' |
| 5 | 5 | |
| 6 | 6 |
Rails.application.config.to_prepare do |
| 7 |
I18n.backend = Redmine::I18n::Backend.new |
|
| 8 |
# Forces I18n to load available locales from the backend |
|
| 9 |
I18n.config.available_locales = nil |
|
| 7 |
I18n::Backend::Simple.include(I18n::Backend::Pluralization) |
|
| 10 | 8 | |
| 11 | 9 |
# Use Nokogiri as XML backend instead of Rexml |
| 12 | 10 |
ActiveSupport::XmlMini.backend = 'Nokogiri' |
| lib/redmine/i18n.rb | ||
|---|---|---|
| 173 | 173 |
def current_language |
| 174 | 174 |
::I18n.locale |
| 175 | 175 |
end |
| 176 | ||
| 177 |
# Custom backend based on I18n::Backend::Simple with the following changes: |
|
| 178 |
# * available_locales are determined by looking at translation file names |
|
| 179 |
class Backend < ::I18n::Backend::Simple |
|
| 180 |
# Get available locales from the translations filenames |
|
| 181 |
def available_locales |
|
| 182 |
@available_locales ||= begin |
|
| 183 |
redmine_locales = Dir[Rails.root / 'config' / 'locales' / '*.yml'].map { |f| File.basename(f, '.yml').to_sym }
|
|
| 184 |
super & redmine_locales |
|
| 185 |
end |
|
| 186 |
end |
|
| 187 | ||
| 188 |
# Adds custom pluralization rules |
|
| 189 |
include ::I18n::Backend::Pluralization |
|
| 190 |
# Adds fallback to default locale for untranslated strings |
|
| 191 |
include ::I18n::Backend::Fallbacks |
|
| 192 |
end |
|
| 193 | 176 |
end |
| 194 | 177 |
end |
- « Previous
- 1
- 2
- Next »