简体   繁体   English

.rb扩展中的Ruby on Rails语言环境

[英]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(.yml)或纯Ruby(.rb)文件将翻译存储在SimpleStore中。 YAML is the preferred option among Rails developers. YAML是Rails开发人员的首选。 However, it has one big disadvantage. 但是,它有一个很大的缺点。 YAML is very sensitive to whitespace and special characters, so the application may not load your dictionary properly. YAML对空格和特殊字符非常敏感,因此应用程序可能无法正确加载字典。

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. 我试图将我的i18n语言环境文件加载到.rb文件中,因为.yml文件中的西班牙口音最终引发I18n :: InvalidLocaleData错误。

However Ive tried copy pasting the file into a .rb and it doesnt work. 但是我已经尝试将文件粘贴粘贴到.rb中,但它不起作用。 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 . %{record}插入的位置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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