locale initializer is missing in rails 5(?) #25398

Closed
murb opened this Issue Jun 14, 2016 · 8 comments

Projects

None yet

6 participants

@murb
Contributor
murb commented Jun 14, 2016 edited

Steps to reproduce

In previous versions of rails there was an by default commented line in config/application.rb that made it very clear how the default English locale setting could be overridden for any app:

# config.i18n.default_locale = :de

The new application.rb in config reads that "application configuration should go into files in config/initializers". But nothing in the bare new Rails app tries to establish a default.

Expected behavior

I would expect a default locale.rb in the initializers directory, probably fully commented with content along the lines of the snippet in the latest i18n docs, bit adjusted to accommodate for the follow up error that might occur for those unaware of the enforce_available_locales setting.

# Where the I18n library should search for translation files
# I18n.load_path += Dir[Rails.root.join('lib', 'locale', '*.{rb,yml}')]
# Whether or not to accept only available locales
# I18n.config.enforce_available_locales = true
# List of available locales
# I18n.config.available_locales = [:en]

# Set default locale to something other than :en (make sure that you either accept all locale values or do not enforce available locales)
# I18n.default_locale = :pt

Actual behavior

It is now harder to figure out where to place locale settings compared to earlier versions of Rails.

System configuration

Rails version: 5.0.0rc1

@maclover7
Member

Hmm, thoughts @dhh? This is a "breaking change" in 5.0. You removed these commented out configuration options @ 28dcadc 😬

@maclover7 maclover7 added the railties label Jun 14, 2016
@dhh
Member
dhh commented Jun 14, 2016

I don't consider removing comments to be a "breaking change". We should solve this in a guide on internationalization instead.

@dhh dhh closed this Jun 14, 2016
@dhh
Member
dhh commented Jun 14, 2016

Actually, seems like we already have a section covering this: http://guides.rubyonrails.org/i18n.html#optional-custom-i18n-configuration-setup

@dhh
Member
dhh commented Jun 14, 2016

We just need to cleanup the documentation around that which talks about the stuff in application.rb.

@murb
Contributor
murb commented Jun 14, 2016 edited

Hmm... I change the default for nearly every project I start... (mostly targeting a Dutch audience), but I guess that's just n=1; on the other hand, just setting a default language isn't enough (as you also need to put in translations in place). I can see why it is better to point the users to docs where everything is explained properly.

@askrynnikov

must be removed The default config/application.rb file has instructions on how to add locales from another directory and how to set a different default locale. ... from http://guides.rubyonrails.org/i18n.html#optional-custom-i18n-configuration-setup

@utilum
Contributor
utilum commented Jan 5, 2017

@askrynnikov this was fixed in 983fa3b, may be worth porting.

@prathamesh-sonpatki prathamesh-sonpatki referenced this issue Jan 8, 2017
@prathamesh-sonpatki prathamesh-sonpatki Update i18n guide about how to change locale and translations paths […
…ci skip]

- config/application.rb no longer has comments about how to specify load paths
  or change default locale after
  28dcadc.
983fa3b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment