繁体   English   中英

Rails 3中的多行I18n

[英]Multiline I18n in Rails 3

这是一个简单的问题,但我无法在某处找到答案。 你如何在Rails中处理i18n中的多行翻译?

我现在拥有的是:

error:
  code:  "This is the first line of the text and at some point it becomes too big. 
          So now i continue here."

这是有效的,我想因为它被翻译成html,如果不在预标签中,空格并不重要。 不过,我觉得这不是正确的方法。 如果是这样,那么真正的正确方法是什么?

这真的不是一个I18n问题,可能是一个yaml问题。 你有没有尝试过:

 body : |
   This is a multi-line string.
   "special" metacharacters may
   appear here. The extent of this string is
   indicated by indentation.

我将上面的内容放在test.yml和irb中:

irb(main):012:0> x= YAML.load(IO.read('test.yml'))
=> {"body"=>"This is a multi-line string.\n\"special\" metacharacters may\nappear here. The extent of this string is\nindicated by indentation.\n"}
irb(main):013:0> x["body"]
=> "This is a multi-line string.\n\"special\" metacharacters may\nappear here. The extent of this string is\nindicated by indentation.\n"

对于您的具体示例,尝试:

error:
  code: |
    Some really
    long error
    message here

暂无
暂无

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

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