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:
31
apps/localization-service/src/lib/geoClient.ts
Normal file
31
apps/localization-service/src/lib/geoClient.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user