Skip to content

Commit 3b1ee76

Browse files
authored
fix: Optimize internationalization configuration #3221 (#9924)
### What problem does this PR solve? fix: Optimize internationalization configuration - Update multi-language options, adding general translations for functions like Select All and Clear - Add internationalization support for modules like Chat, Search, and Datasets ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
1 parent 41cb943 commit 3b1ee76

File tree

36 files changed

+175
-51
lines changed

36 files changed

+175
-51
lines changed

web/src/components/cross-language-form-field.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import {
66
} from '@/components/ui/form';
77
import { MultiSelect } from '@/components/ui/multi-select';
88
import { cn } from '@/lib/utils';
9+
import { t } from 'i18next';
10+
import { toLower } from 'lodash';
911
import { useFormContext } from 'react-hook-form';
1012
import { useTranslation } from 'react-i18next';
1113

@@ -20,7 +22,10 @@ const Languages = [
2022
'Vietnamese',
2123
];
2224

23-
const options = Languages.map((x) => ({ label: x, value: x }));
25+
const options = Languages.map((x) => ({
26+
label: t('language.' + toLower(x)),
27+
value: x,
28+
}));
2429

2530
type CrossLanguageItemProps = {
2631
name?: string;

web/src/components/delimiter-form-field.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export function DelimiterFormField() {
5252
<FormItem className=" items-center space-y-0 ">
5353
<div className="flex items-center gap-1">
5454
<FormLabel
55+
required
5556
tooltip={t('knowledgeDetails.delimiterTip')}
5657
className="text-sm text-muted-foreground whitespace-break-spaces w-1/4"
5758
>

web/src/components/indented-tree/indented-tree.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { TreeData } from '@antv/g6/lib/types';
1818
import isEmpty from 'lodash/isEmpty';
1919
import React, { useCallback, useEffect, useRef } from 'react';
2020
import { ErrorBoundary, FallbackProps } from 'react-error-boundary';
21+
import { useIsDarkTheme } from '../theme-provider';
2122

2223
const rootId = 'root';
2324

@@ -322,7 +323,7 @@ const IndentedTree = ({ data, show, style = {} }: IProps) => {
322323
node.children.forEach((child, idx) => assignIds(child, node.id, idx));
323324
}
324325
}, []);
325-
326+
const isDark = useIsDarkTheme();
326327
const render = useCallback(
327328
async (data: TreeData) => {
328329
const graph: Graph = new Graph({
@@ -335,7 +336,8 @@ const IndentedTree = ({ data, show, style = {} }: IProps) => {
335336
labelBackground: (datum) => datum.id === rootId,
336337
labelBackgroundRadius: 0,
337338
labelBackgroundFill: '#576286',
338-
labelFill: (datum) => (datum.id === rootId ? '#fff' : '#666'),
339+
labelFill: isDark ? '#fff' : '#333',
340+
// labelFill: (datum) => (datum.id === rootId ? '#fff' : '#666'),
339341
labelText: (d) => d.style?.labelText || d.id,
340342
labelTextAlign: (datum) =>
341343
datum.id === rootId ? 'center' : 'left',

web/src/components/knowledge-base-item.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ export function KnowledgeBaseFormField({
134134
name="kb_ids"
135135
render={({ field }) => (
136136
<FormItem>
137-
<FormLabel>{t('chat.knowledgeBases')}</FormLabel>
137+
<FormLabel tooltip={t('chat.knowledgeBasesTip')}>
138+
{t('chat.knowledgeBases')}
139+
</FormLabel>
138140
<FormControl>
139141
<MultiSelect
140142
options={options}

web/src/components/list-filter-bar/filter-popover.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
FormLabel,
1919
FormMessage,
2020
} from '@/components/ui/form';
21+
import { t } from 'i18next';
2122
import { FilterChange, FilterCollection, FilterValue } from './interface';
2223

2324
export type CheckboxFormMultipleProps = {
@@ -134,10 +135,10 @@ function CheckboxFormMultiple({
134135
size={'sm'}
135136
onClick={onReset}
136137
>
137-
Clear
138+
{t('common.clear')}
138139
</Button>
139140
<Button type="submit" size={'sm'}>
140-
Submit
141+
{t('common.submit')}
141142
</Button>
142143
</div>
143144
</form>

web/src/components/max-token-number-from-field.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export function MaxTokenNumberFormField({ max = 2048, initialValue }: IProps) {
1414
<SliderInputFormField
1515
name={'parser_config.chunk_token_num'}
1616
label={t('chunkTokenNumber')}
17+
tooltip={t('chunkTokenNumberTip')}
1718
max={max}
1819
defaultValue={initialValue ?? 0}
1920
layout={FormLayout.Horizontal}

web/src/components/message-input/next.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
import { Button } from '@/components/ui/button';
1616
import { Textarea } from '@/components/ui/textarea';
1717
import { cn } from '@/lib/utils';
18+
import { t } from 'i18next';
1819
import { CircleStop, Paperclip, Send, Upload, X } from 'lucide-react';
1920
import * as React from 'react';
2021
import { toast } from 'sonner';
@@ -141,7 +142,7 @@ export function NextMessageInput({
141142
<Textarea
142143
value={value}
143144
onChange={onInputChange}
144-
placeholder="Type your message here..."
145+
placeholder={t('chat.messagePlaceholder')}
145146
className="field-sizing-content min-h-10 w-full resize-none border-0 bg-transparent p-0 shadow-none focus-visible:ring-0 dark:bg-transparent"
146147
disabled={isUploading || disabled || sendLoading}
147148
onKeyDown={handleKeyDown}

web/src/components/parse-configuration/raptor-form-fields.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ const RaptorFormFields = () => {
9595
tooltip={t('useRaptorTip')}
9696
className="text-sm text-muted-foreground w-1/4 whitespace-break-spaces"
9797
>
98-
{t('useRaptor')}
98+
<div className="w-auto xl:w-20 2xl:w-24 3xl:w-28 4xl:w-auto ">
99+
{t('useRaptor')}
100+
</div>
99101
</FormLabel>
100102
<div className="w-3/4">
101103
<FormControl>

web/src/components/ui/form.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ const FormLabel = React.forwardRef<
9494
React.ElementRef<typeof LabelPrimitive.Root>,
9595
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & {
9696
tooltip?: React.ReactNode;
97+
required?: boolean;
9798
}
98-
>(({ className, tooltip, ...props }, ref) => {
99+
>(({ className, tooltip, required = false, ...props }, ref) => {
99100
const { error, formItemId } = useFormField();
100101

101102
return (
@@ -105,6 +106,7 @@ const FormLabel = React.forwardRef<
105106
htmlFor={formItemId}
106107
{...props}
107108
>
109+
{required && <span className="text-destructive">*</span>}
108110
{props.children}
109111
{tooltip && <FormTooltip tooltip={tooltip}></FormTooltip>}
110112
</Label>

web/src/components/ui/multi-select.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
} from '@/components/ui/popover';
3030
import { Separator } from '@/components/ui/separator';
3131
import { cn } from '@/lib/utils';
32+
import { t } from 'i18next';
3233
import { isEmpty } from 'lodash';
3334

3435
export type MultiSelectOptionType = {
@@ -193,7 +194,7 @@ export const MultiSelect = React.forwardRef<
193194
onValueChange,
194195
variant,
195196
defaultValue = [],
196-
placeholder = 'Select options',
197+
placeholder = t('common.selectPlaceholder'),
197198
animation = 0,
198199
maxCount = 3,
199200
modalPopover = false,
@@ -379,7 +380,7 @@ export const MultiSelect = React.forwardRef<
379380
>
380381
<Command>
381382
<CommandInput
382-
placeholder="Search..."
383+
placeholder={t('common.search') + '...'}
383384
onKeyDown={handleInputKeyDown}
384385
/>
385386
<CommandList>
@@ -401,7 +402,7 @@ export const MultiSelect = React.forwardRef<
401402
>
402403
<CheckIcon className="h-4 w-4" />
403404
</div>
404-
<span>(Select All)</span>
405+
<span>({t('common.selectAll')})</span>
405406
</CommandItem>
406407
)}
407408
{!options.some((x) => 'options' in x) &&
@@ -457,7 +458,7 @@ export const MultiSelect = React.forwardRef<
457458
onSelect={() => setIsPopoverOpen(false)}
458459
className="flex-1 justify-center cursor-pointer max-w-full"
459460
>
460-
Close
461+
{t('common.close')}
461462
</CommandItem>
462463
</div>
463464
</CommandGroup>

0 commit comments

Comments
 (0)