Telegram Bot + Mini App for city walking quests. - React 19 + TypeScript + Vite 6 frontend - Express 5 + PostgreSQL backend - grammY Telegram bot with DeepSeek AI - GitLab CI/CD: lint, build, deploy to production Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
26 lines
716 B
TypeScript
26 lines
716 B
TypeScript
import { ru } from './ru.js'
|
|
import { en } from './en.js'
|
|
|
|
const translations: Record<string, Record<string, string>> = { ru, en }
|
|
|
|
export function getLang(languageCode?: string): string {
|
|
if (!languageCode) return 'ru'
|
|
if (languageCode.startsWith('ru') || languageCode.startsWith('uk') || languageCode.startsWith('be')) {
|
|
return 'ru'
|
|
}
|
|
return 'en'
|
|
}
|
|
|
|
export function t(lang: string, key: string, params?: Record<string, string | number>): string {
|
|
const dict = translations[lang] || translations['ru']
|
|
let text = dict[key] || translations['ru'][key] || key
|
|
|
|
if (params) {
|
|
for (const [k, v] of Object.entries(params)) {
|
|
text = text.replace(`{${k}}`, String(v))
|
|
}
|
|
}
|
|
|
|
return text
|
|
}
|