加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby – rails 3 – I18n :: InvalidLocaleData

发布时间:2020-12-17 03:05:58 所属栏目:百科 来源:网络整理
导读:我使用 this railscast制作我的网站多语言 但是在一开始我得到一个错误: I18n::InvalidLocaleData in Users#indexShowing .../app/views/users/index.html.erb where line #1 raised:can not load translations from .../config/locales/en.yml,expected it
我使用 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 %>

配置/语言环境/ 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"

此外,检查您是否使用空格或制表符,后者将导致麻烦.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读