File tree Expand file tree Collapse file tree 4 files changed +42
-2
lines changed Expand file tree Collapse file tree 4 files changed +42
-2
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ - Copyright 2022 Sven Loesekann
3+ Licensed under the Apache License, Version 2.0 (the "License");
4+ you may not use this file except in compliance with the License.
5+ You may obtain a copy of the License at
6+ http://www.apache.org/licenses/LICENSE-2.0
7+ Unless required by applicable law or agreed to in writing, software
8+ distributed under the License is distributed on an "AS IS" BASIS,
9+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+ See the License for the specific language governing permissions and
11+ limitations under the License.
12+ */
13+ import i18next from 'i18next' ;
14+ import { initReactI18next } from 'react-i18next' ;
15+ import translation from './en/translation.json' ;
16+
17+ i18next . use ( initReactI18next ) . init ( {
18+ lng : 'en' , // if you're using a language detector, do not define the lng option
19+ debug : true ,
20+ resources : {
21+ en : {
22+ translation,
23+ } ,
24+ de : {
25+ translation
26+ }
27+ } ,
28+ // if you see an error like: "Argument of type 'DefaultTFuncReturn' is not assignable to parameter of type xyz"
29+ // set returnNull to false (and also in the i18next.d.ts options)
30+ // returnNull: false,
31+ } ) ;
Original file line number Diff line number Diff line change 1+ {
2+ "common" : {
3+ "ok" : " OK" ,
4+ "cancel" : " Cancel"
5+ }
6+ }
Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ import { useAtom } from "jotai";
2020import type { FormEvent , BaseSyntheticEvent , ChangeEventHandler } from "react" ;
2121import { postLogin , postSignin } from "~/service/http-client" ;
2222import type { UserResponse } from "~/model/user" ;
23+ import '../i18n/config' ;
24+ import { useTranslation , Trans } from 'react-i18next' ;
2325
2426interface MsgData {
2527 jwtToken ?: string ;
@@ -51,6 +53,7 @@ function TabPanel(props: TabPanelProps) {
5153}
5254
5355export function Login ( ) {
56+ const { t } = useTranslation ( ) ;
5457 const navigate = useNavigate ( ) ;
5558 let controller : AbortController | null = null ;
5659 const [ globalUserName , setGlobalUserName ] = useAtom ( GlobalState . userNameState ) ;
@@ -185,8 +188,8 @@ export function Login() {
185188 variant = "standard"
186189 />
187190 < div >
188- < Button type = "submit" > Ok </ Button >
189- < Button onClick = { handleCancel } > Cancel </ Button >
191+ < Button type = "submit" > { t ( 'common.ok' ) } </ Button >
192+ < Button onClick = { handleCancel } > { t ( 'common.cancel' ) } </ Button >
190193 </ div >
191194 < div className = { styles . responseMsg } >
192195 { [ responseMsg ] . filter ( value => ! ! value ) . map ( ( value , index ) =>
You can’t perform that action at this time.
0 commit comments