Skip to content

Conversation

muffinresearch
Copy link
Contributor

@muffinresearch muffinresearch commented Jul 14, 2016

Fixes mozilla/addons#9747

  • Add accept-language fallback to lang lookup (this is derived from mozilla/i18n-abide code + tests).
  • remove lang query-string support since it's superfluous.
  • Make routes with lang (optional) makes it possible to redirect if lang isn't supplied.
  • Improve server tests, splits them up so that passing NODE_APP_INSTANCE is done correctly - which required some test fixes since not passing the NODE_APP_INSTANCE meant some of the older tests were wrong.


export default (
<Route path="/" component={App}>
<Route path="/(:lang/)" component={App}>
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably be path="/(:lang/)firefox/" but that could wait if you'd like.

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder how this will work if you get something like /firefox/addons/, would it be smart enough to see that there is no lang? Maybe we shouldn't worry about redirecting the lang other than at /?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mstriemer
Copy link
Contributor

r+wc

@muffinresearch
Copy link
Contributor Author

muffinresearch commented Jul 18, 2016

@mstriemer I've added a new commit which removes the index route and redirects in development (for the disco pane). This makes it a bit more correct so hitting / will be a 404 which I think is right. I also moved from 301 to 302 for redirection which feels more appropriate.

}

if (appInstanceName === 'disco' && isDevelopment) {
app.get('/', (req, res) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

react-router has a <Redirect /> component, can you add that to the router in disco/routes.js when in development instead?

@muffinresearch
Copy link
Contributor Author

react-router has a component, can you add that to the router in disco/routes.js when in development instead?

That would be nice for removing app specific code from the core apps. What I can't see is what status code you'll get using that.

@muffinresearch
Copy link
Contributor Author

I suppose we could say for local-development we don't really care.

@mstriemer
Copy link
Contributor

Actually react-router won't perform the redirect on the server, so I'm not sure what will happen. Maybe it returns a 200 then redirects in the browser?

@muffinresearch
Copy link
Contributor Author

Actually react-router won't perform the redirect on the server, so I'm not sure what will happen. Maybe it returns a 200 then redirects in the browser?

Yeah - I can't seem to get it to work - presumably because you need to respond to a URL you don't care about in order to be running the JS which will do the location change :/

@muffinresearch
Copy link
Contributor Author

I'm going to land this as is, and we can look at improving the redirects stuff in due course.

@muffinresearch muffinresearch merged commit 705d0bb into mozilla:master Jul 18, 2016
@muffinresearch muffinresearch deleted the add-accept-language-support branch July 18, 2016 18:14
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.

Add l10n facility for parsing accept-language headers

2 participants