I have set the default locale as :es in my application.rb:

config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
config.i18n.default_locale = :es

My es.yml file is looking like this:

es:
  hello:
    world: "Hola mundo"
  activerecord:
    attributes:
      post:
        title: "Titulo"
    errors:
      models:
        post:
          attributes:
            title:
              blank: "Hey el %{attribute} está en blanco!"
              too_short: "%{count} carácteres mínimos"
            text:
              blank: "Hey el %{attribute} está en blanco!"
              too_short: "%{count} carácteres mínimos"

I'm trying to make those nested translation keys work in views like <%= t :'hello.world' %>, with this configuration I get the following error:

can not load translations from /home/edd/Programming/ruby/rails/blog/config/locales/en.yml: #<Psych::SyntaxError: (/home/edd/Programming/ruby/rails/blog/config/locales/en.yml): found character that cannot start any token while scanning for the next token at line 23 column 1>

This error mentions en.yml which is structured like this:

en:
  hello:
    world: "Hello world"
  activerecord:
    attributes:
      post:
        title: "Title"
    ...

If I remove the nested part it starts working the t helper starts working:

en:
    world: "Hello world"

What could be happening here? thanks in advance for your comments.

没有正确的解决方案

其他提示

We need to ensure space to over come this issue.

example:-

en:
  articles: 
    index:
      heading_list: 'Gurudath Articles List In English'
      description: 'Gurudath Articles Description In English'

Check to see if there are any odd characters on line 23, e.g. a space in a series of tabs, etc.

If so, remove and ensure uniformity.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top