better code

Massimo Melina committed Mar 16, 2023 at 10:26 UTC fb355c4851474681ae895281ddcd195ab42bd490
2 files changed +2 -11
frontend/src/i18n.ts
-9
@@ -14,15 +14,6 @@ export function useI18N() {
14 return { t }
15 }
16
17 -// useful for imperative react contexts, that need to be rendered
18 -export function tComponent(...par: Parameters<typeof t>) {
19 - return () => {
20 - const {t} = useI18N()
21 - return h(Fragment, {}, t(...par))
22 - }
23 -}
24 -
25 -
17 export function I18Nprovider({ embedded='en', ...props }) {
18 const langs = urlParams.lang?.split(',') || navigator.languages
19 state.embedded = embedded
frontend/src/login.ts
+2 -2
@@ -6,7 +6,7 @@ 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'
9 -import { t, tComponent, useI18N } from './i18n'
9 +import { t, useI18N } from './i18n'
10
11 async function login(username:string, password:string) {
12 const stopWorking = working()
@@ -58,7 +58,7 @@ export async function loginDialog(navigate: ReturnType<typeof useNavigate>) {
58 resolve(v)
59 closeLoginDialog = undefined
60 },
61 - title: tComponent("Login"),
61 + title: t`Login`,
62 Content() {
63 const usrRef = useRef<HTMLInputElement>()
64 const pwdRef = useRef<HTMLInputElement>()