I18n translation problem
- by kshchepelin
I'm about to translate all time zones to Russian and I've done such things:
model:
# lib/i18n_time_zone.rb
class I18nTimeZone < ActiveSupport::TimeZone
def self.all
super.map { |z| create(z.name, z.utc_offset) }
end
def to_s
translated_name = I18n.t(name, :scope => :timezones, :default => name)
"(GMT#{formatted_offset}) #{translated_name}"
end
end
view:
<%= time_zone_select :user, :time_zone, nil, :model => I18nTimeZone %>
locale file (/config/locales/ru.yml):
ru:
timezones:
"Midway Island": "??????"
"Samoa": "?????"
....
But there are cases when original string includes some dots (".") Like "St. Petersburg"
And I18n.t() tells me that translation is missing.
How can I avoid it?