无法在next-i18next中将localeSubpaths设置为仅外语

时间:2019-09-05 19:48:48

标签: reactjs internationalization next.js i18next react-i18next

问题描述

仅当我将所有语言设置为NextI18Next时,才能用localeSubpaths初始化localeSubpaths

const localeSubpathVariations = {
  none: {},
  foreign: {
    cs: 'cs',
    de: 'de'
  },
  all: {
    de: 'de',
    en: 'en',
    cs: 'cs',
  },
}

const NextI18NextInstance = new NextI18Next({
  defaultLanguage: 'en',
  otherLanguages: ['cs', 'de'],
  localeSubpaths: localeSubpathVariations['all'],
  logging: true,
  fallbackLng: 'en'
} as any)

localeSubpaths更改为localeSubpaths: localeSubpathVariations['all']无效。

行为

localeSubpaths设置为外部时,我在/cs/de路径上得到404。

$ curl -I http://commerceowl.haproxy
HTTP/1.1 200 OK

$ curl -I http://commerceowl.haproxy/de
HTTP/1.1 404 Not Found

$ curl -I http://commerceowl.haproxy/cs
HTTP/1.1 404 Not Found

localeSubpaths设置为我的所有语言后,它将按预期工作:

$ curl -I http://commerceowl.haproxy
HTTP/1.1 302 Found
Location: /en

$ curl -I http://commerceowl.haproxy/de
HTTP/1.1 200 OK

$ curl -I http://commerceowl.haproxy/cs
HTTP/1.1 200 OK

期望的行为

我想访问我的英文版本而不添加/en路径,而是使用/cs/de路径访问外部版本。

0 个答案:

没有答案