如何在Rails的.yml本地化文件中断行? [英] How to break lines in .yml localization files on rails?

查看:77
本文介绍了如何在Rails的.yml本地化文件中断行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有某些本地化的term.en.yml文件,例如:

I have a terms.en.yml file with some localization, for example:

en:
  devise:
    registrations:
      terms:
        text: 'This agreement was written in English (US). To the extent any translated version of this agreement conflicts with the English version, the English version controls.  Please note that Section 16 contains certain changes to the general terms for users outside the United States.\n\ Some new line'

我如何在其中换行或创建一个段落?

How could i break a line or create a paragraph there?

这里有一些信息,但对我没有帮助,我做错了什么. http://yaml.org/spec/1.1/#b-paragraph-separator

Here`s some info but it did not helped to me,i had been doing something wrong. http://yaml.org/spec/1.1/#b-paragraph-separator

推荐答案

这对我有用:

en:
  hello: "Hello world"
  bye: |
    Bye!
    See you!
  error: >
    Something happend.
    Try later.

用法:

irb(main):001:0> I18n.t 'bye'
=> "Bye!\nSee you!\n"
irb(main):002:0> I18n.t 'error'
=> "Something happend. Try later.\n"

这篇关于如何在Rails的.yml本地化文件中断行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆