Created
September 17, 2011 17:40
-
-
Save vraravam/1224170 to your computer and use it in GitHub Desktop.
rails 3.1.1 & i18n gem & number_to_currency
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'i18n/backend/base' | |
module I18n | |
module Backend | |
module Base | |
def translate(locale, key, options = {}) | |
raise InvalidLocale.new(locale) unless locale | |
entry = key && lookup(locale, key, options[:scope], options) | |
if options.empty? | |
entry = resolve(locale, key, entry, options) | |
else | |
count, default = options.values_at(:count, :default) | |
values = options.except(*RESERVED_KEYS) | |
# ************ START BUG FIX ************ | |
entry = entry.nil? && default.present? && !default.empty? ? | |
# ************ END BUG FIX ************ | |
# ************ START ORIGINAL CODE ************ | |
# entry = entry.nil? && default ? | |
# ************ END ORIGINAL CODE ************ | |
default(locale, key, default, options) : resolve(locale, key, entry, options) | |
end | |
throw(:exception, I18n::MissingTranslation.new(locale, key, options)) if entry.nil? | |
entry = entry.dup if entry.is_a?(String) | |
entry = pluralize(locale, entry, count) if count | |
entry = interpolate(locale, entry, values) if values | |
entry | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment