From: Tom Hughes Date: Mon, 1 Mar 2010 00:55:27 +0000 (+0000) Subject: Monkey patch rails to work around stupid I18n bug where it looks up X-Git-Tag: live~6284^2~57 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/07172166daae9ff670878967b370d7a505389d81 Monkey patch rails to work around stupid I18n bug where it looks up time.formats in the locale and then looks for the requested format in that hash, thereby not doing fallback correctly. To make things worse it then defaults to just using the requested format name as the format... --- diff --git a/config/initializers/i18n.rb b/config/initializers/i18n.rb index 54a925e3c..ac4ad81d6 100644 --- a/config/initializers/i18n.rb +++ b/config/initializers/i18n.rb @@ -2,3 +2,26 @@ require 'globalize/i18n/missing_translations_log_handler' I18n.missing_translations_logger = Logger.new("#{RAILS_ROOT}/log/missing_translations.log") I18n.exception_handler = :missing_translations_log_handler + +module I18n + module Backend + class Simple + protected + alias_method :old_init_translations, :init_translations + + def init_translations + old_init_translations + + friendly = translate('en', 'time.formats.friendly') + + available_locales.each do |locale| + time_formats = I18n.t('time.formats', :locale => locale) + + unless time_formats.has_key?(:friendly) + store_translations(locale, :time => { :formats => { :friendly => friendly } }) + end + end + end + end + end +end