Skip to content

Instantly share code, notes, and snippets.

@vraravam
Created September 17, 2011 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vraravam/1224170 to your computer and use it in GitHub Desktop.
Save vraravam/1224170 to your computer and use it in GitHub Desktop.
rails 3.1.1 & i18n gem & number_to_currency
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