Skip to content

Commit

Permalink
Fix language fallback in with-react-intl example (vercel#8894)
Browse files Browse the repository at this point in the history
The call to `accept.languages()` made the fallback not work.
When called e.g. with `Accept-Language: es-ES,es;q=0.9`, `locale` would contain `[ 'es-ES', 'es' ]` instead of `en`.

(See also: https://www.npmjs.com/package/accepts#languagelanguages )
  • Loading branch information
s-h-a-d-o-w authored and Timer committed Oct 16, 2019
1 parent 4dd4df1 commit b6be95b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion examples/with-react-intl/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const getMessages = locale => {
app.prepare().then(() => {
createServer((req, res) => {
const accept = accepts(req)
const locale = accept.language(accept.languages(supportedLanguages)) || 'en'
const locale = accept.language(supportedLanguages) || 'en'
req.locale = locale
req.localeDataScript = getLocaleDataScript(locale)
req.messages = dev ? {} : getMessages(locale)
Expand Down

0 comments on commit b6be95b

Please sign in to comment.