From b6be95ba3263303844a212e608ede526b0ce6c1c Mon Sep 17 00:00:00 2001 From: Andreas Opferkuch Date: Wed, 16 Oct 2019 07:52:49 +0200 Subject: [PATCH] Fix language fallback in with-react-intl example (#8894) 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 ) --- examples/with-react-intl/server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/with-react-intl/server.js b/examples/with-react-intl/server.js index 50ae8f256a..a39a552034 100644 --- a/examples/with-react-intl/server.js +++ b/examples/with-react-intl/server.js @@ -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) -- GitLab