Fix: Cross-language dropdown menu options translation error. (#17615)

This commit is contained in:
balibabu
2026-07-31 14:11:04 +08:00
committed by GitHub
parent 4b619f699b
commit b8117812e4
4 changed files with 23 additions and 16 deletions

View File

@@ -6,12 +6,12 @@ import {
} from '@/components/ui/form';
import { MultiSelect } from '@/components/ui/multi-select';
import { cn } from '@/lib/utils';
import { t } from 'i18next';
import { toLower } from 'lodash';
import { useMemo } from 'react';
import { useFormContext } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
const Languages = [
export const Languages = [
'English',
'Chinese',
'Spanish',
@@ -25,10 +25,18 @@ const Languages = [
'Dutch',
];
export const crossLanguageOptions = Languages.map((x) => ({
label: t('language.' + toLower(x)),
value: x,
}));
export function useCrossLanguageOptions() {
const { t } = useTranslation();
return useMemo(
() =>
Languages.map((x) => ({
label: t('language.' + toLower(x)),
value: x,
})),
[t],
);
}
type CrossLanguageItemProps = {
name?: string;
@@ -43,6 +51,7 @@ export const CrossLanguageFormField = ({
}: CrossLanguageItemProps) => {
const { t } = useTranslation();
const form = useFormContext();
const crossLanguageOptions = useCrossLanguageOptions();
return (
<FormField