mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-03 00:58:50 +01:00
🔄 chore: Enforce 18next Language Keys (#5803)
* chore: enforcing language keys to adhere to the new standard. * chore: enforcing i18n forbids to write plain text in JSX markup * chore: enforcing i18n forbids to write plain text in JSX markup * fix: ci with checkbox for unused keys :) * refactor: removed all the unused `i18n` keys
This commit is contained in:
parent
2a506df443
commit
7f48030452
33 changed files with 200 additions and 219 deletions
|
|
@ -1,4 +1,4 @@
|
|||
/* eslint-disable react-hooks/rules-of-hooks */
|
||||
|
||||
import { ArrowUpDown, Database } from 'lucide-react';
|
||||
import { FileSources, FileContext } from 'librechat-data-provider';
|
||||
import type { ColumnDef } from '@tanstack/react-table';
|
||||
|
|
@ -7,10 +7,10 @@ import { Button, Checkbox, OpenAIMinimalIcon, AzureMinimalIcon } from '~/compone
|
|||
import ImagePreview from '~/components/Chat/Input/Files/ImagePreview';
|
||||
import FilePreview from '~/components/Chat/Input/Files/FilePreview';
|
||||
import { SortFilterHeader } from './SortFilterHeader';
|
||||
import { useLocalize, useMediaQuery } from '~/hooks';
|
||||
import { TranslationKeys, useLocalize, useMediaQuery } from '~/hooks';
|
||||
import { formatDate, getFileType } from '~/utils';
|
||||
|
||||
const contextMap = {
|
||||
const contextMap: Record<any, TranslationKeys> = {
|
||||
[FileContext.avatar]: 'com_ui_avatar',
|
||||
[FileContext.unknown]: 'com_ui_unknown',
|
||||
[FileContext.assistants]: 'com_ui_assistants',
|
||||
|
|
@ -127,8 +127,8 @@ export const columns: ColumnDef<TFile>[] = [
|
|||
),
|
||||
}}
|
||||
valueMap={{
|
||||
[FileSources.azure]: 'Azure',
|
||||
[FileSources.openai]: 'OpenAI',
|
||||
[FileSources.azure]: 'com_ui_azure',
|
||||
[FileSources.openai]: 'com_ui_openai',
|
||||
[FileSources.local]: 'com_ui_host',
|
||||
}}
|
||||
/>
|
||||
|
|
@ -182,7 +182,7 @@ export const columns: ColumnDef<TFile>[] = [
|
|||
const localize = useLocalize();
|
||||
return (
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
{localize(contextMap[context ?? FileContext.unknown] ?? 'com_ui_unknown')}
|
||||
{localize(contextMap[context ?? FileContext.unknown])}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
|
|
@ -212,4 +212,4 @@ export const columns: ColumnDef<TFile>[] = [
|
|||
return `${value}${suffix}`;
|
||||
},
|
||||
},
|
||||
];
|
||||
];
|
||||
|
|
@ -16,7 +16,7 @@ interface SortFilterHeaderProps<TData, TValue> extends React.HTMLAttributes<HTML
|
|||
title: string;
|
||||
column: Column<TData, TValue>;
|
||||
filters?: Record<string, string[] | number[]>;
|
||||
valueMap?: Record<string, string>;
|
||||
valueMap?: Record<any, TranslationKeys>;
|
||||
}
|
||||
|
||||
export function SortFilterHeader<TData, TValue>({
|
||||
|
|
@ -82,7 +82,7 @@ export function SortFilterHeader<TData, TValue>({
|
|||
const translationKey = valueMap?.[value ?? ''];
|
||||
const filterValue =
|
||||
translationKey != null && translationKey.length
|
||||
? localize(translationKey as TranslationKeys)
|
||||
? localize(translationKey)
|
||||
: String(value);
|
||||
if (!filterValue) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import type { MentionOption, ConvoGenerator } from '~/common';
|
|||
import useSelectMention from '~/hooks/Input/useSelectMention';
|
||||
import { useAssistantsMapContext } from '~/Providers';
|
||||
import useMentions from '~/hooks/Input/useMentions';
|
||||
import { useLocalize, useCombobox } from '~/hooks';
|
||||
import { useLocalize, useCombobox, TranslationKeys } from '~/hooks';
|
||||
import { removeCharIfLast } from '~/utils';
|
||||
import MentionItem from './MentionItem';
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ export default function Mention({
|
|||
newConversation: ConvoGenerator;
|
||||
textAreaRef: React.MutableRefObject<HTMLTextAreaElement | null>;
|
||||
commandChar?: string;
|
||||
placeholder?: string;
|
||||
placeholder?: TranslationKeys;
|
||||
includeAssistants?: boolean;
|
||||
}) {
|
||||
const localize = useLocalize();
|
||||
|
|
@ -162,7 +162,7 @@ export default function Mention({
|
|||
<div className="popover border-token-border-light rounded-2xl border bg-white p-2 shadow-lg dark:bg-gray-700">
|
||||
<input
|
||||
// The user expects focus to transition to the input field when the popover is opened
|
||||
// eslint-disable-next-line jsx-a11y/no-autofocus
|
||||
|
||||
autoFocus
|
||||
ref={inputRef}
|
||||
placeholder={localize(placeholder)}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue