fix: login dialog title not translated if displayed at start
Massimo Melina committed
Mar 28, 2023 at 00:01 UTC
930faeaa9a9b6e179613314f6d2a06dd2f827109
1 file changed
+6
-2
frontend/src/login.ts
+6
-2
@@ -5,7 +5,7 @@ import { state, useSnapState } from './state'
5
import { alertDialog, newDialog } from './dialog'
6
import { getPrefixUrl, hIcon, srpSequence, working } from './misc'
7
import { useNavigate } from 'react-router-dom'
8
-import { createElement as h, useEffect, useRef } from 'react'
8
+import { createElement as h, Fragment, useEffect, useRef } from 'react'
9
import { t, useI18N } from './i18n'
10
11
async function login(username:string, password:string) {
@@ -60,7 +60,7 @@ export async function loginDialog(navigate: ReturnType<typeof useNavigate>) {
60
resolve(v)
61
closeLoginDialog = undefined
62
},
63
- title: t`Login`,
63
+ title: () => h(Fragment, {}, useI18N().t(`Login`)), // this dialog could be displayed before the language has been loaded
64
Content() {
65
const usrRef = useRef<HTMLInputElement>()
66
const pwdRef = useRef<HTMLInputElement>()
@@ -145,3 +145,7 @@ export function useAuthorized() {
145
return loginRequired ? null : true
146
}
147
148
+function tElement(s: string) {
149
+ const {t} = useI18N()
150
+ return t(s)
151
+}