feat: optimize i18n implementation for better localization (#2062)

* feat: optimize i18n implementation for better localization

* delete i18n-ally-custom-framework.yml

* update common key
This commit is contained in:
jingyang
2024-07-16 17:56:27 +08:00
committed by GitHub
parent 1e4ffc2481
commit fc96bb99cc
206 changed files with 1360 additions and 1277 deletions

View File

@@ -10,7 +10,11 @@ export const useCopyData = () => {
const { toast } = useToast();
const copyData = useCallback(
async (data: string, title: string | null = t('common.Copy Successful'), duration = 1000) => {
async (
data: string,
title: string | null = t('common:common.Copy Successful'),
duration = 1000
) => {
try {
if (navigator.clipboard) {
await navigator.clipboard.writeText(data);

View File

@@ -78,7 +78,7 @@ export const useEditTitle = ({
({
maxLength = 30,
iconSrc = 'modal/edit',
closeBtnText = t('common.Close')
closeBtnText = t('common:common.Close')
}: {
maxLength?: number;
iconSrc?: string;
@@ -110,7 +110,7 @@ export const useEditTitle = ({
</Button>
)}
<Button onClick={runAsync} isLoading={loading}>
{t('common.Confirm')}
{t('common:common.Confirm')}
</Button>
</ModalFooter>
</MyModal>

View File

@@ -54,7 +54,7 @@ export const useSpeech = (props?: OutLinkChatAuthProps & { appId?: string }) =>
if (!navigator?.mediaDevices?.getUserMedia) {
return toast({
status: 'warning',
title: t('common.speech.not support')
title: t('common:common.speech.not support')
});
}
try {
@@ -116,7 +116,7 @@ export const useSpeech = (props?: OutLinkChatAuthProps & { appId?: string }) =>
} catch (error) {
toast({
status: 'warning',
title: getErrText(error, t('common.speech.error tip'))
title: getErrText(error, t('common:common.speech.error tip'))
});
}
}

View File

@@ -1,4 +1,4 @@
import { I18nNsType } from '@/types/i18n';
import { I18nNsType } from '@/types/i18next';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
export const LANG_KEY = 'NEXT_LOCALE_LANG';

View File

@@ -62,7 +62,7 @@ export const useAudioPlay = (props?: OutLinkChatAuthProps & { ttsConfig?: AppTTS
const data = await response.json();
toast({
status: 'error',
title: getErrText(data, t('core.chat.Audio Speech Error'))
title: getErrText(data, t('common:core.chat.Audio Speech Error'))
});
return Promise.reject(data);
}
@@ -119,7 +119,7 @@ export const useAudioPlay = (props?: OutLinkChatAuthProps & { ttsConfig?: AppTTS
if (!MediaSource) {
toast({
status: 'error',
title: t('core.chat.Audio Not Support')
title: t('common:core.chat.Audio Not Support')
});
return;
}
@@ -194,7 +194,7 @@ export const useAudioPlay = (props?: OutLinkChatAuthProps & { ttsConfig?: AppTTS
} catch (error) {
toast({
status: 'error',
title: getErrText(error, t('core.chat.Audio Speech Error'))
title: getErrText(error, t('common:core.chat.Audio Speech Error'))
});
reject(error);
}
@@ -215,7 +215,7 @@ export const useAudioPlay = (props?: OutLinkChatAuthProps & { ttsConfig?: AppTTS
if (!MediaSource) {
return toast({
status: 'error',
title: t('core.chat.Audio Not Support')
title: t('common:core.chat.Audio Not Support')
});
}
cancelAudio();

View File

@@ -712,29 +712,29 @@ export const getSystemVariables = (t: TFunction): EditorVariablePickerType[] =>
return [
{
key: 'appId',
label: t('core.module.http.AppId'),
label: t('common:core.module.http.AppId'),
required: true,
valueType: WorkflowIOValueTypeEnum.string
},
{
key: 'chatId',
label: t('core.module.http.ChatId'),
label: t('common:core.module.http.ChatId'),
valueType: WorkflowIOValueTypeEnum.string
},
{
key: 'responseChatItemId',
label: t('core.module.http.ResponseChatItemId'),
label: t('common:core.module.http.ResponseChatItemId'),
valueType: WorkflowIOValueTypeEnum.string
},
{
key: 'histories',
label: t('core.module.http.Histories'),
label: t('common:core.module.http.Histories'),
required: true,
valueType: WorkflowIOValueTypeEnum.chatHistory
},
{
key: 'cTime',
label: t('core.module.http.Current time'),
label: t('common:core.module.http.Current time'),
required: true,
valueType: WorkflowIOValueTypeEnum.string
}

View File

@@ -97,7 +97,7 @@ const SelectCollections = ({
return null;
},
errorToast: t('common.Request Error')
errorToast: t('common:common.Request Error')
});
return (
@@ -122,8 +122,8 @@ const SelectCollections = ({
{title
? title
: type === 'folder'
? t('common.Root folder')
: t('dataset.collections.Select Collection')}
? t('common:common.Root folder')
: t('common:dataset.collections.Select Collection')}
</Box>
{!!tip && (
<Box fontSize={'sm'} color={'myGray.500'}>
@@ -194,7 +194,7 @@ const SelectCollections = ({
)}
</Grid>
{collections.length === 0 && (
<EmptyTip pt={'20vh'} text={t('common.folder.No Folder')}></EmptyTip>
<EmptyTip pt={'20vh'} text={t('common:common.folder.No Folder')}></EmptyTip>
)}
<Loading loading={isLoading} fixed={false} />
</ModalBody>
@@ -207,7 +207,7 @@ const SelectCollections = ({
isDisabled={type === 'collection' && selectedDatasetCollectionIds.length === 0}
onClick={mutate}
>
{type === 'folder' ? t('common.Confirm Move') : t('common.Confirm')}
{type === 'folder' ? t('common:common.Confirm Move') : t('common:common.Confirm')}
</Button>
</ModalFooter>
)}

View File

@@ -102,32 +102,32 @@ export const DatasetPageContextProvider = ({
if (vectorTrainingCount < 1000)
return {
colorSchema: 'green',
tip: t('core.dataset.training.Leisure')
tip: t('common:core.dataset.training.Leisure')
};
if (vectorTrainingCount < 10000)
return {
colorSchema: 'yellow',
tip: t('core.dataset.training.Waiting')
tip: t('common:core.dataset.training.Waiting')
};
return {
colorSchema: 'red',
tip: t('core.dataset.training.Full')
tip: t('common:core.dataset.training.Full')
};
})();
const agentTrainingMap = (() => {
if (agentTrainingCount < 100)
return {
colorSchema: 'green',
tip: t('core.dataset.training.Leisure')
tip: t('common:core.dataset.training.Leisure')
};
if (agentTrainingCount < 1000)
return {
colorSchema: 'yellow',
tip: t('core.dataset.training.Waiting')
tip: t('common:core.dataset.training.Waiting')
};
return {
colorSchema: 'red',
tip: t('core.dataset.training.Full')
tip: t('common:core.dataset.training.Full')
};
})();
return {

View File

@@ -25,7 +25,7 @@ export function getCollectionSourceAndOpen(collectionId: string) {
}
} catch (error) {
toast({
title: getErrText(error, t('error.fileNotFound')),
title: getErrText(error, t('common:error.fileNotFound')),
status: 'error'
});
}

View File

@@ -15,7 +15,7 @@ export const useSendCode = () => {
const [codeSending, setCodeSending] = useState(false);
const [codeCountDown, setCodeCountDown] = useState(0);
const sendCodeText = useMemo(() => {
if (codeSending) return t('support.user.auth.Sending Code');
if (codeSending) return t('common:support.user.auth.Sending Code');
if (codeCountDown >= 10) {
return `${codeCountDown}s后重新获取`;
}