I18n additionals (#125)

* New translation keys

* Updates in src/components

* Updates in src/providers

* remove lable in selector, not needed

---------

Co-authored-by: Lokowitz <marvinlokowitz@gmail.com>
This commit is contained in:
vlalx 2025-06-03 21:10:00 +03:00 committed by GitHub
parent dc6fafba41
commit d768bb163a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 152 additions and 51 deletions

View file

@ -34,11 +34,6 @@ import { useUserContext } from "@app/hooks/useUserContext";
import { CheckCircle2 } from "lucide-react";
import { useTranslations } from "next-intl";
const disableSchema = z.object({
password: z.string().min(1, { message: "Password is required" }),
code: z.string().min(1, { message: "Code is required" })
});
type Disable2FaProps = {
open: boolean;
setOpen: (val: boolean) => void;
@ -53,6 +48,13 @@ export default function Disable2FaForm({ open, setOpen }: Disable2FaProps) {
const api = createApiClient(useEnvContext());
const t = useTranslations();
const disableSchema = z.object({
password: z.string().min(1, { message: t('passwordRequired') }),
code: z.string().min(1, { message: t('verificationCodeRequired') })
});
const disableForm = useForm<z.infer<typeof disableSchema>>({
resolver: zodResolver(disableSchema),
defaultValues: {
@ -61,8 +63,6 @@ export default function Disable2FaForm({ open, setOpen }: Disable2FaProps) {
}
});
const t = useTranslations();
const request2fa = async (values: z.infer<typeof disableSchema>) => {
setLoading(true);

View file

@ -1,4 +1,4 @@
import { useLocale } from 'next-intl';
import { useLocale } from "next-intl";
import LocaleSwitcherSelect from './LocaleSwitcherSelect';
export default function LocaleSwitcher() {
@ -9,35 +9,34 @@ export default function LocaleSwitcher() {
defaultValue={locale}
items={[
{
value: 'en-US',
label: 'Englisch'
value: 'en-US',
label: 'English'
},
{
value: 'fr-FR',
label: 'French'
value: 'fr-FR',
label: "Français"
},
{
value: 'de-DE',
label: 'German'
value: 'de-DE',
label: 'Deutsch'
},
{
value: 'it-IT',
label: 'Italian'
value: 'it-IT',
label: 'Italiano'
},
{
value: 'pl-PL',
label: 'Polish'
value: 'pl-PL',
label: 'Polski'
},
{
value: 'pt-PT',
label: 'Portuguese'
value: 'pt-PT',
label: 'Português'
},
{
value: 'tr-TR',
label: 'Turkish'
value: 'tr-TR',
label: 'Türkçe'
}
]}
label='Language'
/>
);
}

View file

@ -53,17 +53,6 @@ type LoginFormProps = {
idps?: LoginFormIDP[];
};
const formSchema = z.object({
email: z.string().email({ message: "Invalid email address" }),
password: z
.string()
.min(8, { message: "Password must be at least 8 characters" })
});
const mfaSchema = z.object({
code: z.string().length(6, { message: "Invalid code" })
});
export default function LoginForm({ redirect, onLogin, idps }: LoginFormProps) {
const router = useRouter();
@ -77,6 +66,19 @@ export default function LoginForm({ redirect, onLogin, idps }: LoginFormProps) {
const [mfaRequested, setMfaRequested] = useState(false);
const t = useTranslations();
const formSchema = z.object({
email: z.string().email({ message: t('emailInvalid') }),
password: z
.string()
.min(8, { message: t('passwordRequirementsChars') })
});
const mfaSchema = z.object({
code: z.string().length(6, { message: t('pincodeInvalid') })
});
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
@ -92,8 +94,6 @@ export default function LoginForm({ redirect, onLogin, idps }: LoginFormProps) {
}
});
const t = useTranslations();
async function onSubmit(values: any) {
const { email, password } = form.getValues();
const { code } = mfaForm.getValues();