gpt4 book ai didi

ruby-on-rails - rails : Translation in Initializer

转载 作者:行者123 更新时间:2023-12-04 06:22:51 25 4
gpt4 key购买 nike

我有几个翻译隐藏在初始化程序中,如下所示:

GROUP_GOVERNANCE_STYLES = [
[I18n.t("constants.group_governance_styles.collective"), 1],
[I18n.t("constants.group_governance_styles.electoral_democracy"), 2],
[I18n.t("constants.group_governance_styles.dictatorship"), 3]
]

在我的 en.yml 文件中,我有:
en:
constants:
group_governance_styles:
collective: "collective"
electoral_democracy: "electoral democracy"
dictatorship: "dictatorship"

不幸的是,当我尝试在 View 中呈现这些翻译时,出现以下错误:
translation missing: en.constants.group_governance_styles.collective
translation missing: en.constants.group_governance_styles.electoral_democracy
translation missing: en.constants.group_governance_styles.dictatorship

我也试过删除范围,但翻译仍然丢失。有没有另一种方法来解决这个问题?也许我不知道初始值设定项的默认范围?

最佳答案

AFAIK,翻译在初始化程序之后加载。尝试将其放入 environment.rb

关于ruby-on-rails - rails : Translation in Initializer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15327019/

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