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

Improve Locale.all and all_locales_options #109

Merged
merged 5 commits into from
Feb 15, 2018

Conversation

jhawthorn
Copy link
Contributor

@jhawthorn jhawthorn commented Feb 9, 2018

We used to scan the config/locales directory of this project to determine available locales. This missed en, so that was added manually in a helper.

This PR changes that to instead scan I18n.available_locales for locales which have anything under t(:spree) and removes the hardcoded English (EN) (which is now also correctly "English (US)").

It also fixes en-IN and es-MX misidentifying as duplicated "English (UK)" and "Castellano (ES)" respectively.

Previously this used Dir[] inside the locales directory. This didn't
allow for locales coming from different gems. For this reason it also
didn't include :en.
Previously, we listed both en-IN as "English (UK)" and es-MX as
"Castellano (ES)".

This commit adds a spec to ensure that the locales have a unique names
and updates the two offending locales.
@jhawthorn jhawthorn changed the title Improve how we detect locales Improve Locale.all and all_locales_options Feb 9, 2018
Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Much nicer

File.join(File.dirname(__FILE__), '/../../config/locales')
def self.all
I18n.available_locales.select do |locale|
I18n.t(:spree, locale: locale, fallback: false, default: nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice and sweet 👌

@kennyadsl kennyadsl merged commit fbae1b8 into solidusio:master Feb 15, 2018
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

Successfully merging this pull request may close these issues.

3 participants