From 32b33d56a176e86c1a2f1d661b2aaaf2664832a7 Mon Sep 17 00:00:00 2001 From: Nicolas Cantu Date: Mon, 5 Jan 2026 22:43:11 +0100 Subject: [PATCH] Add translations for settings page (fr/en) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Motivations:** - Translate settings page and all its components to French and English - Provide consistent multilingual experience **Root causes:** - Settings page and components were hardcoded in English - No translation support for key management and NIP-95 configuration **Correctifs:** - None (new feature) **Evolutions:** - Added translations for settings page title - Added translations for KeyManagementManager component: - Public keys display (npub and hex) - Import form and validation messages - Recovery phrase display - All buttons and warnings - Added translations for Nip95ConfigManager component: - Endpoint list and management - Add/edit/remove actions - Error messages - Updated both fr.txt and en.txt translation files - All text now uses t() function for i18n support **Pages affectées:** - pages/settings.tsx - components/KeyManagementManager.tsx - components/Nip95ConfigManager.tsx - public/locales/fr.txt - public/locales/en.txt - locales/fr.txt - locales/en.txt --- components/KeyManagementManager.tsx | 78 +++++++++++------------- components/Nip95ConfigManager.tsx | 43 +++++++------- locales/en.txt | 68 ++++++++++++++++++++- locales/fr.txt | 92 ++++++++++++++++++++++++++++- pages/settings.tsx | 5 +- public/locales/en.txt | 65 ++++++++++++++++++++ public/locales/fr.txt | 66 +++++++++++++++++++++ 7 files changed, 347 insertions(+), 70 deletions(-) diff --git a/components/KeyManagementManager.tsx b/components/KeyManagementManager.tsx index c3caee1..cc9baa7 100644 --- a/components/KeyManagementManager.tsx +++ b/components/KeyManagementManager.tsx @@ -2,6 +2,7 @@ import { useState, useEffect } from 'react' import { nostrAuthService } from '@/lib/nostrAuth' import { keyManagementService } from '@/lib/keyManagement' import { nip19 } from 'nostr-tools' +import { t } from '@/lib/i18n' interface PublicKeys { publicKey: string @@ -41,7 +42,7 @@ export function KeyManagementManager() { } } } catch (e) { - const errorMessage = e instanceof Error ? e.message : 'Failed to load keys' + const errorMessage = e instanceof Error ? e.message : t('settings.keyManagement.loading') setError(errorMessage) console.error('Error loading keys:', e) } finally { @@ -79,14 +80,14 @@ export function KeyManagementManager() { async function handleImport() { if (!importKey.trim()) { - setError('Please enter a private key') + setError(t('settings.keyManagement.import.error.required')) return } // Extract key from URL or text const extractedKey = extractKeyFromUrl(importKey.trim()) if (!extractedKey) { - setError('Invalid key format. Please provide a nsec (nsec1...) or hex private key.') + setError(t('settings.keyManagement.import.error.invalid')) return } @@ -104,8 +105,7 @@ export function KeyManagementManager() { } catch (e) { // If decoding failed, assume it's hex, validate length (64 hex chars = 32 bytes) if (!/^[0-9a-f]{64}$/i.test(extractedKey)) { - const errorMsg = e instanceof Error ? e.message : 'Invalid format' - setError(`Invalid key format: ${errorMsg}. Please provide a nsec (nsec1...) or hex (64 characters) private key.`) + setError(t('settings.keyManagement.import.error.invalid')) return } } @@ -138,7 +138,7 @@ export function KeyManagementManager() { setShowImportForm(false) await loadKeys() } catch (e) { - const errorMessage = e instanceof Error ? e.message : 'Failed to import key' + const errorMessage = e instanceof Error ? e.message : t('settings.keyManagement.import.error.failed') setError(errorMessage) console.error('Error importing key:', e) } finally { @@ -194,7 +194,7 @@ export function KeyManagementManager() { if (loading) { return (
-

Loading...

+

{t('settings.keyManagement.loading')}

) } @@ -202,7 +202,7 @@ export function KeyManagementManager() { return (
-

Key Management

+

{t('settings.keyManagement.title')}

{error && (
@@ -215,14 +215,14 @@ export function KeyManagementManager() {
-

Public Key (npub)

+

{t('settings.keyManagement.publicKey.npub')}

{publicKeys.npub}

@@ -230,14 +230,14 @@ export function KeyManagementManager() {
-

Public Key (hex)

+

{t('settings.keyManagement.publicKey.hex')}

{publicKeys.publicKey}

@@ -247,9 +247,9 @@ export function KeyManagementManager() { {!publicKeys && !accountExists && (
-

No account found

+

{t('settings.keyManagement.noAccount.title')}

- Create a new account by importing a private key. The key will be encrypted using a two-level encryption system. + {t('settings.keyManagement.noAccount.description')}

)} @@ -263,28 +263,23 @@ export function KeyManagementManager() { }} className="w-full py-3 px-6 bg-neon-cyan/20 hover:bg-neon-cyan/30 text-neon-cyan rounded-lg font-medium transition-all border border-neon-cyan/50 hover:shadow-glow-cyan" > - {accountExists ? 'Replace Account (Import New Key)' : 'Import Private Key'} + {accountExists ? t('settings.keyManagement.import.button.replace') : t('settings.keyManagement.import.button.new')} )} {showImportForm && (
-

⚠️ Important

-

- After importing, you will receive 4 recovery words (BIP39 dictionary) to secure your account. - These words encrypt a Key Encryption Key (KEK) stored in the browser's Credentials API, which then encrypts your private key stored in IndexedDB (two-level encryption system). -

+

{t('settings.keyManagement.import.warning.title')}

+

{accountExists && ( -

- Warning: Importing a new key will replace your existing account. Make sure you have your recovery phrase saved before proceeding. -

+

)}