Skip to content

Use param for i18n#1510

Merged
hursey013 merged 1 commit intomasterfrom
bh-param-i18n
Jun 29, 2017
Merged

Use param for i18n#1510
hursey013 merged 1 commit intomasterfrom
bh-param-i18n

Conversation

@hursey013
Copy link
Contributor

In preparation for a language picker UI element, this allows users to set language preference using a param. The selected language can be accessed by prepending the url path with the language tag (/es/ for example). The priority of the language will be param > HTTP header > default language (EN).

This also contains an update to pass the language preference to the marketing site if one is selected.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this overriding an existing method? Do we need to call super here at all?

config/routes.rb Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

We should not scope the /api routes with a locale IMO

config/routes.rb Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto for the /openid_connect URLs (or anything we publish in the developer docs, those should not be locale-scoped IMO

Copy link
Contributor

Choose a reason for hiding this comment

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

Are we doing to default en to be not there (like the marketing site)? Or are we going to always have a locale in the URL? I think it might be nice to remove it (aka default to english)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah caught this when I saw all the failing specs, fixing now.

@zachmargolis
Copy link
Contributor

Can we add feature specs that test a few URLs?

Copy link
Contributor

Choose a reason for hiding this comment

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

This still needs to be moved to a method to check against available locales, to avoid the InvalidLocale exception.

Copy link
Contributor

Choose a reason for hiding this comment

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

can we update the specs for these marketing site URLs as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would move this into a before block (so it's part of the context) and the same for all of these:

context 'when the user has their locale set to :es' do
  before { I18n.locale = :es }

  it 'points to the privacy page with the locale embedded' do
   expect # ...
  end
end

Copy link
Contributor

@zachmargolis zachmargolis left a comment

Choose a reason for hiding this comment

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

LGTM! I tested it out locally and it works great!

Once we fix the codeclimate issues, LGTM! (I think we can just tell reek to ignore feature envy)

Copy link
Contributor

Choose a reason for hiding this comment

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

rubocop detected some trailign whitespace here

Copy link
Contributor

@amoose amoose left a comment

Choose a reason for hiding this comment

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

LGTM once Bhurst adds the spec for unsupported locales + revert behavior 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about moving this to a separate i18n param validator class? That's what Reek was suggesting, which I agree with. I'd prefer not to disable Reek offenses if there is an easy way to resolve them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@monfresh updated based on feedback, let me know if that is what you were thinking.

@hursey013 hursey013 force-pushed the bh-param-i18n branch 4 times, most recently from 2e56eb0 to 6a4f198 Compare June 29, 2017 14:06
@hursey013
Copy link
Contributor Author

@zachmargolis @amoose @monfresh pushed latest changes and squashed - if you wouldn't mind giving it one more look and then i'll merge!

Copy link
Contributor

@zachmargolis zachmargolis left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@monfresh monfresh left a comment

Choose a reason for hiding this comment

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

lgtm

@hursey013 hursey013 merged commit b0e53a7 into master Jun 29, 2017
@hursey013 hursey013 deleted the bh-param-i18n branch June 29, 2017 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants