提交 b6be95ba 编写于 作者: A Andreas Opferkuch 提交者: Joe Haddad

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 )
上级 4dd4df10
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册