I18n translation problem

Posted by kshchepelin on Stack Overflow See other posts from Stack Overflow or by kshchepelin
Published on 2010-05-01T20:00:40Z Indexed on 2010/05/01 20:07 UTC
Read the original article Hit count: 153

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?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about internationalization