Skip to content

Commit

Permalink
feat: use i18next-http-backend and fix ts-ignore
Browse files Browse the repository at this point in the history
i18next-xhr-backend is not maintained any more and [superseded](i18next/i18next-xhr-backend#348 (comment))
by i18next-http-backend.
  • Loading branch information
wfleischer authored and damencho committed Aug 17, 2023
1 parent 8cf6ba8 commit 840cfd8
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 24 deletions.
51 changes: 33 additions & 18 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"i18n-iso-countries": "6.8.0",
"i18next": "17.0.6",
"i18next-browser-languagedetector": "3.0.1",
"i18next-xhr-backend": "3.0.0",
"i18next-http-backend": "^2.2.1",
"image-capture": "0.4.0",
"jquery": "3.6.1",
"jquery-i18next": "1.2.1",
Expand Down
11 changes: 6 additions & 5 deletions react/features/base/i18n/i18next.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import COUNTRIES_RESOURCES from 'i18n-iso-countries/langs/en.json';
import i18next from 'i18next';
import I18nextXHRBackend from 'i18next-xhr-backend';
import I18nextXHRBackend, { HttpBackendOptions } from 'i18next-http-backend';
import _ from 'lodash';

import LANGUAGES_RESOURCES from '../../../../lang/languages.json';
Expand Down Expand Up @@ -61,10 +61,10 @@ export const DEFAULT_LANGUAGE = 'en';
/**
* The options to initialize i18next with.
*
* @type {Object}
* @type {i18next.InitOptions}
*/
const options = {
backend: {
const options: i18next.InitOptions = {
backend: <HttpBackendOptions>{
loadPath: 'lang/{{ns}}-{{lng}}.json'
},
defaultNS: 'main',
Expand All @@ -76,6 +76,7 @@ const options = {
ns: [ 'main', 'languages', 'countries', 'translation-languages' ],
react: {
// re-render when a new resource bundle is added
// @ts-expect-error. Fixed in i18next 19.6.1.
bindI18nStore: 'added',
useSuspense: false
},
Expand All @@ -89,7 +90,7 @@ const options = {

i18next
.use(navigator.product === 'ReactNative' ? {} : I18nextXHRBackend)
.use(languageDetector) // @ts-ignore
.use(languageDetector)
.init(options);

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

0 comments on commit 840cfd8

Please sign in to comment.