简体   繁体   中英

Ruby on Rails locales in .rb extension

Taken from the rails guide:

You may use YAML (.yml) or plain Ruby (.rb) files for storing your translations in SimpleStore. YAML is the preferred option among Rails developers. However, it has one big disadvantage. YAML is very sensitive to whitespace and special characters, so the application may not load your dictionary properly.

Im trying to load my i18n locale files in a .rb files since the spanish accents in the .yml file end up throwing a I18n::InvalidLocaleData error.

However Ive tried copy pasting the file into a .rb and it doesnt work. How is this supposed to be done?

One option would be to do it like this:

{ de: {
errors: {
  messages: {
  restrict_dependent_destroy: {
    one: "Datensatz kann nicht gelöscht werden, da ein abhängiger %{record}-Datensatz existiert.",
    many: "Datensatz kann nicht gelöscht werden, da abhängige %{record} existieren." }}}}}

Where %{record} would be interpolated .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM