Skip to content

Commit

Permalink
feat: Add setup file
Browse files Browse the repository at this point in the history
  • Loading branch information
codemod[bot] committed Jan 24, 2025
1 parent d774c4d commit bb24bf5
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@
"classnames": "^2.3.2",
"compose-function": "^3.0.3",
"history": "^5.3.0",
"i18next": "^24.1.0",
"i18next-browser-languagedetector": "^8.0.2",
"localforage": "^1.10.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hotkeys-hook": "^4.0.2"
"react-hotkeys-hook": "^4.0.2",
"react-i18next": "^15.2.0"
},
"devDependencies": {
"@babel/core": "^7.19.6",
Expand Down
47 changes: 47 additions & 0 deletions src/app/i18n.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import type { Resource } from "i18next";

Check warning on line 1 in src/app/i18n.ts

View workflow job for this annotation

GitHub Actions / build

Replace `"i18next"` with `'i18next'`
import i18n from "i18next";

Check warning on line 2 in src/app/i18n.ts

View workflow job for this annotation

GitHub Actions / build

Replace `"i18next"` with `'i18next'`
import LanguageDetector from "i18next-browser-languagedetector";

Check warning on line 3 in src/app/i18n.ts

View workflow job for this annotation

GitHub Actions / build

Replace `"i18next-browser-languagedetector"` with `'i18next-browser-languagedetector'`
import { initReactI18next } from "react-i18next";

Check warning on line 4 in src/app/i18n.ts

View workflow job for this annotation

GitHub Actions / build

Replace `"react-i18next"` with `'react-i18next'`

void i18n

Check warning on line 6 in src/app/i18n.ts

View workflow job for this annotation

GitHub Actions / build

Expected 'undefined' and instead saw 'void'
.use({
type: "backend",

Check warning on line 8 in src/app/i18n.ts

View workflow job for this annotation

GitHub Actions / build

Replace `"backend"` with `'backend'`
read(
language: string,
namespace: string,
callback: (errorValue: unknown, translations: null | Resource) => void,
) {
import(`./${namespace}/locales/${language}.json`)
.then((resources) => {
callback(null, resources as unknown as Resource);
})
.catch((error) => {
callback(error, null);
});
},
})
.use(LanguageDetector)
.use(initReactI18next)
.init({
fallbackLng: "en",

Check warning on line 26 in src/app/i18n.ts

View workflow job for this annotation

GitHub Actions / build

Replace `"en"` with `'en'`
debug: true,

interpolation: {
escapeValue: false,
},

// react i18next special options (optional)
// override if needed - omit if ok with defaults
/*
react: {
bindI18n: 'languageChanged',
bindI18nStore: '',
transEmptyNodeValue: '',
transSupportBasicHtmlNodes: true,
transKeepBasicHtmlNodesFor: ['br', 'strong', 'i'],
useSuspense: true,
}
*/
});

export { i18n };
2 changes: 2 additions & 0 deletions src/app/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { I18nextProvider } from "react-i18next";

Check warning on line 1 in src/app/index.tsx

View workflow job for this annotation

GitHub Actions / build

Run autofix to sort these imports!

Check warning on line 1 in src/app/index.tsx

View workflow job for this annotation

GitHub Actions / build

'I18nextProvider' is defined but never used. Allowed unused vars must match /^_/u

Check warning on line 1 in src/app/index.tsx

View workflow job for this annotation

GitHub Actions / build

Replace `"react-i18next"` with `'react-i18next'`
import { i18n } from ".././i18n";

Check failure on line 2 in src/app/index.tsx

View workflow job for this annotation

GitHub Actions / build

Unable to resolve path to module '.././i18n'
import React from 'react';
import { createRoot } from 'react-dom/client';
import { App } from './app';
Expand Down

0 comments on commit bb24bf5

Please sign in to comment.