Files
tg_tinder_bot/src/models/User.ts
Andrey K. Choi edddd52589 feat: Complete localization system with i18n and DeepSeek AI translation
🌐 Interface Localization:
- Added i18next for multi-language interface support
- Created LocalizationService with language detection
- Added translation files for Russian and English
- Implemented language selection in user settings

🤖 AI Profile Translation (Premium feature):
- Integrated DeepSeek API for profile translation
- Added TranslationController for translation management
- Premium-only access to profile translation feature
- Support for 10 languages (ru, en, es, fr, de, it, pt, zh, ja, ko)

�� Database & Models:
- Added language field to users table with migration
- Updated User model to support language preferences
- Added language constraints and indexing

🎛️ User Interface:
- Added language settings menu in bot settings
- Implemented callback handlers for language selection
- Added translate profile button for VIP users
- Localized all interface strings

📚 Documentation:
- Created comprehensive LOCALIZATION.md guide
- Documented API usage and configuration
- Added examples for extending language support
2025-09-13 08:59:10 +09:00

83 lines
2.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export interface UserData {
id: string;
telegramId: number;
username?: string;
firstName?: string;
lastName?: string;
languageCode?: string;
language?: string; // Предпочитаемый язык интерфейса
isActive: boolean;
createdAt: Date;
lastActiveAt: Date;
}
export class User {
id: string;
telegramId: number;
username?: string;
firstName?: string;
lastName?: string;
languageCode?: string;
language: string; // Предпочитаемый язык интерфейса
isActive: boolean;
createdAt: Date;
lastActiveAt: Date;
constructor(data: UserData) {
this.id = data.id;
this.telegramId = data.telegramId;
this.username = data.username;
this.firstName = data.firstName;
this.lastName = data.lastName;
this.languageCode = data.languageCode || 'en';
this.language = data.language || 'ru'; // Язык интерфейса по умолчанию
this.isActive = data.isActive;
this.createdAt = data.createdAt;
this.lastActiveAt = data.lastActiveAt;
}
// Метод для получения информации о пользователе
getUserInfo() {
return {
id: this.id,
telegramId: this.telegramId,
username: this.username,
firstName: this.firstName,
lastName: this.lastName,
fullName: this.getFullName(),
isActive: this.isActive
};
}
// Получить полное имя пользователя
getFullName(): string {
const parts = [this.firstName, this.lastName].filter(Boolean);
return parts.length > 0 ? parts.join(' ') : this.username || `User ${this.telegramId}`;
}
// Обновить время последней активности
updateLastActive(): void {
this.lastActiveAt = new Date();
}
// Деактивировать пользователя
deactivate(): void {
this.isActive = false;
}
// Активировать пользователя
activate(): void {
this.isActive = true;
this.updateLastActive();
}
// Установить язык интерфейса
setLanguage(language: string): void {
this.language = language;
}
// Получить язык интерфейса
getLanguage(): string {
return this.language;
}
}