From d69b4b7bea28fcab04f61afe381e06fa8e37b429 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20T=C3=A4nav?= Date: Tue, 7 Oct 2008 14:23:05 +0300 Subject: Made i18n simple backend able to store false values (and not confuse them with nil or lack of value) Implemented support.array.skip_last_comma i18n key for Array#to_sentence, this also tests the ability to store false. Signed-off-by: Pratik Naik --- .../vendor/i18n-0.0.1/i18n/backend/simple.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'activesupport/lib/active_support/vendor/i18n-0.0.1') diff --git a/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb b/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb index 2dbaf8a405..30e3655b7b 100644 --- a/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb +++ b/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb @@ -30,7 +30,13 @@ module I18n options.delete(:default) values = options.reject{|name, value| reserved.include? name } - entry = lookup(locale, key, scope) || default(locale, default, options) || raise(I18n::MissingTranslationData.new(locale, key, options)) + entry = lookup(locale, key, scope) + if entry.nil? + entry = default(locale, default, options) + if entry.nil? + raise(I18n::MissingTranslationData.new(locale, key, options)) + end + end entry = pluralize locale, entry, count entry = interpolate locale, entry, values entry @@ -83,7 +89,13 @@ module I18n return unless key init_translations unless initialized? keys = I18n.send :normalize_translation_keys, locale, key, scope - keys.inject(translations){|result, k| result[k.to_sym] or return nil } + keys.inject(translations) do |result, k| + if (x = result[k.to_sym]).nil? + return nil + else + x + end + end end # Evaluates a default translation. -- cgit v1.2.3