Skip to content

Commit

Permalink
fix: add translation for error
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgemoya committed Jan 14, 2025
1 parent 2d061a7 commit a0ed3c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 4 additions & 1 deletion core/components/header/_actions/switch-locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
import { SubmissionResult } from '@conform-to/react';
import { parseWithZod } from '@conform-to/zod';
import { revalidatePath } from 'next/cache';
import { getTranslations } from 'next-intl/server';

import { localeSchema } from '@/vibes/soul/primitives/navigation/schema';
import { defaultLocale, redirect } from '~/i18n/routing';

export const switchLocale = async (_prevState: SubmissionResult | null, payload: FormData) => {
const t = await getTranslations('Components.Header.Locale');

const submission = parseWithZod(payload, { schema: localeSchema });

if (submission.status !== 'success') {
return submission.reply({ formErrors: ['Invalid locale'] });
return submission.reply({ formErrors: [t('invalidLocale')] });
}

await Promise.resolve();
Expand Down
5 changes: 2 additions & 3 deletions core/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -507,9 +507,8 @@
"login": "Login",
"logout": "Log out"
},
"LocaleSwitcher": {
"chooseCountryAndLanguage": "Choose your country and language",
"goToSite": "Go to site"
"Locale": {
"invalidLocale": "Invalid locale"
},
"MiniCart": {
"cart": "Cart",
Expand Down

0 comments on commit a0ed3c8

Please sign in to comment.