Rails 3 强制特定文本的本地化语言

发布于 2024-11-19 15:17:20 字数 115 浏览 6 评论 0原文

任何强制仅将某些文本翻译为特定语言的方法。比如:

t("my.text",:fr)

原因是我希望用户能够更改其内容的语言,但不能更改网站界面。谢谢!

Any way to force the translation to a specific language only for some text. Something like:

t("my.text",:fr)

The reason is that i want the user to be able to change the language of their content but not the site interface. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

与往事干杯 2024-11-26 15:17:20

可以这样完成:

I18n.t :foo, :locale => :fr

也等效:

t("my.text", :locale => :fr)

It could be done this way:

I18n.t :foo, :locale => :fr

equivalent too:

t("my.text", :locale => :fr)
情深如许 2024-11-26 15:17:20
t("my.text", locale: :fr)

更多选项此处

t("my.text", locale: :fr)

More options here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文