gpt4 book ai didi

ruby-on-rails - Spree 内部化 default_locale 保持 :en

转载 作者:数据小太阳 更新时间:2023-10-29 08:49:56 25 4
gpt4 key购买 nike

Spree I18n

2.3 Setting the Default Locale

The default locale for Spree is en. This can be changed by editing the :default_locale setting in the AppConfiguration model. This setting is ignored unless the relevant translation file are within #{Rails.root}/config/locales or the spree_i18n gem. In the future we hope to add a localization settings page that will allow you to set the default locale from the admin screen.

我制作了一个新应用程序,然后安装了 spree,将 gem 'spree_i18n' 添加到 Gemfile。将 hu-Hu.yml 文件添加到 config/locales,但无法将 hugnarian 翻译设为默认。

我什至尝试过:

 rails c
irb(main):001:0> I18n.default_locale = :hu
=> :hu

我的模型目录中没有app_configuration.rb。

问:我应该在哪里设置 default_locale?

编辑:如果我在 application.rb 中设置

    config.i18n.default_locale = :hu

我收到如下错误:

enter image description here

最佳答案

确保将正确的语言环境名称分配给 config/application.rb 中的 config.i18n.default_locale,例如:

config.i18n.default_locale = :hu

和 config/locales 中的翻译文件,如

config/locales/spree_i18n.hu.yml

如果此文件的内容看起来正确 - 在顶部,翻译树应该以 hu:

开头

当然,以上所有路径都是相对于项目树的根。

更新:官方 spree_i18n 来源中似乎缺少匈牙利语(?)的翻译文件。我刚刚在 https://github.com/minktom/spree_i18n 找到了一个如上所述保存它,希望您已准备就绪。

关于ruby-on-rails - Spree 内部化 default_locale 保持 :en,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15499130/

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