diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-08-20 15:58:11 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-08-20 15:58:11 +0100 |
commit | ce30500cea5c2d6304643bc90ce0c5b36a2f5919 (patch) | |
tree | 92ef48879721d017e7b72e663ef8dbc3d6421fb0 /lib/i18n_fixes.rb | |
parent | f757ce4ba02c6621e04a349376aeda1c1cb553a3 (diff) | |
parent | dfb5f97ac44656f0e021b09856e0c54b9fa41b3f (diff) |
Merge branch 'release/0.13'0.13
Conflicts:
locale/bg/app.po
locale/es/app.po
locale/fi/app.po
locale/fr/app.po
locale/fr_CA/app.po
locale/he_IL/app.po
locale/hr/app.po
locale/nb_NO/app.po
locale/nl/app.po
locale/pt_BR/app.po
locale/ro_RO/app.po
locale/sl/app.po
locale/vi/app.po
script/rails-post-deploy
Diffstat (limited to 'lib/i18n_fixes.rb')
-rw-r--r-- | lib/i18n_fixes.rb | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/i18n_fixes.rb b/lib/i18n_fixes.rb index 82d1b2c3a..9c1206215 100644 --- a/lib/i18n_fixes.rb +++ b/lib/i18n_fixes.rb @@ -17,7 +17,7 @@ end def n_(*keys) # The last parameter should be the values to do the interpolation with if keys.count > 3 - options = keys.pop + options = keys.pop else options = {} end @@ -33,7 +33,7 @@ def gettext_interpolate(string, values) safe = string.html_safe? string = string.to_str.gsub(MATCH) do pattern, key = $1, $1.to_sym - + if !values.include?(key) raise I18n::MissingInterpolationArgument.new(pattern, string) else @@ -50,7 +50,7 @@ end module I18n - # used by Globalize plugin. + # used by Globalize plugin. # XXX much of this stuff should (might?) be in newer versions of Rails @@fallbacks = nil class << self @@ -120,7 +120,7 @@ module I18n @defaults = defaults.map { |default| compute(default, false) }.flatten end attr_reader :defaults - + def [](locale) raise InvalidLocale.new(locale) if locale.nil? locale = locale.to_sym @@ -138,7 +138,7 @@ module I18n end protected - + def compute(tags, include_defaults = true) result = Array(tags).collect do |tag| tags = I18n::Locale::Tag::Simple.tag(tag).self_and_parents.map! { |t| t.to_sym } @@ -161,7 +161,18 @@ module GettextI18nRails class Backend def available_locales FastGettext.available_locales.map{|l| l.to_sym} || [] - end + end end end +# Monkeypatch Globalize to compensate for the way gettext_i18n_rails patches +# I18n.locale= so that it changes underscores in locale names (as used in the gettext world) +# to the dashes that I18n prefers +module Globalize + class << self + def locale + read_locale || I18n.locale.to_s.gsub('-', '_').to_sym + end + end +end + |