Skip to content

Commit

Permalink
(feat:settings) sync with locales
Browse files Browse the repository at this point in the history
  • Loading branch information
ManishMadan2882 committed Jan 4, 2025
1 parent b9540ba commit fa10812
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 54 deletions.
28 changes: 22 additions & 6 deletions frontend/src/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,36 @@
"selectLanguage": "Select Language",
"chunks": "Chunks processed per query",
"prompt": "Active Prompt",
"deleteAllLabel": "Delete all Conversation",
"deleteAllBtn": "Delete all",
"deleteAllLabel": "Delete All Conversations",
"deleteAllBtn": "Delete All",
"addNew": "Add New",
"convHistory": "Conversational history",
"convHistory": "Conversation History",
"none": "None",
"low": "Low",
"medium": "Medium",
"high": "High",
"unlimited": "Unlimited",
"default": "default"
"default": "Default"
},
"documents": {
"label": "Documents",
"name": "Document Name",
"date": "Vector Date",
"type": "Type",
"tokenUsage": "Token Usage",
"noData": "No existing Documents"
"noData": "No existing Documents",
"searchPlaceholder": "Search...",
"addNew": "Add New",
"addNewTitle": "Add New Document",
"preLoaded": "Pre-loaded",
"private": "Private",
"sync": "Sync",
"syncFrequency": {
"never": "Never",
"daily": "Daily",
"weekly": "Weekly",
"monthly": "Monthly"
}
},
"apiKeys": {
"label": "Chatbots",
Expand All @@ -72,7 +84,11 @@
"label": "Analytics"
},
"logs": {
"label": "Logs"
"label": "Logs",
"filterByChatbot": "Filter by chatbot",
"none": "None",
"selectChatbotPlaceholder": "Select chatbot",
"apiGeneratedConversations": "API generated / chatbot conversations"
},
"tools": {
"label": "Tools"
Expand Down
26 changes: 21 additions & 5 deletions frontend/src/locale/es.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"language": "Spanish",
"language": "Español",
"chat": "Chat",
"chats": "Chats",
"newChat": "Nuevo Chat",
Expand Down Expand Up @@ -41,7 +41,7 @@
"selectLanguage": "Seleccionar Idioma",
"chunks": "Trozos procesados por consulta",
"prompt": "Prompt Activo",
"deleteAllLabel": "Eliminar toda la Conversación",
"deleteAllLabel": "Eliminar todas las conversaciones",
"deleteAllBtn": "Eliminar todo",
"addNew": "Agregar Nuevo",
"convHistory": "Historial de conversaciones",
Expand All @@ -50,15 +50,27 @@
"medium": "Medio",
"high": "Alto",
"unlimited": "Ilimitado",
"default": "predeterminado"
"default": "Predeterminado"
},
"documents": {
"label": "Documentos",
"name": "Nombre del Documento",
"date": "Fecha Vector",
"type": "Tipo",
"tokenUsage": "Uso de Tokens",
"noData": "No hay documentos existentes"
"noData": "No hay documentos existentes",
"searchPlaceholder": "Buscar...",
"addNew": "Agregar Nuevo",
"addNewTitle": "Agregar Nuevo Documento",
"preLoaded": "Precargado",
"private": "Privado",
"sync": "Sincronizar",
"syncFrequency": {
"never": "Nunca",
"daily": "Diario",
"weekly": "Semanal",
"monthly": "Mensual"
}
},
"apiKeys": {
"label": "Chatbots",
Expand All @@ -72,7 +84,11 @@
"label": "Analítica"
},
"logs": {
"label": "Registros"
"label": "Registros",
"filterByChatbot": "Filtrar por chatbot",
"none": "Ninguno",
"selectChatbotPlaceholder": "Seleccionar chatbot",
"apiGeneratedConversations": "Conversaciones generadas por API / chatbot"
},
"tools": {
"label": "Herramientas"
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/locale/jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@
"label": "分析"
},
"logs": {
"label": "ログ"
"label": "ログ",
"filterByChatbot": "チャットボットでフィルタ",
"none": "なし",
"selectChatbotPlaceholder": "チャットボットを選択",
"apiGeneratedConversations": "API生成/チャットボット会話"
},
"tools": {
"label": "ツール"
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/locale/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@
"label": "Аналитика"
},
"logs": {
"label": "Журналы"
"label": "Регистры",
"filterByChatbot": "Фильтр по чат-боту",
"none": "Нет",
"selectChatbotPlaceholder": "Выберите чат-бота",
"apiGeneratedConversations": "Разговоры, сгенерированные API / чат-ботом"
},
"tools": {
"label": "Инструменты"
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/locale/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@
"label": "分析"
},
"logs": {
"label": "日誌"
"label": "日誌",
"filterByChatbot": "按聊天機器人篩選",
"none": "",
"selectChatbotPlaceholder": "選擇聊天機器人",
"apiGeneratedConversations": "API生成/聊天機器人對話"
},
"tools": {
"label": "工具"
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/locale/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@
"label": "分析"
},
"logs": {
"label": "日志"
"label": "日志",
"filterByChatbot": "按聊天机器人筛选",
"none": "",
"selectChatbotPlaceholder": "选择聊天机器人",
"apiGeneratedConversations": "API生成/聊天机器人对话"
},
"tools": {
"label": "工具"
Expand Down
20 changes: 10 additions & 10 deletions frontend/src/settings/Documents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ const Documents: React.FC<DocumentsProps> = ({
const [totalPages, setTotalPages] = useState<number>(1);
const currentDocuments = paginatedDocuments ?? [];
const syncOptions = [
{ label: 'Never', value: 'never' },
{ label: 'Daily', value: 'daily' },
{ label: 'Weekly', value: 'weekly' },
{ label: 'Monthly', value: 'monthly' },
{ label: t('settings.documents.syncFrequency.never'), value: 'never' },
{ label: t('settings.documents.syncFrequency.daily'), value: 'daily' },
{ label: t('settings.documents.syncFrequency.weekly'), value: 'weekly' },
{ label: t('settings.documents.syncFrequency.monthly'), value: 'monthly' },
];

const refreshDocs = useCallback(
Expand Down Expand Up @@ -153,7 +153,7 @@ const Documents: React.FC<DocumentsProps> = ({
<div className="p-1">
<Input
maxLength={256}
placeholder="Search..."
placeholder={t('settings.documents.searchPlaceholder')}
name="Document-search-input"
type="text"
id="document-search-input"
Expand All @@ -169,19 +169,19 @@ const Documents: React.FC<DocumentsProps> = ({
</div>
<button
className="rounded-full w-40 bg-purple-30 px-4 py-3 text-white hover:bg-[#6F3FD1]"
title="Add New Document"
title={t('settings.documents.addNewTitle')}
onClick={() => {
setIsOnboarding(false); // Set onboarding flag if needed
setModalState('ACTIVE'); // Open the upload modal
}}
>
Add New
{t('settings.documents.addNew')}
</button>
</div>
{loading ? (
<SkeletonLoader count={1} />
) : (
<div className="flex flex-col">
<div className="flex flex-col">
<div className="flex-grow">
<div className="dark:border-silver/40 border-silver rounded-md border overflow-auto">
<table className="min-w-full divide-y divide-silver dark:divide-silver/40 text-xs sm:text-sm ">
Expand Down Expand Up @@ -270,7 +270,7 @@ const Documents: React.FC<DocumentsProps> = ({
{document.type !== 'remote' && (
<img
src={Trash}
alt="Delete"
alt={t('convTile.delete')}
className="h-4 w-4 cursor-pointer opacity-60 hover:opacity-100"
id={`img-${index}`}
onClick={(event) => {
Expand All @@ -282,7 +282,7 @@ const Documents: React.FC<DocumentsProps> = ({
{document.syncFrequency && (
<div className="ml-2">
<DropdownMenu
name="Sync"
name={t('settings.documents.sync')}
options={syncOptions}
onSelect={(value: string) => {
handleManageSync(document, value);
Expand Down
32 changes: 7 additions & 25 deletions frontend/src/settings/General.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,15 @@ export default function General() {
t,
i18n: { changeLanguage, language },
} = useTranslation();
const themes = ['Light', 'Dark'];
const themes = [t('settings.general.light'), t('settings.general.dark')];

const languageOptions = [
{
label: 'English',
value: 'en',
},
{
label: 'Spanish',
value: 'es',
},
{
label: 'Japanese',
value: 'jp',
},
{
label: 'Mandarin',
value: 'zh',
},
{
label: 'Traditional Chinese',
value: 'zhTW',
},
{
label: 'Russian',
value: 'ru',
},
{ label: 'English', value: 'en' },
{ label: 'Español', value: 'es' },
{ label: '日本語', value: 'jp' },
{ label: '普通话', value: 'zh' },
{ label: '繁體中文(臺灣)', value: 'zhTW' },
{ label: 'Русский', value: 'ru' },
];
const chunks = ['0', '2', '4', '6', '8', '10'];
const token_limits = new Map([
Expand Down
12 changes: 8 additions & 4 deletions frontend/src/settings/Logs.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState, useEffect, useRef, useCallback } from 'react';
import { useTranslation } from 'react-i18next';

import userService from '../api/services/userService';
import ChevronRight from '../assets/chevron-right.svg';
Expand All @@ -8,6 +9,7 @@ import { APIKeyData, LogData } from './types';
import CoppyButton from '../components/CopyButton';

export default function Logs() {
const { t } = useTranslation();
const [chatbots, setChatbots] = useState<APIKeyData[]>([]);
const [selectedChatbot, setSelectedChatbot] = useState<APIKeyData | null>();
const [logs, setLogs] = useState<LogData[]>([]);
Expand Down Expand Up @@ -66,7 +68,7 @@ export default function Logs() {
<div className="flex flex-col items-start">
<div className="flex flex-col gap-3">
<p className="font-bold text-jet dark:text-bright-gray">
Filter by chatbot
{t('settings.logs.filterByChatbot')}
</p>
{loadingChatbots ? (
<SkeletonLoader />
Expand All @@ -78,9 +80,9 @@ export default function Logs() {
label: chatbot.name,
value: chatbot.id,
})),
{ label: 'None', value: '' },
{ label: t('settings.logs.none'), value: '' },
]}
placeholder="Select chatbot"
placeholder={t('settings.logs.selectChatbotPlaceholder')}
onSelect={(chatbot: { label: string; value: string }) => {
setSelectedChatbot(
chatbots.find((item) => item.id === chatbot.value),
Expand Down Expand Up @@ -120,6 +122,7 @@ type LogsTableProps = {
};

function LogsTable({ logs, setPage }: LogsTableProps) {
const { t } = useTranslation();
const observerRef = useRef<any>();
const firstObserver = useCallback((node: HTMLDivElement) => {
if (observerRef.current) {
Expand All @@ -134,7 +137,7 @@ function LogsTable({ logs, setPage }: LogsTableProps) {
<div className="logs-table border rounded-2xl h-[55vh] w-full overflow-hidden border-silver dark:border-silver/40">
<div className="h-8 bg-black/10 dark:bg-chinese-black flex flex-col items-start justify-center">
<p className="px-3 text-xs dark:text-gray-6000">
API generated / chatbot conversations
{t('settings.logs.apiGeneratedConversations')}
</p>
</div>
<div
Expand All @@ -156,6 +159,7 @@ function LogsTable({ logs, setPage }: LogsTableProps) {
}

function Log({ log }: { log: LogData }) {
const { t } = useTranslation();
const logLevelColor = {
info: 'text-green-500',
error: 'text-red-500',
Expand Down

0 comments on commit fa10812

Please sign in to comment.