some changes
This commit is contained in:
parent
5e96ab6955
commit
bc5c2075f4
8 changed files with 45 additions and 41 deletions
|
@ -1,7 +1,7 @@
|
|||
import { useUser } from '../../user/user.ts'
|
||||
import NavButton from '../../../components/buttons/NavButton.tsx'
|
||||
import { useLocation } from 'react-router-dom'
|
||||
import { useTranslations } from '../../i18n/useTranslations.ts'
|
||||
import { useTranslations } from '../../i18n/translations.ts'
|
||||
|
||||
export default function AuthNavButtons() {
|
||||
const { t } = useTranslations()
|
||||
|
|
|
@ -8,7 +8,7 @@ import { useUser } from '../../user/user.ts'
|
|||
import NavBar from '../../../components/NavBar.tsx'
|
||||
import NavButton from '../../../components/buttons/NavButton.tsx'
|
||||
import LinkButton from '../../../components/buttons/LinkButton.tsx'
|
||||
import { useTranslations } from '../../i18n/useTranslations.ts'
|
||||
import { useTranslations } from '../../i18n/translations.ts'
|
||||
|
||||
interface LoginPageProps {
|
||||
authService: AuthService
|
||||
|
|
|
@ -8,7 +8,7 @@ import { AuthService } from '../authService.ts'
|
|||
import LinkButton from '../../../components/buttons/LinkButton.tsx'
|
||||
import NavBar from '../../../components/NavBar.tsx'
|
||||
import NavButton from '../../../components/buttons/NavButton.tsx'
|
||||
import { useTranslations } from '../../i18n/useTranslations.ts'
|
||||
import { useTranslations } from '../../i18n/translations.ts'
|
||||
|
||||
const SignupCodeKey = 'signupCode'
|
||||
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
export interface Translations {
|
||||
'auth.login.cta': string
|
||||
'auth.login.register_instead': string
|
||||
'auth.password.label': string
|
||||
'auth.register.cta': string
|
||||
'auth.register.login_instead': string
|
||||
'auth.remember_me.label': string
|
||||
'auth.username.label': string
|
||||
|
||||
'misc.loading': string
|
||||
|
||||
'nav.admin': string
|
||||
'nav.home': string
|
||||
'nav.login': string
|
||||
'nav.logout': string
|
||||
'nav.register': string
|
||||
|
||||
'post.add_media.cta': string
|
||||
'post.editor.placeholder': string
|
||||
'post.public.label': string
|
||||
'post.submit.cta': string
|
||||
}
|
||||
|
||||
export type TranslationKey = keyof Translations
|
41
src/app/i18n/translations.ts
Normal file
41
src/app/i18n/translations.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import en from './translations/en.json' assert { type: 'json' }
|
||||
|
||||
interface Translation {
|
||||
'auth.login.cta': string
|
||||
'auth.login.register_instead': string
|
||||
'auth.password.label': string
|
||||
'auth.register.cta': string
|
||||
'auth.register.login_instead': string
|
||||
'auth.remember_me.label': string
|
||||
'auth.username.label': string
|
||||
|
||||
'misc.loading': string
|
||||
|
||||
'nav.admin': string
|
||||
'nav.home': string
|
||||
'nav.login': string
|
||||
'nav.logout': string
|
||||
'nav.register': string
|
||||
|
||||
'post.add_media.cta': string
|
||||
'post.editor.placeholder': string
|
||||
'post.public.label': string
|
||||
'post.submit.cta': string
|
||||
}
|
||||
|
||||
export type TranslationKey = keyof Translation
|
||||
|
||||
export interface UseTranslations {
|
||||
t: <K extends TranslationKey>(key: K) => Translation[K]
|
||||
}
|
||||
|
||||
export function useTranslations(): UseTranslations {
|
||||
// TODO somehow handle other languages (reactively)
|
||||
const texts = en as Translation
|
||||
|
||||
function getText<K extends TranslationKey>(key: K): Translation[K] {
|
||||
return texts[key] ?? key
|
||||
}
|
||||
|
||||
return { t: getText }
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
import { TranslationKey, Translations } from './translationKeys.ts'
|
||||
import en from './en.json' assert { type: 'json' }
|
||||
|
||||
export function useTranslations() {
|
||||
// TODO somehow handle other languages (reactively)
|
||||
const texts = en as Translations
|
||||
|
||||
function getText<K extends TranslationKey>(key: K): Translations[K] {
|
||||
return texts[key] ?? key
|
||||
}
|
||||
|
||||
return { t: getText }
|
||||
}
|
|
@ -3,7 +3,7 @@ import FancyTextEditor, { TextInputKeyDownEvent } from './inputs/FancyTextEditor
|
|||
import Button from './buttons/Button.tsx'
|
||||
import { openFileDialog } from '../utils/openFileDialog.ts'
|
||||
import makePica from 'pica'
|
||||
import { useTranslations } from '../app/i18n/useTranslations.ts'
|
||||
import { useTranslations } from '../app/i18n/translations.ts'
|
||||
|
||||
interface NewPostWidgetProps {
|
||||
onSubmit: (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue