Skip to content

Commit

Permalink
to: gh-100 locales not loaded when using base path.
Browse files Browse the repository at this point in the history
  • Loading branch information
riccox committed Dec 25, 2023
1 parent 18f5e36 commit 864afed
Show file tree
Hide file tree
Showing 23 changed files with 10 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"fuse.js": "^7.0.0",
"i18next": "^23.6.0",
"i18next-browser-languagedetector": "^7.1.0",
"i18next-http-backend": "^2.3.1",
"i18next-resources-to-backend": "^1.2.0",
"immer": "^10.0.3",
"lodash": "^4.17.21",
"meilisearch": "^0.35.0",
Expand Down
22 changes: 6 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 3 additions & 6 deletions src/utils/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import Backend from 'i18next-http-backend';
import LanguageDetector from 'i18next-browser-languagedetector';
import resourcesToBackend from 'i18next-resources-to-backend';

export const SUPPORTED_LANGUAGES = ['en', 'zh'] as const;
export type SUPPORTED_LANGUAGE = (typeof SUPPORTED_LANGUAGES)[number];
Expand All @@ -22,18 +22,15 @@ export const NAMESPACES = [
] as const;

i18n
.use(Backend)
// .use(Backend)
.use(resourcesToBackend((language: string, namespace: string) => import(`../locales/${language}/${namespace}.json`)))
.use(LanguageDetector)
.use(initReactI18next) // passes i18n down to react-i18next
.init({
debug: true,
fallbackLng: SUPPORTED_LANGUAGES[0],
ns: NAMESPACES,
fallbackNS: NAMESPACES[0],
backend: {
// fs backend options
loadPath: '/locales/{{lng}}/{{ns}}.json',
},
interpolation: {
escapeValue: false, // react already safes from xss
},
Expand Down

0 comments on commit 864afed

Please sign in to comment.