如何在 YAML 中声明带有单引号和双引号的字符串? [英] How do I declare a string with both single and double quotes in YAML?

查看:452
本文介绍了如何在 YAML 中声明带有单引号和双引号的字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在对应用程序进行国际化,但不知道如何声明包含单引号和双引号的翻译字符串.这是我尝试使用的 en.yml 字符串的示例

I'm internationalizing an application and cannot figure out how to declare a translation string that contains both single and double quotes. Here's an example of the en.yml string that I am trying to

en:
  my_string: When you're using double quotes, they look like "this"

使用上面的字符串,我得到以下错误:

With the above string, I get the following error:

can not load translations from /vagrant/config/locales/en.yml,
expected it to return a hash, but does not

如果只有双引号,我会把它用单引号括起来,反之亦然.我如何处理双引号和单引号?

If there were just double quotes, I would wrap it in single quotes and vise-versa. How do I handle both double and single quotes though?

推荐答案

转义应该是这样的

"When you're using double quotes, they look like \"this\""

这篇关于如何在 YAML 中声明带有单引号和双引号的字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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