加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 如何逃脱冒号:在轨道i18n?

发布时间:2020-12-17 02:38:33 所属栏目:百科 来源:网络整理
导读:以下是视图中的一行: %= f.input :comm_date,:label = "Hello:",:as = :string % 常规i18n文件的格式为: Hello : 'Aloha' 在i18n yml文件中,我们想要翻译“Hello:”,例如“Aloha:”.我们可以逃过结肠:做下面的事吗? ‘你好:’:’阿罗哈:’ 或者什么
以下是视图中的一行:

<%= f.input :comm_date,:label => "Hello:",:as => :string %>

常规i18n文件的格式为:

Hello : 'Aloha'

在i18n yml文件中,我们想要翻译“Hello:”,例如“Aloha:”.我们可以逃过结肠:做下面的事吗?

‘你好:’:’阿罗哈:’

或者什么是逃避结肠的正确方法?

解决方法

您正在使用的gem,simple_form以及其他类似的形式,如formtastic,允许使用翻译文件(例如en.yml)来定义您的标签文本.

您可以从simple_form文档中查看转换文件期望值.使用您的示例,您需要两个翻译,如下所示,假设您的模型名为Communication:

en.yml

en:
  simple_form:
    labels:
      communication:
        comm_date: "Hello:"

olelo.yml

olelo:
  simple_form:
    labels:
      communication:
        comm_date: "Aloha:"

你的观点就是这样

<%= f.input :comm_date,:as => :string %>

无需为:label选项提供值.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读