gpt4 book ai didi

ruby-on-rails - 在 rails i18n 语言环境文件中使用 YAML block

转载 作者:太空宇宙 更新时间:2023-11-03 16:38:26 24 4
gpt4 key购买 nike

因此,我希望能够将更长的文本 block 添加到 Rails 中的 YAML 语言环境文件中。但是,YAML 解析器会为看似正常的 block 提供语法错误!我通读了 Ruby YAML 说明书,似乎下面的这些示例都应该有效,但它们却没有。

配置/locales/tx.yml

这个很好用:

tx:
states:
show:
state_population: "2009 est. pop.: 24,782,302 (cit. <a href=\"http://quickfacts.census.gov/qfd/states/48000.html\">Census.gov</a>"
state_pop_per_upper_chamber_member: "Each senator serves a four-year term and represents approx. 774,447 Texans"

...但是很丑。

这些都不起作用...

tx:
states:
show:
state_population: |
2009 est. pop.: 24,782,302 (cit. <a href="http://quickfacts.census.gov/qfd/states/48000.html">Census.gov</a>
state_pop_per_upper_chamber_member: "Each senator serves a four-year term and represents approx. 774,447 Texans"


tx:
states:
show:
state_population: >
2009 est. pop.: 24,782,302 (cit. <a href="http://quickfacts.census.gov/qfd/states/48000.html">Census.gov</a>
state_pop_per_upper_chamber_member: "Each senator serves a four-year term and represents approx. 774,447 Texans"

tx:
states:
show:
state_population: |
"2009 est. pop.: 24,782,302 (cit. <a href=\"http://quickfacts.census.gov/qfd/states/48000.html\">Census.gov</a>"
state_pop_per_upper_chamber_member: "Each senator serves a four-year term and represents approx. 774,447 Texans"

tx:
states:
show:
state_population: |
2009 est. pop.\: 24,782,302 (cit. <a href="http://quickfacts.census.gov/qfd/states/48000.html">Census.gov</a>
state_pop_per_upper_chamber_member: "Each senator serves a four-year term and represents approx. 774,447 Texans"

最佳答案

来自 http://pastie.org/1352791

配置/locales/tx.yml

tx:
states:
show:
state_population: >
2009 est. pop.: 24,782,302
(cit.
<a href=\"http://quickfacts.census.gov/qfd/states/48000.html\">Census.gov</a>)
state_pop_per_upper_chamber_member: "Each senator serves a four-year term and represents approx. 774,447 Texans"

关于ruby-on-rails - 在 rails i18n 语言环境文件中使用 YAML block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3772385/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com