Skip to content

Commit

Permalink
docs: namespace concept of i18n-ally is different from that of i18next
Browse files Browse the repository at this point in the history
  • Loading branch information
hemengke1997 committed Jun 1, 2024
1 parent 5a028d5 commit c5da3c0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ i18next
.use(initReactI18next)
.init({
resources: {}, // !!! important: No resources are added at initialization, otherwise what's lazy loading :)
nsSeparator: '.', // namespace separator. If you use `namespace`, you need to configure this
keySeparator: false, // key separator.
nsSeparator: '.',
keySeparator: '.',
fallbackLng,
detection: {
lookupQuerystring: lookupTarget,
Expand Down Expand Up @@ -120,11 +120,11 @@ const { beforeLanguageChange } = i18nAlly({
},
})

const _changeLanguage = i18next.changeLanguage
const i18nextChangeLanguage = i18next.changeLanguage
i18next.changeLanguage = async (lang: string, ...args) => {
// Load resources before language change
await beforeLanguageChange(lang)
return _changeLanguage(lang, ...args)
return i18nextChangeLanguage(lang, ...args)
}
```

Expand Down
8 changes: 4 additions & 4 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ await i18next
.use(initReactI18next)
.init({
resources: {}, // !!! 初始化时不添加资源,不然何来懒加载:)
nsSeparator: '.', // 如果你使用namespace,就需要配置此项
keySeparator: false, // 或者你不使用namespace,可以配置此项为你的key分隔符
nsSeparator: '.',
keySeparator: '.',
fallbackLng,
detection: { // 探测浏览器语言
lookupQuerystring: lookupTarget,
Expand Down Expand Up @@ -121,11 +121,11 @@ const { beforeLanguageChange } = i18nAlly({
},
})

const _changeLanguage = i18next.changeLanguage
const i18nextChangeLanguage = i18next.changeLanguage
i18next.changeLanguage = async (lang: string, ...args) => {
// 语言改变之前,先加载资源
await beforeLanguageChange(lang)
return _changeLanguage(lang, ...args)
return i18nextChangeLanguage(lang, ...args)
}
```

Expand Down
2 changes: 1 addition & 1 deletion playground/spa-with-namespace/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ i18next
debug: import.meta.env.DEV,
resources: {},
nsSeparator: '.',
keySeparator: false,
keySeparator: '.',
interpolation: {
escapeValue: false,
},
Expand Down
2 changes: 1 addition & 1 deletion playground/vscode-setting/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ i18next
debug: import.meta.env.DEV,
resources: {},
nsSeparator: '.',
keySeparator: false,
keySeparator: '.',
interpolation: {
escapeValue: false,
},
Expand Down

0 comments on commit c5da3c0

Please sign in to comment.