M
M
Max Yawo2014-07-15 15:25:30
Ruby on Rails
Max Yawo, 2014-07-15 15:25:30

How to configure I18n correctly or why the t() method doesn't work?

The problem is the following,
in the view, the t () method returns to me what I passed to it, despite the fact that the necessary keys are specified in ru.yml.
%h1= t('welcome')
returns just the header "Welcome"
application.rb

require File.expand_path('../boot', __FILE__)

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module IJOUR
  class Application < Rails::Application
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.

    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
    # config.time_zone = 'Central Time (US & Canada)'

    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
    config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]

    I18n.config.enforce_available_locales = true
    I18n.available_locales = [:en, :ru]
    config.i18n.default_locale = :ru

    config.encoding = "utf-8"
  end
end

en.yml
ru:
  welcome: "Добро пожаловать в Интернет Журнал"

Through the terminal
2.1.2 :064 >   I18n.t('Welcome')
 => "translation missing: ru.Welcome"

How to solve this problem?
Thank you very much in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Petrov, 2014-07-15
@dzhiriki

I18n.t('welcome')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question