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

@@ -95,7 +95,7 @@ const ChatInput = ({
}
}
},
errorToast: t('common.Upload File Failed')
errorToast: t('common:common.Upload File Failed')
});
const onSelectFile = useCallback(
async (files: File[]) => {
@@ -257,7 +257,7 @@ const ChatInput = ({
visibility={isSpeaking && isTransCription ? 'visible' : 'hidden'}
>
<Spinner size={'sm'} mr={4} />
{t('core.chat.Converting to text')}
{t('common:core.chat.Converting to text')}
</Flex>
{/* file preview */}
@@ -336,7 +336,7 @@ const ChatInput = ({
onOpenSelectFile();
}}
>
<MyTooltip label={t('core.chat.Select Image')}>
<MyTooltip label={t('common:core.chat.Select Image')}>
<MyIcon name={'core/chat/fileSelect'} w={'18px'} color={'myGray.600'} />
</MyTooltip>
<File onSelect={onSelectFile} />
@@ -353,7 +353,9 @@ const ChatInput = ({
_focusVisible={{
border: 'none'
}}
placeholder={isSpeaking ? t('core.chat.Speaking') : t('core.chat.Type a message')}
placeholder={
isSpeaking ? t('common:core.chat.Speaking') : t('common:core.chat.Type a message')
}
resize={'none'}
rows={1}
height={'22px'}
@@ -430,7 +432,7 @@ const ChatInput = ({
}}
/>
{isSpeaking && (
<MyTooltip label={t('core.chat.Cancel Speak')}>
<MyTooltip label={t('common:core.chat.Cancel Speak')}>
<Flex
mr={2}
alignItems={'center'}
@@ -451,7 +453,11 @@ const ChatInput = ({
</Flex>
</MyTooltip>
)}
<MyTooltip label={isSpeaking ? t('core.chat.Finish Speak') : t('core.chat.Record')}>
<MyTooltip
label={
isSpeaking ? t('common:core.chat.Finish Speak') : t('common:core.chat.Record')
}
>
<Flex
mr={2}
alignItems={'center'}
@@ -513,7 +519,7 @@ const ChatInput = ({
color={'gray.500'}
/>
) : (
<MyTooltip label={t('core.chat.Send Message')}>
<MyTooltip label={t('common:core.chat.Send Message')}>
<MyIcon
name={'core/chat/sendFill'}
width={['18px', '20px']}

View File

@@ -94,7 +94,7 @@ export default function InputGuideBox({
<Box fontSize={'sm'} flex={'1 0 0'}>
<HighlightText rawText={item} matchText={text} />
</Box>
<MyTooltip label={t('core.chat.markdown.Send Question')}>
<MyTooltip label={t('common:core.chat.markdown.Send Question')}>
<MyIcon
className="send-icon"
display={'none'}

View File

@@ -79,7 +79,7 @@ const ChatController = ({
}
})}
>
<MyTooltip label={t('common.Copy')}>
<MyTooltip label={t('common:common.Copy')}>
<MyIcon
{...controlIconStyle}
name={'copy'}
@@ -90,7 +90,7 @@ const ChatController = ({
{!!onDelete && !isChatting && (
<>
{onRetry && (
<MyTooltip label={t('core.chat.retry')}>
<MyTooltip label={t('common:core.chat.retry')}>
<MyIcon
{...controlIconStyle}
name={'common/retryLight'}
@@ -99,7 +99,7 @@ const ChatController = ({
/>
</MyTooltip>
)}
<MyTooltip label={t('common.Delete')}>
<MyTooltip label={t('common:common.Delete')}>
<MyIcon
{...controlIconStyle}
name={'delete'}
@@ -116,7 +116,7 @@ const ChatController = ({
if (isPlayingChat && audioPlaying) {
return (
<Flex alignItems={'center'}>
<MyTooltip label={t('core.chat.tts.Stop Speech')}>
<MyTooltip label={t('common:core.chat.tts.Stop Speech')}>
<MyIcon
{...controlIconStyle}
borderRight={'none'}
@@ -136,13 +136,13 @@ const ChatController = ({
}
if (isPlayingChat && audioLoading) {
return (
<MyTooltip label={t('common.Loading')}>
<MyTooltip label={t('common:common.Loading')}>
<MyIcon {...controlIconStyle} name={'common/loading'} />
</MyTooltip>
);
}
return (
<MyTooltip label={t('core.app.TTS start')}>
<MyTooltip label={t('common:core.app.TTS start')}>
<MyIcon
{...controlIconStyle}
name={'common/voiceLight'}
@@ -171,7 +171,7 @@ const ChatController = ({
);
})()}
{!!onMark && (
<MyTooltip label={t('core.chat.Mark')}>
<MyTooltip label={t('common:core.chat.Mark')}>
<MyIcon
{...controlIconStyle}
name={'core/app/markLight'}
@@ -183,7 +183,7 @@ const ChatController = ({
{chat.obj === ChatRoleEnum.AI && (
<>
{!!onCloseUserLike && chat.userGoodFeedback && (
<MyTooltip label={t('core.chat.feedback.Close User Like')}>
<MyTooltip label={t('common:core.chat.feedback.Close User Like')}>
<MyIcon
{...controlIconStyle}
color={'white'}
@@ -195,7 +195,7 @@ const ChatController = ({
</MyTooltip>
)}
{!!onReadUserDislike && chat.userBadFeedback && (
<MyTooltip label={t('core.chat.feedback.Read User dislike')}>
<MyTooltip label={t('common:core.chat.feedback.Read User dislike')}>
<MyIcon
{...controlIconStyle}
color={'white'}

View File

@@ -31,7 +31,7 @@ const FeedbackModal = ({
const { mutate, isLoading } = useRequest({
mutationFn: async () => {
const val = ref.current?.value || t('core.chat.feedback.No Content');
const val = ref.current?.value || t('common:core.chat.feedback.No Content');
return updateChatUserFeedback({
appId,
chatId,
@@ -44,10 +44,10 @@ const FeedbackModal = ({
});
},
onSuccess() {
onSuccess(ref.current?.value || t('core.chat.feedback.No Content'));
onSuccess(ref.current?.value || t('common:core.chat.feedback.No Content'));
},
successToast: t('core.chat.Feedback Success'),
errorToast: t('core.chat.Feedback Failed')
successToast: t('common:core.chat.Feedback Success'),
errorToast: t('common:core.chat.Feedback Failed')
});
return (
@@ -55,17 +55,17 @@ const FeedbackModal = ({
isOpen={true}
onClose={onClose}
iconSrc="/imgs/modal/badAnswer.svg"
title={t('core.chat.Feedback Modal')}
title={t('common:core.chat.Feedback Modal')}
>
<ModalBody>
<Textarea ref={ref} rows={10} placeholder={t('core.chat.Feedback Modal Tip')} />
<Textarea ref={ref} rows={10} placeholder={t('common:core.chat.Feedback Modal Tip')} />
</ModalBody>
<ModalFooter>
<Button variant={'whiteBase'} mr={2} onClick={onClose}>
{t('common.Close')}
{t('common:common.Close')}
</Button>
<Button isLoading={isLoading} onClick={mutate}>
{t('core.chat.Feedback Submit')}
{t('common:core.chat.Feedback Submit')}
</Button>
</ModalFooter>
</MyModal>

View File

@@ -51,7 +51,7 @@ const QuoteModal = ({
<>{t('core.chat.Quote Amount', { amount: rawSearch.length })}</>
)}
<Box fontSize={'xs'} color={'myGray.500'} fontWeight={'normal'}>
{t('core.chat.quote.Quote Tip')}
{t('common:core.chat.quote.Quote Tip')}
</Box>
</Box>
}

View File

@@ -19,12 +19,12 @@ const ReadFeedbackModal = ({
isOpen={true}
onClose={onClose}
iconSrc="/imgs/modal/readFeedback.svg"
title={t('core.chat.Feedback Modal')}
title={t('common:core.chat.Feedback Modal')}
>
<ModalBody>{content}</ModalBody>
<ModalFooter>
<Button mr={2} onClick={onCloseFeedback}>
{t('core.chat.feedback.Feedback Close')}
{t('common:core.chat.feedback.Feedback Close')}
</Button>
</ModalFooter>
</MyModal>

View File

@@ -102,10 +102,10 @@ const ResponseTags = ({
<>
{sourceList.length > 0 && (
<>
<ChatBoxDivider icon="core/chat/quoteFill" text={t('core.chat.Quote')} />
<ChatBoxDivider icon="core/chat/quoteFill" text={t('common:core.chat.Quote')} />
<Flex alignItems={'center'} flexWrap={'wrap'} gap={2}>
{sourceList.map((item) => (
<MyTooltip key={item.collectionId} label={t('core.chat.quote.Read Quote')}>
<MyTooltip key={item.collectionId} label={t('common:core.chat.quote.Read Quote')}>
<Flex
alignItems={'center'}
fontSize={'xs'}
@@ -186,14 +186,14 @@ const ResponseTags = ({
</MyTag>
</MyTooltip>
)}
<MyTooltip label={t('core.chat.response.Read complete response tips')}>
<MyTooltip label={t('common:core.chat.response.Read complete response tips')}>
<MyTag
colorSchema="gray"
type="borderSolid"
cursor={'pointer'}
onClick={onOpenWholeModal}
>
{t('core.chat.response.Read complete response')}
{t('common:core.chat.response.Read complete response')}
</MyTag>
</MyTooltip>
</Flex>

View File

@@ -45,7 +45,7 @@ const SelectMarkCollection = ({
onClose={onClose}
setParentId={setParentId}
isLoading={isFetching}
tips={t('core.chat.Select dataset Desc')}
tips={t('common:core.chat.Select dataset Desc')}
>
<ModalBody flex={'1 0 0'} overflowY={'auto'}>
<Grid
@@ -100,7 +100,7 @@ const SelectMarkCollection = ({
<SelectCollections
datasetId={adminMarkData.datasetId}
type={'collection'}
title={t('dataset.collections.Select One Collection To Store')}
title={t('common:dataset.collections.Select One Collection To Store')}
onClose={onClose}
onChange={({ collectionIds }) => {
setAdminMarkData({
@@ -120,7 +120,7 @@ const SelectMarkCollection = ({
});
}}
>
{t('common.Last Step')}
{t('common:common.Last Step')}
</Button>
</ModalFooter>
}

View File

@@ -104,7 +104,7 @@ const VariableInput = ({
chatForm.setValue('chatStarted', true);
})}
>
{t('core.chat.Start Chat')}
{t('common:core.chat.Start Chat')}
</Button>
)}
</Card>

View File

@@ -814,7 +814,7 @@ const ChatBox = (
return {
status: chatContent.status || 'loading',
name: t(chatContent.moduleName || '') || t('common.Loading')
name: t(chatContent.moduleName || '') || t('common:common.Loading')
};
}, [chatHistories, isChatting, t]);
@@ -935,11 +935,13 @@ const ChatBox = (
<Box>
<ChatBoxDivider
icon={'core/app/customFeedback'}
text={t('core.app.feedback.Custom feedback')}
text={t('common:core.app.feedback.Custom feedback')}
/>
{item.customFeedbacks.map((text, i) => (
<Box key={`${text}${i}`}>
<MyTooltip label={t('core.app.feedback.close custom feedback')}>
<MyTooltip
label={t('common:core.app.feedback.close custom feedback')}
>
<Checkbox onChange={onCloseCustomFeedback(item, i)}>
{text}
</Checkbox>
@@ -953,7 +955,7 @@ const ChatBox = (
<Box fontSize={'sm'}>
<ChatBoxDivider
icon="core/app/markLight"
text={t('core.chat.Admin Mark Content')}
text={t('common:core.chat.Admin Mark Content')}
/>
<Box whiteSpace={'pre-wrap'}>
<Box color={'black'}>{item.adminFeedback.q}</Box>

View File

@@ -58,7 +58,7 @@ const RenderInput = () => {
handleSubmit(onSubmit)();
}}
>
{histories.length > 0 ? t('common.Restart') : t('common.Run')}
{histories.length > 0 ? t('common:common.Restart') : t('common:common.Run')}
</Button>
</Flex>
)}

View File

@@ -96,7 +96,7 @@ const WholeResponseModal = ({
iconSrc="/imgs/modal/wholeRecord.svg"
title={
<Flex alignItems={'center'}>
{t('core.chat.response.Complete Response')}
{t('common:core.chat.response.Complete Response')}
<QuestionTip ml={2} label={'从左往右,为各个模块的响应顺序'}></QuestionTip>
</Flex>
}
@@ -175,27 +175,33 @@ export const ResponseBox = React.memo(function ResponseBox({
})}
>
<>
<Row label={t('core.chat.response.module name')} value={t(activeModule.moduleName)} />
<Row
label={t('common:core.chat.response.module name')}
value={t(activeModule.moduleName)}
/>
{activeModule?.totalPoints !== undefined && (
<Row
label={t('support.wallet.usage.Total points')}
label={t('common:support.wallet.usage.Total points')}
value={formatNumber(activeModule.totalPoints)}
/>
)}
<Row
label={t('core.chat.response.module time')}
label={t('common:core.chat.response.module time')}
value={`${activeModule?.runningTime || 0}s`}
/>
<Row label={t('core.chat.response.module model')} value={activeModule?.model} />
<Row label={t('core.chat.response.module tokens')} value={`${activeModule?.tokens}`} />
<Row label={t('common:core.chat.response.module model')} value={activeModule?.model} />
<Row
label={t('core.chat.response.Tool call tokens')}
label={t('common:core.chat.response.module tokens')}
value={`${activeModule?.tokens}`}
/>
<Row
label={t('common:core.chat.response.Tool call tokens')}
value={`${activeModule?.toolCallTokens}`}
/>
<Row label={t('core.chat.response.module query')} value={activeModule?.query} />
<Row label={t('common:core.chat.response.module query')} value={activeModule?.query} />
<Row
label={t('core.chat.response.context total length')}
label={t('common:core.chat.response.context total length')}
value={activeModule?.contextTotalLen}
/>
<Row label={workflowT('response.Error')} value={activeModule?.error} />
@@ -204,12 +210,15 @@ export const ResponseBox = React.memo(function ResponseBox({
{/* ai chat */}
<>
<Row
label={t('core.chat.response.module temperature')}
label={t('common:core.chat.response.module temperature')}
value={activeModule?.temperature}
/>
<Row label={t('core.chat.response.module maxToken')} value={activeModule?.maxToken} />
<Row
label={t('core.chat.response.module historyPreview')}
label={t('common:core.chat.response.module maxToken')}
value={activeModule?.maxToken}
/>
<Row
label={t('common:core.chat.response.module historyPreview')}
rawDom={
activeModule.historyPreview ? (
<Box px={3} py={2} border={theme.borders.base} borderRadius={'md'}>
@@ -239,31 +248,31 @@ export const ResponseBox = React.memo(function ResponseBox({
<>
{activeModule?.searchMode && (
<Row
label={t('core.dataset.search.search mode')}
label={t('common:core.dataset.search.search mode')}
// @ts-ignore
value={t(DatasetSearchModeMap[activeModule.searchMode]?.title)}
/>
)}
<Row
label={t('core.chat.response.module similarity')}
label={t('common:core.chat.response.module similarity')}
value={activeModule?.similarity}
/>
<Row label={t('core.chat.response.module limit')} value={activeModule?.limit} />
<Row label={t('common:core.chat.response.module limit')} value={activeModule?.limit} />
<Row
label={t('core.chat.response.search using reRank')}
label={t('common:core.chat.response.search using reRank')}
value={`${activeModule?.searchUsingReRank}`}
/>
<Row
label={t('core.chat.response.Extension model')}
label={t('common:core.chat.response.Extension model')}
value={activeModule?.extensionModel}
/>
<Row
label={t('support.wallet.usage.Extension result')}
label={t('common:support.wallet.usage.Extension result')}
value={`${activeModule?.extensionResult}`}
/>
{activeModule.quoteList && activeModule.quoteList.length > 0 && (
<Row
label={t('core.chat.response.module quoteList')}
label={t('common:core.chat.response.module quoteList')}
rawDom={<QuoteList showDetail={showDetail} rawSearch={activeModule.quoteList} />}
/>
)}
@@ -271,9 +280,12 @@ export const ResponseBox = React.memo(function ResponseBox({
{/* classify question */}
<>
<Row label={t('core.chat.response.module cq result')} value={activeModule?.cqResult} />
<Row
label={t('core.chat.response.module cq')}
label={t('common:core.chat.response.module cq result')}
value={activeModule?.cqResult}
/>
<Row
label={t('common:core.chat.response.module cq')}
value={(() => {
if (!activeModule?.cqList) return '';
return activeModule.cqList.map((item) => `* ${item.value}`).join('\n');
@@ -284,7 +296,7 @@ export const ResponseBox = React.memo(function ResponseBox({
{/* if-else */}
<>
<Row
label={t('core.chat.response.module if else Result')}
label={t('common:core.chat.response.module if else Result')}
value={activeModule?.ifElseResult}
/>
</>
@@ -292,11 +304,11 @@ export const ResponseBox = React.memo(function ResponseBox({
{/* extract */}
<>
<Row
label={t('core.chat.response.module extract description')}
label={t('common:core.chat.response.module extract description')}
value={activeModule?.extractDescription}
/>
<Row
label={t('core.chat.response.module extract result')}
label={t('common:core.chat.response.module extract result')}
value={activeModule?.extractResult}
/>
</>
@@ -307,17 +319,20 @@ export const ResponseBox = React.memo(function ResponseBox({
<Row label={'Params'} value={activeModule?.params} />
<Row label={'Body'} value={activeModule?.body} />
<Row
label={t('core.chat.response.module http result')}
label={t('common:core.chat.response.module http result')}
value={activeModule?.httpResult}
/>
</>
{/* plugin */}
<>
<Row label={t('core.chat.response.plugin output')} value={activeModule?.pluginOutput} />
<Row
label={t('common:core.chat.response.plugin output')}
value={activeModule?.pluginOutput}
/>
{activeModule?.pluginDetail && activeModule?.pluginDetail.length > 0 && (
<Row
label={t('core.chat.response.Plugin response detail')}
label={t('common:core.chat.response.Plugin response detail')}
rawDom={
<ResponseBox response={activeModule.pluginDetail} showDetail={showDetail} />
}
@@ -326,12 +341,15 @@ export const ResponseBox = React.memo(function ResponseBox({
</>
{/* text output */}
<Row label={t('core.chat.response.text output')} value={activeModule?.textOutput} />
<Row
label={t('common:core.chat.response.text output')}
value={activeModule?.textOutput}
/>
{/* tool call */}
{activeModule?.toolDetail && activeModule?.toolDetail.length > 0 && (
<Row
label={t('core.chat.response.Tool call response detail')}
label={t('common:core.chat.response.Tool call response detail')}
rawDom={<ResponseBox response={activeModule.toolDetail} showDetail={showDetail} />}
/>
)}