mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-19 13:21:46 +00:00
fix(login): address review feedback on language dropdown PR
- Fix import path: use i18n barrel instead of TranslationContext directly - Encapsulate localStorage key behind hasStoredLanguage() helper in settingsStore - Fix pt-BR detection: only map pt-BR to br, pt-PT now returns null correctly - Add comment linking server SUPPORTED_LANG_CODES to canonical client source - Extract /api/config inline handler to routes/publicConfig.ts - Add aria-haspopup, aria-expanded, role=listbox/option, aria-selected to dropdown - Add 8 tests for detectBrowserLanguage (FE-COMP-I18N-016–023) - Add 3 tests for setLanguageTransient (FE-STORE-SETTINGS-015–017)
This commit is contained in:
+3
-2
@@ -6,7 +6,7 @@ import path from 'node:path';
|
||||
import fs from 'node:fs';
|
||||
|
||||
import jwt from 'jsonwebtoken';
|
||||
import { JWT_SECRET, DEFAULT_LANGUAGE } from './config';
|
||||
import { JWT_SECRET } from './config';
|
||||
import { logDebug, logWarn, logError } from './services/auditLog';
|
||||
import { enforceGlobalMfaPolicy } from './middleware/mfaPolicy';
|
||||
import { authenticate } from './middleware/auth';
|
||||
@@ -41,6 +41,7 @@ import notificationRoutes from './routes/notifications';
|
||||
import shareRoutes from './routes/share';
|
||||
import journeyRoutes from './routes/journey';
|
||||
import journeyPublicRoutes from './routes/journeyPublic';
|
||||
import publicConfigRoutes from './routes/publicConfig';
|
||||
import { mcpHandler } from './mcp';
|
||||
import { Addon } from './types';
|
||||
import { getPhotoProviderConfig } from './services/memories/helpersService';
|
||||
@@ -194,7 +195,7 @@ export function createApp(): express.Application {
|
||||
app.use('/api/trips/:tripId/reservations', reservationsRoutes);
|
||||
app.use('/api/trips/:tripId/days/:dayId/notes', dayNotesRoutes);
|
||||
app.get('/api/health', (_req: Request, res: Response) => res.json({ status: 'ok' }));
|
||||
app.get('/api/config', (_req: Request, res: Response) => res.json({ defaultLanguage: DEFAULT_LANGUAGE }));
|
||||
app.use('/api/config', publicConfigRoutes);
|
||||
app.use('/api', assignmentsRoutes);
|
||||
app.use('/api/tags', tagsRoutes);
|
||||
app.use('/api/categories', categoriesRoutes);
|
||||
|
||||
@@ -102,6 +102,8 @@ export const ENCRYPTION_KEY = _encryptionKey;
|
||||
// DEFAULT_LANGUAGE sets the language shown on the login page before the user
|
||||
// selects one. Only applies when the user has no saved language preference.
|
||||
// Supported values: de, en, es, fr, hu, nl, br, cs, pl, ru, zh, zh-TW, it, ar
|
||||
// Must stay in sync with client/src/i18n/supportedLanguages.ts (canonical source).
|
||||
// Kept duplicated here because server and client are separate npm packages.
|
||||
const SUPPORTED_LANG_CODES = ['de', 'en', 'es', 'fr', 'hu', 'nl', 'br', 'cs', 'pl', 'ru', 'zh', 'zh-TW', 'it', 'ar'];
|
||||
const rawDefaultLang = process.env.DEFAULT_LANGUAGE || 'en';
|
||||
if (!SUPPORTED_LANG_CODES.includes(rawDefaultLang)) {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import express, { Request, Response } from 'express';
|
||||
import { DEFAULT_LANGUAGE } from '../config';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
router.get('/', (_req: Request, res: Response) => {
|
||||
res.json({ defaultLanguage: DEFAULT_LANGUAGE });
|
||||
});
|
||||
|
||||
export default router;
|
||||
Reference in New Issue
Block a user