Browse files

added notes about #localize optimization TODOs

  • Loading branch information...
1 parent bbf7064 commit dd76298e109c773551d39dc50a0dadbf51ff7f1f @svenfuchs committed Aug 25, 2008
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/i18n/backend/simple.rb
View
5 lib/i18n/backend/simple.rb
@@ -47,12 +47,15 @@ def localize(locale, object, format = :default)
raise ArgumentError, "Object must be a Date, DateTime or Time object. #{object.inspect} given." unless object.respond_to?(:strftime)
type = object.respond_to?(:sec) ? 'time' : 'date'
+ # TODO only translate these if format is a String?
formats = translate(locale, :"#{type}.formats")
format = formats[format.to_sym] if formats && formats[format.to_sym]
# TODO raise exception unless format found?
format = format.to_s.dup
- format.gsub!(/%a/, translate(locale, :"date.abbr_day_names")[object.wday])
+ # TODO only translate these if the format string is actually present
+ # TODO check which format strings are present, then bulk translate then, then replace them
+ format.gsub!(/%a/, translate(locale, :"date.abbr_day_names")[object.wday])
format.gsub!(/%A/, translate(locale, :"date.day_names")[object.wday])
format.gsub!(/%b/, translate(locale, :"date.abbr_month_names")[object.mon])
format.gsub!(/%B/, translate(locale, :"date.month_names")[object.mon])

0 comments on commit dd76298

Please sign in to comment.