Rails 4: I18n::InvalidLocaleData

1k views Asked by At

I installed the Kaminari gem and followed the instructions. I customized my theme to the foundations but when trying to further customize the pagination style using the en.yml file, I run into this error:

I18n::InvalidLocaleData in Campaigns#index

can not load translations from /myapp/config/locales/en.yml: #<Psych::SyntaxError: (/myapp/config/locales/en.yml): did not find expected key while parsing a block mapping at line 23 column 3>

Extracted source (around line #2):

1  <li>
2    <%= link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, :remote => remote %>
3  </li>

I simply copied and pasted what was in the docs..

en:
  hello: "Hello world"
    pagination:
      first: "&laquo; First"
      last: "Last &raquo;"
      previous: "&lsaquo; Prev"
      next: "Next &rsaquo;"
      truncate: "&hellip;"

If I delete everything other than pagination: line, the error still remains. I'm not super familiar with the locale file in Rails as well as YAML files so any help is highly appreciated.

1

There are 1 answers

0
summea On BEST ANSWER

According to the results from YAML Lint, it appears that the hello: "Hello world" line is invalid.

Also, it looks like the views.pagination.first line in your code is looking for a path like: views -> pagination -> first in your YAML file (and because this pattern can't be found, there's another error).

Therefore, it might be better to use this kind of YAML example:

en:
  views:
    pagination:
      first: "&laquo; First"
      last: "Last &raquo;"
      previous: "&lsaquo; Prev"
      next: "Next &rsaquo;"
      truncate: "&hellip;"