Answer the question
In order to leave comments, you need to log in
Rails i18n. Problems with date translation. How to do?
Hello habravchan. I can't translate the date.
I took this yaml https://github.com/svenfuchs/rails-i18n/blob/maste... Added
default localization to application.rb:
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.
config.generators.assets = false
# 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 = 'Astana'
# 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]
config.i18n.default_locale = :ru
# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true
end
= Date.today.strftime("%B %d, %Y")
Answer the question
In order to leave comments, you need to log in
I don't know what "this yaml" is. But you need to display dates like this l(date, format: '%e %b')
You just need to take into account that this is a helper.
In your case, you need to output the date like this: l(Date.today, format: :my_format)
where :myformat should be added to yml with translation, here is a description like rusrails.ru/rails-internationalization-i18n-api#do...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question