簡體   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