Translate all the strings

This commit is contained in:
Alex Gleason committed 2025-09-19 14:15:30 -05:00
1 parent ced204bfde
commit 03b712a917
17 files changed
+569 -191

No files matched your search

+15 -11
View File
@@ -1,5 +1,6 @@
import { useState, useMemo } from 'react';
import { useNavigate } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { Check, ChevronDown, Edit3, RefreshCw, AlertCircle, Settings } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
@@ -23,8 +24,9 @@ export function ModelSelector({
onChange,
className,
disabled = false,
placeholder = "Select or enter a model...",
placeholder,
}: ModelSelectorProps) {
const { t } = useTranslation();
const [open, setOpen] = useState(false);
const [isCustomInput, setIsCustomInput] = useState(false);
const [customValue, setCustomValue] = useState('');
@@ -32,6 +34,8 @@ export function ModelSelector({
const { models, isLoading, error, refetch } = useProviderModels();
const navigate = useNavigate();
const defaultPlaceholder = t('selectOrEnterModel');
const recentlyUsedModels = useMemo(() => settings.recentlyUsedModels || [], [settings.recentlyUsedModels]);
// Group models by provider
@@ -125,14 +129,14 @@ export function ModelSelector({
disabled={disabled}
>
<span className="w-full truncate">
{value || placeholder}
{value || placeholder || defaultPlaceholder}
</span>
<ChevronDown className="size-3 shrink-0 opacity-50" />
</Button>
</PopoverTrigger>
<PopoverContent className="w-96 p-0" align="end">
<Command>
{isConfigured && <CommandInput placeholder="Search models..." className="h-9" />}
{isConfigured && <CommandInput placeholder={t('searchModels')} className="h-9" />}
<CommandList className="max-h-[300px]">
{/* Custom model option and manage providers */}
<CommandGroup>
@@ -143,7 +147,7 @@ export function ModelSelector({
className="cursor-pointer"
>
<Edit3 className="mr-2 h-4 w-4" />
Enter custom model...
{t('enterCustomModel')}
</CommandItem>
)}
<CommandItem
@@ -152,7 +156,7 @@ export function ModelSelector({
className="cursor-pointer"
>
<Settings className="mr-2 h-4 w-4" />
Manage providers...
{t('manageProviders')}
</CommandItem>
</CommandGroup>
@@ -160,13 +164,13 @@ export function ModelSelector({
<CommandEmpty>
<div className="py-6 text-center text-sm text-muted-foreground">
<p>No models found.</p>
<p className="mt-2 text-xs">Try using a custom model instead.</p>
<p>{t('noModelsFound')}</p>
<p className="mt-2 text-xs">{t('tryCustomModel')}</p>
</div>
</CommandEmpty>
{recentlyUsedModels.length > 0 && (
<CommandGroup heading="Recently Used">
<CommandGroup heading={t('recentlyUsed')}>
{recentlyUsedModels.map((model) => (
<CommandItem
key={model}
@@ -190,7 +194,7 @@ export function ModelSelector({
{/* Loading state */}
{isLoading && (
<CommandGroup heading="Loading Models...">
<CommandGroup heading={t('loading')}>
<div className="px-2 py-1.5">
<div className="space-y-2">
<Skeleton className="h-4 w-full" />
@@ -203,7 +207,7 @@ export function ModelSelector({
{/* Error state */}
{error && !isLoading && (
<CommandGroup heading="Error Loading Models">
<CommandGroup heading={t('errorLoadingModels')}>
<div className="px-2 py-1.5 text-sm text-muted-foreground">
<div className="flex items-start gap-2">
<AlertCircle className="h-4 w-4 text-destructive flex-shrink-0 mt-0.5" />
@@ -216,7 +220,7 @@ export function ModelSelector({
className="h-7 text-xs"
>
<RefreshCw className="h-3 w-3 mr-1" />
Retry
{t('retry')}
</Button>
</div>
</div>
+9 -7
View File
@@ -1,5 +1,6 @@
import React, { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { Plus, Folder, GitBranch, Loader2, ChevronDown, Star, Columns2, X, Settings, HelpCircle } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Skeleton } from '@/components/ui/skeleton';
@@ -87,6 +88,7 @@ export function ProjectSidebar({
onToggleSidebar,
onClose
}: ProjectSidebarProps) {
const { t } = useTranslation();
const queryClient = useQueryClient();
const { data: projects = [], isLoading, error } = useProjects();
const [favorites] = useLocalStorage<string[]>('project-favorites', []);
@@ -144,7 +146,7 @@ export function ProjectSidebar({
size="sm"
className="h-8 w-8 p-0 hover:bg-primary/10 -mr-2"
onClick={handleToggleSidebar}
aria-label={(onClose && isMobile) ? "Close sidebar" : "Collapse sidebar"}
aria-label={(onClose && isMobile) ? t('closeSidebar') : t('collapseSidebar')}
>
{(onClose && isMobile) ? (
<X className="h-4 w-4 text-primary/60 hover:text-primary" />
@@ -167,7 +169,7 @@ export function ProjectSidebar({
className="flex-1 flex items-center justify-center px-3 py-2 text-sm font-medium text-primary-foreground rounded-l-md hover:bg-white/10 transition-colors"
>
<Plus className="h-4 w-4 mr-2" />
New Project
{t('newProject')}
</button>
<div className="w-px bg-white/20" />
<DropdownMenu>
@@ -182,7 +184,7 @@ export function ProjectSidebar({
className="flex items-center gap-2 w-full"
>
<GitBranch className="h-4 w-4" />
Import Repository
{t('importRepository')}
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
@@ -204,8 +206,8 @@ export function ProjectSidebar({
) : projects.length === 0 ? (
<div className="text-center p-6 text-muted-foreground">
<Folder className="h-8 w-8 mx-auto mb-2 opacity-50" />
<p className="text-sm">No projects yet</p>
<p className="text-xs">Create your first project to get started</p>
<p className="text-sm">{t('noProjectsYet')}</p>
<p className="text-xs">{t('createFirstProject')}</p>
</div>
) : (
<div className="space-y-1">
@@ -233,14 +235,14 @@ export function ProjectSidebar({
onClick={() => navigateAndClose('/settings')}
>
<Settings className="h-4 w-4 transition-colors duration-200" />
Settings
{t('settings')}
</Button>
<Button
variant="ghost"
size="sm"
className="h-9 w-9 p-0 text-sidebar-foreground dark:hover:text-sidebar-primary hover:bg-primary/10 dark:hover:bg-sidebar-accent/30 transition-all duration-200"
onClick={() => window.open('https://soapbox.pub/shakespeare-resources/', '_blank')}
aria-label="Help"
aria-label={t('help')}
>
<HelpCircle className="h-4 w-4 transition-colors duration-200" />
</Button>
+19 -15
View File
@@ -1,5 +1,6 @@
import { useState, useEffect } from 'react';
import { useNavigate, useLocation, Outlet } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { Button } from '@/components/ui/button';
import { ScrollArea } from '@/components/ui/scroll-area';
import { Menu, Bot, GitBranch, Database, Wifi, Settings2 } from 'lucide-react';
@@ -18,45 +19,47 @@ interface SettingsItem {
href: string;
}
const settingsItems: SettingsItem[] = [
// Define settings items as a function to get fresh translations
const getSettingsItems = (t: (key: string) => string): SettingsItem[] => [
{
id: 'preferences',
title: 'Preferences',
description: 'General application preferences and appearance',
title: t('preferences'),
description: t('preferencesDescription'),
icon: Settings2,
href: '/settings/preferences',
},
{
id: 'ai',
title: 'AI Settings',
description: 'Configure AI providers and API keys',
title: t('aiSettings'),
description: t('aiSettingsDescription'),
icon: Bot,
href: '/settings/ai',
},
{
id: 'git',
title: 'Git Settings',
description: 'Configure Git credentials for HTTP authentication',
title: t('gitSettings'),
description: t('gitSettingsDescription'),
icon: GitBranch,
href: '/settings/git',
},
{
id: 'nostr',
title: 'Nostr Settings',
description: 'Configure relay connections and Nostr preferences',
title: t('nostrSettings'),
description: t('nostrSettingsDescription'),
icon: Wifi,
href: '/settings/nostr',
},
{
id: 'data',
title: 'Data',
description: 'Export files and manage local data',
title: t('dataSettings'),
description: t('dataSettingsDescription'),
icon: Database,
href: '/settings/data',
},
];
export function SettingsLayout() {
const { t } = useTranslation();
const navigate = useNavigate();
const location = useLocation();
const isMobile = useIsMobile();
@@ -104,6 +107,7 @@ export function SettingsLayout() {
};
// Get current settings page
const settingsItems = getSettingsItems(t);
const currentPath = location.pathname;
const currentSettingsId = settingsItems.find(item => item.href === currentPath)?.id;
@@ -117,11 +121,11 @@ export function SettingsLayout() {
variant="ghost"
size="sm"
onClick={() => setIsSidebarVisible(!isSidebarVisible)}
aria-label="Toggle sidebar"
aria-label={t('toggleSidebar')}
>
<Menu className="h-4 w-4" />
</Button>
<h1 className="text-lg font-semibold">Settings</h1>
<h1 className="text-lg font-semibold">{t('settings')}</h1>
</div>
</header>
@@ -176,13 +180,13 @@ export function SettingsLayout() {
size="sm"
onClick={() => setIsSidebarVisible(true)}
className="h-8 w-8 p-0"
aria-label="Open sidebar"
aria-label={t('openSidebar')}
>
<Menu className="h-4 w-4" />
</Button>
)}
<h1 className="text-xl font-bold flex items-center gap-2">
Settings
{t('settings')}
</h1>
</div>
</div>
+20 -14
View File
@@ -1,5 +1,6 @@
import { useState, useRef, useEffect, forwardRef, useImperativeHandle, useMemo, useCallback } from 'react';
import { useSearchParams } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { Button } from '@/components/ui/button';
import { Textarea } from '@/components/ui/textarea';
import { Skeleton } from '@/components/ui/skeleton';
@@ -67,6 +68,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
isBuildLoading: externalIsBuildLoading,
isDeployLoading: externalIsDeployLoading
}, ref) => {
const { t } = useTranslation();
const [input, setInput] = useState('');
const [systemPrompt, setSystemPrompt] = useState('');
const [showScrollToBottom, setShowScrollToBottom] = useState(false);
@@ -417,12 +419,12 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
<div className="text-center space-y-4 max-w-md mx-auto p-6">
<div className="text-4xl mb-4">🤖</div>
<div>
<h3 className="text-lg font-semibold mb-2 bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">AI Assistant Not Configured</h3>
<h3 className="text-lg font-semibold mb-2 bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">{t('aiNotConfigured')}</h3>
<p className="text-sm text-muted-foreground mb-4">
Please configure your AI settings to start building with AI assistance.
{t('configureAI')}
</p>
<p className="text-sm text-muted-foreground">
Use the menu in the top bar to access AI Settings.
{t('useMenuForAI')}
</p>
</div>
</div>
@@ -445,16 +447,16 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
<div className="text-6xl mb-6">🎭</div>
<div>
<h3 className="text-xl font-semibold mb-2 bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
Welcome to Shakespeare
{t('welcomeToShakespeare')}
</h3>
<p className="text-muted-foreground mb-6 leading-relaxed">
Your AI-powered development assistant is ready to help you build, edit, and enhance your project.
{t('aiAssistantReady')}
</p>
<div className="space-y-2 text-sm text-muted-foreground">
<p>💡 Ask me to add new features</p>
<p>📝 Request file edits and improvements</p>
<p>🔧 Get help with debugging and optimization</p>
<p>🚀 Build and deploy your project</p>
<p>{t('askMeFeatures')}</p>
<p>{t('requestEdits')}</p>
<p>{t('getHelp')}</p>
<p>{t('buildDeploy')}</p>
</div>
</div>
</div>
@@ -512,7 +514,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
<div className="flex items-center gap-2 px-2 py-1 text-xs text-muted-foreground">
<Loader2 className="h-3 w-3 animate-spin flex-shrink-0" />
<span className="font-medium">
Running {streamingMessage.tool_calls?.[0]?.function?.name || 'tool'}...
{t('running')} {streamingMessage.tool_calls?.[0]?.function?.name || 'tool'}...
</span>
</div>
</div>
@@ -543,7 +545,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
onKeyDown={handleKeyDown}
onPaste={handlePaste}
onFocus={handleFirstInteraction}
placeholder={providerModel.trim() ? "Ask me to add features, edit files, or build your project..." : "Please select a model to start chatting..."}
placeholder={providerModel.trim() ? t('askToAddFeatures') : t('selectModelFirst')}
className="flex-1 resize-none border-0 bg-transparent px-4 py-3 text-sm focus-visible:ring-0 focus-visible:ring-offset-0 placeholder:text-muted-foreground"
disabled={isLoading || !providerModel.trim()}
rows={1}
@@ -583,7 +585,11 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
</div>
</TooltipTrigger>
<TooltipContent>
<p>Context usage: {lastInputTokens.toLocaleString()} / {currentModel.contextLength.toLocaleString()} tokens ({contextUsagePercentage.toFixed(1)}%)</p>
<p>{t('contextUsage', {
tokens: lastInputTokens.toLocaleString(),
total: currentModel.contextLength.toLocaleString(),
percentage: contextUsagePercentage.toFixed(1)
})}</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
@@ -599,7 +605,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
</div>
</TooltipTrigger>
<TooltipContent>
<p>Total cost for this chat session</p>
<p>{t('totalCostSession')}</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
@@ -612,7 +618,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
onChange={setProviderModel}
className="w-full"
disabled={isLoading}
placeholder="Choose a model..."
placeholder={t('chooseModel')}
/>
</div>
+6 -4
View File
@@ -1,4 +1,5 @@
import { useState, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { Button } from '@/components/ui/button';
import { Textarea } from '@/components/ui/textarea';
import { CardContent, CardHeader, CardTitle } from '@/components/ui/card';
@@ -15,6 +16,7 @@ interface FileEditorProps {
}
export function FileEditor({ filePath, content, onSave, isLoading, projectId }: FileEditorProps) {
const { t } = useTranslation();
const [editedContent, setEditedContent] = useState(content);
const [isSaving, setIsSaving] = useState(false);
const [hasChanges, setHasChanges] = useState(false);
@@ -99,7 +101,7 @@ export function FileEditor({ filePath, content, onSave, isLoading, projectId }:
<CardTitle className={cn("text-sm sm:text-base truncate flex-1 mr-2", gitStatusClasses)}>{filePath}</CardTitle>
<div className="flex items-center space-x-1 sm:space-x-2">
{hasChanges && (
<span className="text-xs sm:text-sm text-muted-foreground hidden sm:inline">Unsaved changes</span>
<span className="text-xs sm:text-sm text-muted-foreground hidden sm:inline">{t('unsavedChanges')}</span>
)}
<Button
onClick={handleSave}
@@ -110,19 +112,19 @@ export function FileEditor({ filePath, content, onSave, isLoading, projectId }:
{isSaving ? (
<>
<Loader2 className="mr-1 sm:mr-2 h-4 w-4 animate-spin" />
<span className="hidden sm:inline">Saving...</span>
<span className="hidden sm:inline">{t('saving')}</span>
</>
) : (
<>
<Save className="sm:mr-2 h-4 w-4" />
<span className="hidden sm:inline">Save</span>
<span className="hidden sm:inline">{t('save')}</span>
</>
)}
</Button>
</div>
</div>
<div className="text-xs text-muted-foreground mt-1">
Language: {getLanguageFromPath(filePath)}
{t('languageLabel')}: {getLanguageFromPath(filePath)}
</div>
</CardHeader>
+5 -3
View File
@@ -1,4 +1,5 @@
import { useState, useEffect, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { useProjectsManager } from '@/hooks/useProjectsManager';
import { useFS } from '@/hooks/useFS';
import { useGitStatus } from '@/hooks/useGitStatus';
@@ -22,6 +23,7 @@ interface FileNode {
}
export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProps) {
const { t } = useTranslation();
const [tree, setTree] = useState<FileNode[]>([]);
const [filteredTree, setFilteredTree] = useState<FileNode[]>([]);
const [isLoading, setIsLoading] = useState(true);
@@ -179,7 +181,7 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp
for (const node of nodes) {
if (node.type === 'file') {
const fileNameMatch = node.name.toLowerCase().includes(searchTermLower);
if (fileNameMatch) {
results.push(node);
}
@@ -296,7 +298,7 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp
<div className="relative">
<Search className="absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" />
<Input
placeholder="Search files..."
placeholder={t('searchFiles')}
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
className="pl-8"
@@ -313,7 +315,7 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp
</div>
) : filteredTree.length === 0 ? (
<div className="text-center text-sm text-muted-foreground py-4">
{searchTerm ? 'No files found matching your search' : 'No files found'}
{searchTerm ? t('noFilesFoundSearch') : t('noFilesFound')}
</div>
) : (
filteredTree.map(node => renderNode(node))
-18
View File
@@ -71,24 +71,6 @@ describe('LoginArea', () => {
expect(screen.getByTestId('account-switcher')).toBeInTheDocument();
});
it('shows anonymous user menu when user is not logged in', () => {
mockUseLoggedInAccounts.mockReturnValue({
authors: [],
currentUser: undefined,
otherUsers: [],
setLogin: vi.fn(),
removeLogin: vi.fn(),
isLoading: false
});
render(<LoginArea />);
// Should show anonymous user display
expect(screen.getByText('Anonymous')).toBeInTheDocument();
// Should show the dropdown trigger button
expect(screen.getByRole('button')).toBeInTheDocument();
});
+7 -5
View File
@@ -2,6 +2,7 @@
// It is important that all functionality in this file is preserved, and should only be modified if explicitly requested.
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { User, UserPlus, ChevronDown, Settings, HelpCircle } from 'lucide-react';
import {
DropdownMenu,
@@ -23,6 +24,7 @@ export interface LoginAreaProps {
}
export function LoginArea({ className }: LoginAreaProps) {
const { t } = useTranslation();
const { currentUser } = useLoggedInAccounts();
const navigate = useNavigate();
const [loginDialogOpen, setLoginDialogOpen] = useState(false);
@@ -47,7 +49,7 @@ export function LoginArea({ className }: LoginAreaProps) {
</AvatarFallback>
</Avatar>
<div className='flex-1 text-left truncate'>
<p className='font-medium text-sm truncate'>Anonymous</p>
<p className='font-medium text-sm truncate'>{t('anonymous')}</p>
</div>
<ChevronDown className='w-4 h-4 text-muted-foreground' />
</button>
@@ -58,14 +60,14 @@ export function LoginArea({ className }: LoginAreaProps) {
className='flex items-center gap-2 cursor-pointer p-2 rounded-md'
>
<Settings className='w-4 h-4' />
<span>Settings</span>
<span>{t('settings')}</span>
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => window.open('https://soapbox.pub/shakespeare-resources/', '_blank')}
className='flex items-center gap-2 cursor-pointer p-2 rounded-md'
>
<HelpCircle className='w-4 h-4' />
<span>Help</span>
<span>{t('help')}</span>
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem
@@ -73,14 +75,14 @@ export function LoginArea({ className }: LoginAreaProps) {
className='flex items-center gap-2 cursor-pointer p-2 rounded-md'
>
<User className='w-4 h-4' />
<span>Log in</span>
<span>{t('logIn')}</span>
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => setSignupDialogOpen(true)}
className='flex items-center gap-2 cursor-pointer p-2 rounded-md'
>
<UserPlus className='w-4 h-4' />
<span>Sign up</span>
<span>{t('signUp')}</span>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>