Skip to content

Commit 840cfd8

Browse files
wfleischerdamencho
authored andcommittedAug 17, 2023
feat: use i18next-http-backend and fix ts-ignore
i18next-xhr-backend is not maintained any more and [superseded](i18next/i18next-xhr-backend#348 (comment)) by i18next-http-backend.
1 parent 8cf6ba8 commit 840cfd8

File tree

3 files changed

+40
-24
lines changed

3 files changed

+40
-24
lines changed
 

‎package-lock.json

+33-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"i18n-iso-countries": "6.8.0",
5959
"i18next": "17.0.6",
6060
"i18next-browser-languagedetector": "3.0.1",
61-
"i18next-xhr-backend": "3.0.0",
61+
"i18next-http-backend": "^2.2.1",
6262
"image-capture": "0.4.0",
6363
"jquery": "3.6.1",
6464
"jquery-i18next": "1.2.1",

‎react/features/base/i18n/i18next.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import COUNTRIES_RESOURCES from 'i18n-iso-countries/langs/en.json';
22
import i18next from 'i18next';
3-
import I18nextXHRBackend from 'i18next-xhr-backend';
3+
import I18nextXHRBackend, { HttpBackendOptions } from 'i18next-http-backend';
44
import _ from 'lodash';
55

66
import LANGUAGES_RESOURCES from '../../../../lang/languages.json';
@@ -61,10 +61,10 @@ export const DEFAULT_LANGUAGE = 'en';
6161
/**
6262
* The options to initialize i18next with.
6363
*
64-
* @type {Object}
64+
* @type {i18next.InitOptions}
6565
*/
66-
const options = {
67-
backend: {
66+
const options: i18next.InitOptions = {
67+
backend: <HttpBackendOptions>{
6868
loadPath: 'lang/{{ns}}-{{lng}}.json'
6969
},
7070
defaultNS: 'main',
@@ -76,6 +76,7 @@ const options = {
7676
ns: [ 'main', 'languages', 'countries', 'translation-languages' ],
7777
react: {
7878
// re-render when a new resource bundle is added
79+
// @ts-expect-error. Fixed in i18next 19.6.1.
7980
bindI18nStore: 'added',
8081
useSuspense: false
8182
},
@@ -89,7 +90,7 @@ const options = {
8990

9091
i18next
9192
.use(navigator.product === 'ReactNative' ? {} : I18nextXHRBackend)
92-
.use(languageDetector) // @ts-ignore
93+
.use(languageDetector)
9394
.init(options);
9495

9596
// Add default language which is preloaded from the source code.

0 commit comments

Comments
 (0)
Please sign in to comment.