Skip to content

Commit

Permalink
fixed active_record_missing mixin, now uses new i18n.plural.keys name…
Browse files Browse the repository at this point in the history
…space
  • Loading branch information
purzelrakete authored and Sven Fuchs committed Dec 25, 2009
1 parent 20fb935 commit 2e13fc1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions lib/i18n/backend/active_record/missing.rb
Expand Up @@ -11,19 +11,21 @@
# I18n.backend = I18nChainBackend.new(I18n::Backend::ActiveRecord.new, I18n::Backend::Simple.new)
#
# Stub records for pluralizations will also be created for each key defined
# in i18n.plural_keys.
# in i18n.plural.keys.
#
# For example:
#
# # en.yml
# en:
# i18n:
# plural_keys: [:zero, :one, :other]
# plural:
# keys: [:zero, :one, :other]
#
# # pl.yml
# pl:
# i18n:
# plural_keys: [:zero, :one, :few, :other]
# plural:
# keys: [:zero, :one, :few, :other]
#
# It will also persist interpolation keys in Translation#interpolations so
# translators will be able to review and use them.
Expand All @@ -40,7 +42,7 @@ def store_default_translations(locale, key, options = {})

unless ActiveRecord::Translation.locale(locale).lookup(key, separator).exists?
interpolations = options.reject { |name, value| Base::RESERVED_KEYS.include?(name) }.keys
keys = count ? I18n.t('i18n.plural_keys', :locale => locale).map { |k| [key, k].join(separator) } : [key]
keys = count ? I18n.t('i18n.plural.keys', :locale => locale).map { |k| [key, k].join(separator) } : [key]
keys.each { |key| store_default_translation(locale, key, interpolations) }
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/cases/backend/active_record/missing_test.rb
Expand Up @@ -5,7 +5,7 @@

class I18nActiveRecordMissingTest < Test::Unit::TestCase
def setup
store_translations(:en, :i18n => { :plural_keys => [:zero, :one, :other] })
store_translations(:en, :i18n => { :plural => { :keys => [:zero, :one, :other] } })

I18n.backend = I18n::Backend::Chain.new(I18n.backend)
I18n.backend.meta_class.send(:include, I18n::Backend::ActiveRecord::Missing)
Expand Down

0 comments on commit 2e13fc1

Please sign in to comment.