gpt4 book ai didi

ruby - rails 3 - I18n::InvalidLocaleData

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

我正在使用 this railscast 使我的网站多语言化

但是一开始我就报错了:

I18n::InvalidLocaleData in Users#index

Showing .../app/views/users/index.html.erb where line #1 raised:

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

index.html.erb:

<% provide(:title, t('users.index.title.site_title')) %>
<h1><%= t 'users.index.title.head' %></h1>

<%= form_tag users_path, :method => 'get' do %>
<%= hidden_field_tag :direction, params[:direction] %>
<%= hidden_field_tag :sort, params[:sort] %>
<p>
<%= text_field_tag :search, params[:search] %>
<%= submit_tag (t 'users.index.search_form.search'), :name => nil %>
</p>
<% end %>

配置/locales/en.yml

en:
users:
index:
title:
site_title: "Users"
head: "Users"
search_form:
search: "Search"

最佳答案

区域设置数据应该缩进两个空格,而不是四个,所以正确的版本是:

en:
users:
index:
title:
site_title: "Users"
head: "Users"
search_form:
search: "Search"

此外,请检查您使用的是空格还是制表符,后者会造成问题。

关于ruby - rails 3 - I18n::InvalidLocaleData,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18894999/

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