feat: localization service and frontend integration

- Add localization-service microservice (locale resolution, translations)
- Add frontend API routes /api/locale and /api/translations/[locale]
- Add LocalizationProvider and localization context
- Integrate localization into layout, EmptyChat, MessageInput components
- Update MICROSERVICES.md architecture docs
- Add localization-service to workspaces

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
home
2026-02-20 21:45:44 +03:00
parent 4269c8d99b
commit f4d945a2b5
21 changed files with 878 additions and 107 deletions

View File

@@ -0,0 +1,31 @@
import type { GeoDeviceContext } from '../types.js';
const GEO_DEVICE_URL =
process.env.GEO_DEVICE_SERVICE_URL ?? 'http://localhost:4002';
export async function fetchGeoContext(
headers: Record<string, string>,
body?: unknown,
): Promise<GeoDeviceContext | null> {
try {
const url = `${GEO_DEVICE_URL}/api/context`;
const options: RequestInit = {
method: body ? 'POST' : 'GET',
headers: {
'Content-Type': 'application/json',
'user-agent': headers['user-agent'] ?? '',
'accept-language': headers['accept-language'] ?? '',
'x-forwarded-for': headers['x-forwarded-for'] ?? '',
'x-real-ip': headers['x-real-ip'] ?? '',
},
};
if (body) {
options.body = JSON.stringify(body);
}
const res = await fetch(url, options);
if (!res.ok) return null;
return (await res.json()) as GeoDeviceContext;
} catch {
return null;
}
}