Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

select_available_locales search doesn't respect rails enforce_available_locales #614

Open
yf6 opened this issue Aug 4, 2015 · 0 comments

Comments

@yf6
Copy link

yf6 commented Aug 4, 2015

I'm on Spree 2.4.9 and rails 4.1.11, it appears that rails enforce_available_locales is not working well with the i18n select_available_locales search box.

The select tag gathers all supported locales by spree and list them in the local presentation, but doing so triggers a Spree.t call of each locale. But when I have enforce_available_locales set to true in my rails application, and allow only a subset of what spree supports, rails i18n throws an invalid locale error when the t method is called on the other locales.

I think spree i18n needs to respect rails enforce_available_locales, and maybe only show the list of available locale by rails in the select tag?

Here is the detailed error message:

ActionView::Template::Error (:sk is not a valid locale):
    69: 
    70:   <div class="field">
    71:     <label for="available_locales_"><%= Spree.t(:'i18n.available_locales') %></label>
    72:     <%= select_available_locales %>
    73:   </div>
    74: </fieldset>
    75: 
  vendor/bundle/ruby/2.0/gems/i18n-0.7.0/lib/i18n.rb:284:in `enforce_available_locales!'
  vendor/bundle/ruby/2.0/gems/i18n-0.7.0/lib/i18n.rb:151:in `translate'
  vendor/bundle/ruby/2.0/gems/actionview-4.1.11/lib/action_view/helpers/translation_helper.rb:68:in `translate'
  vendor/bundle/ruby/2.0/gems/spree_core-2.4.8/lib/spree/i18n.rb:18:in `translate'
  vendor/bundle/ruby/2.0/bundler/gems/spree_i18n-fe65f6b87f1d/app/helpers/spree_i18n/locale_helper.rb:31:in `locale_presentation'
  vendor/bundle/ruby/2.0/bundler/gems/spree_i18n-fe65f6b87f1d/app/helpers/spree_i18n/locale_helper.rb:26:in `block in all_locales_options'
  vendor/bundle/ruby/2.0/bundler/gems/spree_i18n-fe65f6b87f1d/app/helpers/spree_i18n/locale_helper.rb:26:in `map'
  vendor/bundle/ruby/2.0/bundler/gems/spree_i18n-fe65f6b87f1d/app/helpers/spree_i18n/locale_helper.rb:26:in `all_locales_options'
  vendor/bundle/ruby/2.0/bundler/gems/spree_i18n-fe65f6b87f1d/app/helpers/spree_i18n/locale_helper.rb:8:in `select_available_locales'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant