mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Add translations support
This commit is contained in:
15 files changed
+444
-31
No files matched your search
Generated
+80
-3
@@ -54,6 +54,7 @@
|
||||
"decimal.js": "^10.6.0",
|
||||
"embla-carousel-react": "^8.3.0",
|
||||
"esbuild-wasm": "^0.25.8",
|
||||
"i18next": "^25.5.2",
|
||||
"ignore": "^7.0.5",
|
||||
"input-otp": "^1.2.4",
|
||||
"isomorphic-git": "^1.32.1",
|
||||
@@ -67,6 +68,7 @@
|
||||
"react-day-picker": "^8.10.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-hook-form": "^7.53.0",
|
||||
"react-i18next": "^15.7.3",
|
||||
"react-markdown": "^10.1.0",
|
||||
"react-resizable-panels": "^3.0.3",
|
||||
"react-router-dom": "^6.26.2",
|
||||
@@ -209,9 +211,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/runtime": {
|
||||
"version": "7.27.1",
|
||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.27.1.tgz",
|
||||
"integrity": "sha512-1x3D2xEk2fRo3PAhwQwu5UubzgiVWSXTBfWpVd2Mx2AzRqJuDJCsgaDVZ7HB5iGzDW1Hl1sWN2mFyKjmR9uAog==",
|
||||
"version": "7.28.4",
|
||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.4.tgz",
|
||||
"integrity": "sha512-Q/N6JNWvIvPnLDvjlE1OUBLPQHH6l3CltCEsHIujp45zQUSSh8K+gHnaEX45yAT1nyngnINhvWtzN+Nb9D8RAQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
@@ -6331,6 +6333,15 @@
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/html-parse-stringify": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/html-parse-stringify/-/html-parse-stringify-3.0.1.tgz",
|
||||
"integrity": "sha512-KknJ50kTInJ7qIScF3jeaFRpMpE8/lfiTdzf/twXyPBLAGrLRTmkz3AdTnKeh40X8k9L2fdYwEp/42WGXIRGcg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"void-elements": "3.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/html-url-attributes": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/html-url-attributes/-/html-url-attributes-3.0.1.tgz",
|
||||
@@ -6379,6 +6390,37 @@
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/i18next": {
|
||||
"version": "25.5.2",
|
||||
"resolved": "https://registry.npmjs.org/i18next/-/i18next-25.5.2.tgz",
|
||||
"integrity": "sha512-lW8Zeh37i/o0zVr+NoCHfNnfvVw+M6FQbRp36ZZ/NyHDJ3NJVpp2HhAUyU9WafL5AssymNoOjMRB48mmx2P6Hw==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://locize.com"
|
||||
},
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://locize.com/i18next.html"
|
||||
},
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://www.i18next.com/how-to/faq#i18next-is-awesome.-how-can-i-support-the-project"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.27.6"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/iconv-lite": {
|
||||
"version": "0.6.3",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
|
||||
@@ -8888,6 +8930,32 @@
|
||||
"react": "^16.8.0 || ^17 || ^18 || ^19"
|
||||
}
|
||||
},
|
||||
"node_modules/react-i18next": {
|
||||
"version": "15.7.3",
|
||||
"resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-15.7.3.tgz",
|
||||
"integrity": "sha512-AANws4tOE+QSq/IeMF/ncoHlMNZaVLxpa5uUGW1wjike68elVYr0018L9xYoqBr1OFO7G7boDPrbn0HpMCJxTw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.27.6",
|
||||
"html-parse-stringify": "^3.0.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"i18next": ">= 25.4.1",
|
||||
"react": ">= 16.8.0",
|
||||
"typescript": "^5"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"react-dom": {
|
||||
"optional": true
|
||||
},
|
||||
"react-native": {
|
||||
"optional": true
|
||||
},
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/react-is": {
|
||||
"version": "18.3.1",
|
||||
"resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz",
|
||||
@@ -10848,6 +10916,15 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/void-elements": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/void-elements/-/void-elements-3.1.0.tgz",
|
||||
"integrity": "sha512-Dhxzh5HZuiHQhbvTW9AMetFfBHDMYpo23Uo9btPXgdYP+3T5S+p+jgNy7spra+veYhBP2dCSgxR/i2Y02h5/6w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/w3c-xmlserializer": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz",
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
"decimal.js": "^10.6.0",
|
||||
"embla-carousel-react": "^8.3.0",
|
||||
"esbuild-wasm": "^0.25.8",
|
||||
"i18next": "^25.5.2",
|
||||
"ignore": "^7.0.5",
|
||||
"input-otp": "^1.2.4",
|
||||
"isomorphic-git": "^1.32.1",
|
||||
@@ -69,6 +70,7 @@
|
||||
"react-day-picker": "^8.10.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-hook-form": "^7.53.0",
|
||||
"react-i18next": "^15.7.3",
|
||||
"react-markdown": "^10.1.0",
|
||||
"react-resizable-panels": "^3.0.3",
|
||||
"react-router-dom": "^6.26.2",
|
||||
|
||||
@@ -41,6 +41,7 @@ const defaultConfig: AppConfig = {
|
||||
theme: "light",
|
||||
relayUrl: "wss://relay.primal.net",
|
||||
deployServer: "shakespeare.wtf",
|
||||
language: "en",
|
||||
};
|
||||
|
||||
const presetRelays = [
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { ReactNode, useEffect } from 'react';
|
||||
import { z } from 'zod';
|
||||
import { useLocalStorage } from '@/hooks/useLocalStorage';
|
||||
import { AppContext, type AppConfig, type AppContextType, type Theme } from '@/contexts/AppContext';
|
||||
import { AppContext, type AppConfig, type AppContextType, type Theme, type Language } from '@/contexts/AppContext';
|
||||
import i18n from '@/lib/i18n';
|
||||
|
||||
interface AppProviderProps {
|
||||
children: ReactNode;
|
||||
@@ -18,6 +19,7 @@ const AppConfigSchema: z.ZodType<AppConfig, z.ZodTypeDef, unknown> = z.object({
|
||||
theme: z.enum(['dark', 'light', 'system']),
|
||||
relayUrl: z.string().url(),
|
||||
deployServer: z.string().min(1),
|
||||
language: z.enum(['en', 'pt']),
|
||||
});
|
||||
|
||||
export function AppProvider(props: AppProviderProps) {
|
||||
@@ -55,6 +57,9 @@ export function AppProvider(props: AppProviderProps) {
|
||||
// Apply theme effects to document
|
||||
useApplyTheme(config.theme);
|
||||
|
||||
// Apply language effects to i18n
|
||||
useApplyLanguage(config.language);
|
||||
|
||||
return (
|
||||
<AppContext.Provider value={appContextValue}>
|
||||
{children}
|
||||
@@ -101,4 +106,13 @@ function useApplyTheme(theme: Theme) {
|
||||
mediaQuery.addEventListener('change', handleChange);
|
||||
return () => mediaQuery.removeEventListener('change', handleChange);
|
||||
}, [theme]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook to apply language changes to i18n
|
||||
*/
|
||||
function useApplyLanguage(language: Language) {
|
||||
useEffect(() => {
|
||||
i18n.changeLanguage(language);
|
||||
}, [language]);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { render, screen, fireEvent } from '@testing-library/react';
|
||||
import { TestApp } from '@/test/TestApp';
|
||||
import { LanguagePicker } from './LanguagePicker';
|
||||
|
||||
describe('LanguagePicker', () => {
|
||||
it('renders language picker with default English selection', () => {
|
||||
render(
|
||||
<TestApp>
|
||||
<LanguagePicker />
|
||||
</TestApp>
|
||||
);
|
||||
|
||||
// Should show the trigger button
|
||||
expect(screen.getByRole('combobox')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows language options when opened', async () => {
|
||||
render(
|
||||
<TestApp>
|
||||
<LanguagePicker />
|
||||
</TestApp>
|
||||
);
|
||||
|
||||
// Click to open the dropdown
|
||||
const trigger = screen.getByRole('combobox');
|
||||
fireEvent.click(trigger);
|
||||
|
||||
// Should show both language options (using getAllByText since there might be duplicates)
|
||||
expect(screen.getAllByText('English').length).toBeGreaterThan(0);
|
||||
expect(screen.getAllByText('Portuguese').length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('displays flag emojis for languages', async () => {
|
||||
render(
|
||||
<TestApp>
|
||||
<LanguagePicker />
|
||||
</TestApp>
|
||||
);
|
||||
|
||||
// Click to open the dropdown
|
||||
const trigger = screen.getByRole('combobox');
|
||||
fireEvent.click(trigger);
|
||||
|
||||
// Should show flag emojis (using getAllByText since there might be duplicates)
|
||||
expect(screen.getAllByText('🇺🇸').length).toBeGreaterThan(0);
|
||||
expect(screen.getAllByText('🇧🇷').length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,41 @@
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||
import { useAppContext } from '@/hooks/useAppContext';
|
||||
import type { Language } from '@/contexts/AppContext';
|
||||
|
||||
interface LanguagePickerProps {
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function LanguagePicker({ className }: LanguagePickerProps) {
|
||||
const { t } = useTranslation();
|
||||
const { config, updateConfig } = useAppContext();
|
||||
|
||||
const handleLanguageChange = (language: Language) => {
|
||||
updateConfig((prev) => ({ ...prev, language }));
|
||||
};
|
||||
|
||||
return (
|
||||
<Select value={config.language} onValueChange={handleLanguageChange}>
|
||||
<SelectTrigger className={className}>
|
||||
<div className="flex items-center gap-2">
|
||||
<SelectValue />
|
||||
</div>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="en">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-lg">🇺🇸</span>
|
||||
{t('english')}
|
||||
</div>
|
||||
</SelectItem>
|
||||
<SelectItem value="pt">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-lg">🇧🇷</span>
|
||||
{t('portuguese')}
|
||||
</div>
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ChevronsUpDown, Monitor, Moon, Sun } from "lucide-react";
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
@@ -10,12 +11,13 @@ import { useTheme } from "@/hooks/useTheme";
|
||||
import { type Theme } from "@/contexts/AppContext";
|
||||
|
||||
export function ThemePicker() {
|
||||
const { t } = useTranslation();
|
||||
const { theme, setTheme } = useTheme();
|
||||
|
||||
const themeOptions: { value: Theme; label: string; icon: React.ComponentType<{ className?: string }> }[] = [
|
||||
{ value: "system", label: "System", icon: Monitor },
|
||||
{ value: "light", label: "Light", icon: Sun },
|
||||
{ value: "dark", label: "Dark", icon: Moon },
|
||||
{ value: "system", label: t('system'), icon: Monitor },
|
||||
{ value: "light", label: t('light'), icon: Sun },
|
||||
{ value: "dark", label: t('dark'), icon: Moon },
|
||||
];
|
||||
|
||||
const currentTheme = themeOptions.find(option => option.value === theme);
|
||||
@@ -27,7 +29,7 @@ export function ThemePicker() {
|
||||
<Button variant="outline" className="w-full justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<CurrentIcon className="h-4 w-4" />
|
||||
<span>{currentTheme?.label || "System"}</span>
|
||||
<span>{currentTheme?.label || t('system')}</span>
|
||||
</div>
|
||||
<ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
||||
</Button>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { createContext } from "react";
|
||||
|
||||
export type Theme = "dark" | "light" | "system";
|
||||
export type Language = "en" | "pt";
|
||||
|
||||
export interface AppConfig {
|
||||
/** Current theme */
|
||||
@@ -9,6 +10,8 @@ export interface AppConfig {
|
||||
relayUrl: string;
|
||||
/** Deploy server domain (e.g., "shakespeare.wtf") */
|
||||
deployServer: string;
|
||||
/** Selected language */
|
||||
language: Language;
|
||||
}
|
||||
|
||||
export interface AppContextType {
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
// Re-export useTranslation from react-i18next for consistency
|
||||
export { useTranslation } from 'react-i18next';
|
||||
+159
@@ -0,0 +1,159 @@
|
||||
import i18n from 'i18next';
|
||||
import { initReactI18next } from 'react-i18next';
|
||||
|
||||
// Translation resources
|
||||
const resources = {
|
||||
en: {
|
||||
translation: {
|
||||
// Navigation and Layout
|
||||
preferences: 'Preferences',
|
||||
settings: 'Settings',
|
||||
backToSettings: 'Back to Settings',
|
||||
|
||||
// Preferences Page
|
||||
preferencesTitle: 'Preferences',
|
||||
preferencesDescription: 'Manage your general application preferences and appearance settings.',
|
||||
|
||||
// Appearance Section
|
||||
appearance: 'Appearance',
|
||||
appearanceDescription: 'Customize how the application looks and feels.',
|
||||
theme: 'Theme',
|
||||
themeDescription: 'Choose between light, dark, or system theme preference.',
|
||||
|
||||
// Language Section
|
||||
language: 'Language',
|
||||
languageDescription: 'Select your preferred language for the interface.',
|
||||
|
||||
// Language Options
|
||||
english: 'English',
|
||||
portuguese: 'Portuguese',
|
||||
|
||||
// Theme Options
|
||||
light: 'Light',
|
||||
dark: 'Dark',
|
||||
system: 'System',
|
||||
|
||||
// Common UI Elements
|
||||
save: 'Save',
|
||||
cancel: 'Cancel',
|
||||
close: 'Close',
|
||||
open: 'Open',
|
||||
edit: 'Edit',
|
||||
delete: 'Delete',
|
||||
create: 'Create',
|
||||
update: 'Update',
|
||||
loading: 'Loading...',
|
||||
error: 'Error',
|
||||
success: 'Success',
|
||||
warning: 'Warning',
|
||||
info: 'Information',
|
||||
|
||||
// Shakespeare Main Page
|
||||
buildNostrApps: 'Build Nostr apps with AI',
|
||||
whatToBuild: 'What would you like to build?',
|
||||
createProject: 'Create Project',
|
||||
generating: 'Generating...',
|
||||
creating: 'Creating...',
|
||||
chooseModel: 'Choose a model...',
|
||||
selectModelFirst: "Please select a model below, then describe what you'd like to build...",
|
||||
examplePrompt: "e.g., Create a farming equipment marketplace for local farmers to buy and sell tractors, tools, and supplies...",
|
||||
|
||||
// Settings Page
|
||||
settingsTitle: 'Settings',
|
||||
settingsDescription: 'Manage your application settings and preferences.',
|
||||
aiSettings: 'AI Settings',
|
||||
aiSettingsDescription: 'Configure AI providers and API keys',
|
||||
gitSettings: 'Git Settings',
|
||||
gitSettingsDescription: 'Configure Git credentials for HTTP authentication',
|
||||
nostrSettings: 'Nostr Settings',
|
||||
nostrSettingsDescription: 'Configure relay connections and Nostr preferences',
|
||||
dataSettings: 'Data',
|
||||
dataSettingsDescription: 'Export files and manage local data',
|
||||
}
|
||||
},
|
||||
pt: {
|
||||
translation: {
|
||||
// Navigation and Layout
|
||||
preferences: 'Preferências',
|
||||
settings: 'Configurações',
|
||||
backToSettings: 'Voltar às Configurações',
|
||||
|
||||
// Preferences Page
|
||||
preferencesTitle: 'Preferências',
|
||||
preferencesDescription: 'Gerencie suas preferências gerais da aplicação e configurações de aparência.',
|
||||
|
||||
// Appearance Section
|
||||
appearance: 'Aparência',
|
||||
appearanceDescription: 'Personalize como a aplicação se parece e funciona.',
|
||||
theme: 'Tema',
|
||||
themeDescription: 'Escolha entre preferência de tema claro, escuro ou do sistema.',
|
||||
|
||||
// Language Section
|
||||
language: 'Idioma',
|
||||
languageDescription: 'Selecione seu idioma preferido para a interface.',
|
||||
|
||||
// Language Options
|
||||
english: 'Inglês',
|
||||
portuguese: 'Português',
|
||||
|
||||
// Theme Options
|
||||
light: 'Claro',
|
||||
dark: 'Escuro',
|
||||
system: 'Sistema',
|
||||
|
||||
// Common UI Elements
|
||||
save: 'Salvar',
|
||||
cancel: 'Cancelar',
|
||||
close: 'Fechar',
|
||||
open: 'Abrir',
|
||||
edit: 'Editar',
|
||||
delete: 'Excluir',
|
||||
create: 'Criar',
|
||||
update: 'Atualizar',
|
||||
loading: 'Carregando...',
|
||||
error: 'Erro',
|
||||
success: 'Sucesso',
|
||||
warning: 'Aviso',
|
||||
info: 'Informação',
|
||||
|
||||
// Shakespeare Main Page
|
||||
buildNostrApps: 'Construa aplicativos Nostr com IA',
|
||||
whatToBuild: 'O que você gostaria de construir?',
|
||||
createProject: 'Criar Projeto',
|
||||
generating: 'Gerando...',
|
||||
creating: 'Criando...',
|
||||
chooseModel: 'Escolha um modelo...',
|
||||
selectModelFirst: "Por favor, selecione um modelo abaixo e depois descreva o que gostaria de construir...",
|
||||
examplePrompt: "ex., Criar um marketplace de equipamentos agrícolas para fazendeiros locais comprarem e venderem tratores, ferramentas e suprimentos...",
|
||||
|
||||
// Settings Page
|
||||
settingsTitle: 'Configurações',
|
||||
settingsDescription: 'Gerencie as configurações e preferências da aplicação.',
|
||||
aiSettings: 'Configurações de IA',
|
||||
aiSettingsDescription: 'Configure provedores de IA e chaves de API',
|
||||
gitSettings: 'Configurações do Git',
|
||||
gitSettingsDescription: 'Configure credenciais do Git para autenticação HTTP',
|
||||
nostrSettings: 'Configurações do Nostr',
|
||||
nostrSettingsDescription: 'Configure conexões de relay e preferências do Nostr',
|
||||
dataSettings: 'Dados',
|
||||
dataSettingsDescription: 'Exporte arquivos e gerencie dados locais',
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Initialize i18next
|
||||
i18n
|
||||
.use(initReactI18next)
|
||||
.init({
|
||||
resources,
|
||||
lng: 'en', // Default language
|
||||
fallbackLng: 'en',
|
||||
interpolation: {
|
||||
escapeValue: false, // React already escapes values
|
||||
},
|
||||
react: {
|
||||
useSuspense: false, // Disable suspense for better compatibility
|
||||
}
|
||||
});
|
||||
|
||||
export default i18n;
|
||||
@@ -3,6 +3,9 @@ import { createRoot } from 'react-dom/client';
|
||||
// Import polyfills first
|
||||
import './lib/polyfills.ts';
|
||||
|
||||
// Import i18n configuration
|
||||
import './lib/i18n';
|
||||
|
||||
import App from './App.tsx';
|
||||
import './index.css';
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { TestApp } from '@/test/TestApp';
|
||||
import { Preferences } from './Preferences';
|
||||
|
||||
describe('Preferences', () => {
|
||||
it('renders preferences page with language and theme sections', () => {
|
||||
render(
|
||||
<TestApp>
|
||||
<Preferences />
|
||||
</TestApp>
|
||||
);
|
||||
|
||||
// Should show the preferences title
|
||||
expect(screen.getByText('Preferences')).toBeInTheDocument();
|
||||
|
||||
// Should show appearance section
|
||||
expect(screen.getByText('Appearance')).toBeInTheDocument();
|
||||
|
||||
// Should show theme and language labels
|
||||
expect(screen.getByText('Theme')).toBeInTheDocument();
|
||||
expect(screen.getByText('Language')).toBeInTheDocument();
|
||||
|
||||
// Should show language picker
|
||||
expect(screen.getByRole('combobox')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('displays translated content correctly', () => {
|
||||
render(
|
||||
<TestApp>
|
||||
<Preferences />
|
||||
</TestApp>
|
||||
);
|
||||
|
||||
// Check for key translated strings
|
||||
expect(screen.getByText('Manage your general application preferences and appearance settings.')).toBeInTheDocument();
|
||||
expect(screen.getByText('Customize how the application looks and feels.')).toBeInTheDocument();
|
||||
expect(screen.getByText('Select your preferred language for the interface.')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
+23
-10
@@ -1,12 +1,15 @@
|
||||
import { Settings2, ArrowLeft } from "lucide-react";
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { ThemePicker } from "@/components/ThemePicker";
|
||||
import { LanguagePicker } from "@/components/LanguagePicker";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { useIsMobile } from "@/hooks/useIsMobile";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
export function Preferences() {
|
||||
const { t } = useTranslation();
|
||||
const isMobile = useIsMobile();
|
||||
const navigate = useNavigate();
|
||||
|
||||
@@ -21,15 +24,15 @@ export function Preferences() {
|
||||
className="h-8 w-auto px-2 -ml-2"
|
||||
>
|
||||
<ArrowLeft className="h-4 w-4 mr-2" />
|
||||
Back to Settings
|
||||
{t('backToSettings')}
|
||||
</Button>
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-2xl font-bold flex items-center gap-3">
|
||||
<Settings2 className="h-6 w-6 text-primary" />
|
||||
Preferences
|
||||
{t('preferencesTitle')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
Manage your general application preferences and appearance settings.
|
||||
{t('preferencesDescription')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -39,29 +42,39 @@ export function Preferences() {
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-2xl font-bold flex items-center gap-3">
|
||||
<Settings2 className="h-6 w-6 text-primary" />
|
||||
Preferences
|
||||
{t('preferencesTitle')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
Manage your general application preferences and appearance settings.
|
||||
{t('preferencesDescription')}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Appearance</CardTitle>
|
||||
<CardTitle>{t('appearance')}</CardTitle>
|
||||
<CardDescription>
|
||||
Customize how the application looks and feels.
|
||||
{t('appearanceDescription')}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<CardContent className="space-y-6">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="theme-picker">Theme</Label>
|
||||
<Label htmlFor="theme-picker">{t('theme')}</Label>
|
||||
<div className="w-full max-w-xs">
|
||||
<ThemePicker />
|
||||
</div>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Choose between light, dark, or system theme preference.
|
||||
{t('themeDescription')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="language-picker">{t('language')}</Label>
|
||||
<div className="w-full max-w-xs">
|
||||
<LanguagePicker />
|
||||
</div>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{t('languageDescription')}
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
|
||||
+18
-13
@@ -1,4 +1,5 @@
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Bot, GitBranch, Database, Wifi, Settings2 } from 'lucide-react';
|
||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||
|
||||
@@ -10,55 +11,59 @@ 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 Settings() {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const isMobile = useIsMobile();
|
||||
|
||||
const settingsItems = getSettingsItems(t);
|
||||
|
||||
if (isMobile) {
|
||||
return (
|
||||
<div className="p-6 space-y-4">
|
||||
<div className="space-y-2">
|
||||
<h2 className="text-xl font-bold">Settings</h2>
|
||||
<h2 className="text-xl font-bold">{t('settingsTitle')}</h2>
|
||||
<p className="text-muted-foreground">
|
||||
Manage your application settings and preferences.
|
||||
{t('settingsDescription')}
|
||||
</p>
|
||||
</div>
|
||||
<div className="space-y-3">
|
||||
|
||||
@@ -11,6 +11,7 @@ import { LightningFSAdapter } from '@/lib/LightningFSAdapter';
|
||||
import { AISettingsProvider } from '@/components/AISettingsProvider';
|
||||
import { GitSettingsProvider } from '@/components/GitSettingsProvider';
|
||||
import { SessionManagerProvider } from '@/components/SessionManagerProvider';
|
||||
import '@/lib/i18n';
|
||||
|
||||
interface TestAppProps {
|
||||
children: React.ReactNode;
|
||||
@@ -30,6 +31,7 @@ export function TestApp({ children }: TestAppProps) {
|
||||
theme: 'light',
|
||||
relayUrl: 'wss://relay.nostr.band',
|
||||
deployServer: 'shakespeare.wtf',
|
||||
language: 'en',
|
||||
};
|
||||
|
||||
// Initialize LightningFS for testing
|
||||
|
||||
Reference in new issue
Block a user