Translating Rails Timezones

前端 未结 9 668
滥情空心
滥情空心 2021-02-05 11:09

We internationalized our site months ago, but forgot one part: The drop down where a user picks their timezone.

How do you translate the following line:



        
9条回答
  •  独厮守ぢ
    2021-02-05 11:53

    I had trouble translating the time zones with .'s in them, like "St. Petersburg"

    "translation missing: en, time_zones, St, Petersburg"

    I removed the .'s from the keys, and changed this:

    translated_name = I18n.t(name, :scope => :time_zones, :default => name)

    to:

    translated_name = I18n.t(name.gsub(".", ""), :scope => :time_zones, :default => name)

    There are four keys with .'s:

    • Cape Verde Is.
    • St. Petersburg
    • Solomon Is.
    • Marshall Is.

提交回复
热议问题