File tree Expand file tree Collapse file tree 6 files changed +197
-24
lines changed Expand file tree Collapse file tree 6 files changed +197
-24
lines changed Original file line number Diff line number Diff line change 1010 "@types/react-dom" : " ^19.0.2" ,
1111 "antd" : " ^5.22.1" ,
1212 "blockly" : " ^11.1.1" ,
13+ "i18next" : " ^24.2.2" ,
14+ "i18next-http-backend" : " ^3.0.2" ,
1315 "jszip" : " ^3.10.1" ,
1416 "lucide-react" : " ^0.460.0" ,
1517 "re-resizable" : " ^6.10.1" ,
1618 "react" : " ^18.3.1" ,
1719 "react-dom" : " ^18.3.1" ,
20+ "react-i18next" : " ^15.4.1" ,
1821 "react-syntax-highlighter" : " ^15.6.1" ,
1922 "web-vitals" : " ^2.1.4"
2023 },
Original file line number Diff line number Diff line change 1+ {
2+ "project_delete" : " i18n: Delete Project" ,
3+ "project_rename" : " i18n: Rename Project" ,
4+ "project_copy" : " i18n: Copy Project"
5+ }
6+
Original file line number Diff line number Diff line change @@ -35,6 +35,8 @@ import {
3535 UploadOutlined ,
3636} from '@ant-design/icons' ;
3737
38+ import { useTranslation } from "react-i18next" ;
39+
3840import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter' ;
3941import { dracula } from 'react-syntax-highlighter/dist/esm/styles/prism' ;
4042
@@ -117,6 +119,8 @@ const App: React.FC = () => {
117119 const PURPOSE_RENAME_MODULE = 'RenameModule' ;
118120 const PURPOSE_COPY_MODULE = 'CopyModule' ;
119121
122+ const { t } = useTranslation ( ) ;
123+
120124 const ignoreEffect = ( ) => {
121125 if ( ! import . meta. env . MODE || import . meta. env . MODE === 'development' ) {
122126 // Development mode.
@@ -308,9 +312,9 @@ const App: React.FC = () => {
308312
309313 if ( module != null ) {
310314 if ( module . moduleType == commonStorage . MODULE_TYPE_PROJECT ) {
311- setRenameTooltip ( 'Rename Project' ) ;
312- setCopyTooltip ( 'Copy Project' ) ;
313- setDeleteTooltip ( 'Delete Project' ) ;
315+ setRenameTooltip ( t ( 'project_rename' ) ) ;
316+ setCopyTooltip ( t ( 'project_copy' ) ) ;
317+ setDeleteTooltip ( t ( 'project_delete' ) ) ;
314318 } else if ( module . moduleType == commonStorage . MODULE_TYPE_MECHANISM ) {
315319 setRenameTooltip ( 'Rename Mechanism' ) ;
316320 setCopyTooltip ( 'Copy Mechanism' ) ;
Original file line number Diff line number Diff line change 1+ // src/i18n/config.ts
2+
3+ // Core i18next library.
4+ import i18n from "i18next" ;
5+ import HttpApi from "i18next-http-backend" ;
6+ // Bindings for React: allow components to
7+ // re-render when language changes.
8+ import { initReactI18next } from "react-i18next" ;
9+
10+ i18n
11+ // Wire up the backend as a plugin.
12+ . use ( HttpApi )
13+ // Add React bindings as a plugin.
14+ . use ( initReactI18next )
15+ // Initialize the i18next instance.
16+ . init ( {
17+ // Config options
18+
19+ // Specifies the default language (locale) used
20+ // when a user visits our site for the first time.
21+ // We use English here, but feel free to use
22+ // whichever locale you want.
23+ lng : "en" ,
24+
25+ // Fallback locale used when a translation is
26+ // missing in the active locale. Again, use your
27+ // preferred locale here.
28+ fallbackLng : "en" ,
29+
30+ // Normally, we want `escapeValue: true` as it
31+ // ensures that i18next escapes any code in
32+ // translation messages, safeguarding against
33+ // XSS (cross-site scripting) attacks. However,
34+ // React does this escaping itself, so we turn
35+ // it off in i18next.
36+ interpolation : {
37+ escapeValue : false ,
38+ } ,
39+ } ) ;
40+
41+ export default i18n ;
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import React from 'react';
22import ReactDOM from 'react-dom/client' ;
33import './index.css' ;
44import App from './App' ;
5+ import "./i18n/config.ts"
56import reportWebVitals from './reportWebVitals' ;
67
78const root = ReactDOM . createRoot (
You can’t perform that action at this time.
0 commit comments