"""
Internationalization module for the Lichess Telegram Bot
English language only
"""
from typing import Optional
# Translation dictionary (English only)
TRANSLATIONS = {
'en': {
# Start command
'start_message': (
"The bot tracks one or more players on Lichess.\n"
"It shows ratings, daily, yesterday and weekly activity.\n"
"When specifying a user_token (with puzzle read permission), you can also get puzzle data.\n"
"The bot supports automatic checks at specified intervals and sends a report if there was activity during that time.\n\n"
"Example for a week:\n"
"š§© Puzzles: 114 (ā
81 - ā 33)\n\n"
"š„ Blitz ā 5 games ⢠š“ -10\n"
"Rating: 2245\n"
"ā
Wins: 1\n"
"ā Losses: 3\n"
"š¤ Draws: 1\n\n"
"š Rapid ā 19 games ⢠š¢ +20\n"
"Rating: 2248\n"
"ā
Wins: 8\n"
"ā Losses: 4\n"
"š¤ Draws: 7\n\n"
"š Available commands:\n"
"/addgamer - Add a Lichess player to track (username only)\n"
"/addtoken - Add a player with a token to get puzzle data\n"
"/getgamers - Select active player (for which /today and other commands will work)\n"
"/delgamer - Remove a player from the tracked list\n"
"/today - Statistics for today\n"
"/yesterday - Statistics for yesterday\n"
"/week - Statistics for the week\n"
"/lastYear_or_1000games - Statistics for the last year or last 1000 rated games (whichever comes first)\n"
"/setperiod - Set up periodic notifications for the active player\n"
"(active player changes in the /getgamers menu)\n"
"/support - Contact the developer for support and feedback"
),
# Add gamer commands
'addgamer_prompt': "š¤ Enter the Lichess username of the player to track:",
'addtoken_prompt': (
"š Enter the Lichess API token to get puzzle data.\n"
"The token is created in profile settings ā give it only puzzle:read permission.\n"
"After that, the player corresponding to this token will be added."
),
'token_added': "ā
Token added for player {username}!",
'gamer_added_with_token': "ā
Player {username} added with token!",
'gamer_added': "ā
Player {username} successfully added!\n\nTo add another player, use /addgamer",
'invalid_token': "ā Invalid token. Please try again.",
'token_username_error': "ā Failed to get username from token. Please try again.",
'empty_username': "ā Username cannot be empty. Please try again.",
'user_not_found': "ā Player {username} not found on Lichess. Check the spelling of the name.",
# Get gamers
'no_gamers': "š No players in database. Use /addgamer to add.",
'loading_ratings': "š Loading player ratings...",
'select_active_gamer': "š„ Select active player:\n\n",
'active_gamer_set': "ā
Active player: {username}",
'gamer_not_found': "ā Player not found",
# Delete gamer
'no_gamers_to_delete': "š You have no tracked players.",
'loading_gamers': "š Loading player list...",
'select_gamer_to_delete': "šļø Select player to delete:\n\n",
'gamer_deleted': "ā
Player {username} removed from tracked list.",
'active_gamer_deleted': "ā
Player {username} removed from tracked list.\n\nā ļø You deleted the active player. Use the /getgamers command to select a player for which the /today, /yesterday, /week commands will work.",
'last_gamer_deleted': "ā
Player {username} removed from tracked list.\n\nā ļø You deleted the last player. Use the /addgamer command to add a new tracked player.",
'delete_failed': "ā Failed to delete player",
# Stats commands
'no_active_gamer': "ā No active player. Use /getgamers to select.",
'unknown_period': "ā Unknown period",
'no_data': "š No data",
'stats_title': "š Statistics {username} ⢠{date_range}\n\n",
'puzzles_section': "š§© Puzzles: {total} (ā
{solved} - ā {unsolved})\n\n",
'games_section': "{emoji} {game_type} ā {games_count} games ⢠{rating_change}\nRating: {rating}\nā
Wins: {wins}\nā Losses: {losses}\nš¤ Draws: {draws}\n\n",
# Set period
'select_gamer_for_period': "ā±ļø Select player to set notification period:\n\n",
'select_period': "ā±ļø Select period for player {username}:\nš± Notifications will be sent to personal messages",
'notifications_disabled': "ā
Notifications disabled for {username}",
'period_set': "ā
Period {period} minutes set for {username}\nš± Notifications will be sent to personal messages",
'disable_notifications': "ā Disable notifications",
'period_minutes': "ā° {period} minutes",
# Period notification
'period_1_minute': "for 1 minute",
'period_2_3_4_minutes': "for {period} minutes",
'period_minutes_text': "for {period} minutes",
'period_notification_title': "š Statistics {username} ⢠{period_text}\n\n",
'period_puzzles_section': "š§© Puzzles: {total} (ā
{solved} - ā {failed})\n\n",
'period_games_section': "{emoji} {game_type} ā {games_count} games ⢠{rating_change}\nRating: {rating}\nā
Wins: {wins}\nā Losses: {losses}\nš¤ Draws: {draws}\n\n",
'no_activity': "š No activity for this period",
# Last year or 1000 games
'last_year_1000_processing': "ā³ Processing request... This may take a while as requests are very slow.",
'last_year_1000_player_processing': "š Requesting data for player {username}...",
# Stats commands (today/yesterday/week)
'stats_processing': "ā³ Processing request...",
'stats_player_processing': "š Requesting data for player {username}...",
'stats_all_done': "ā
That's all",
# Support
'support_message': (
"š¬ Support & Feedback\n\n"
"You can write to the service developer directly and report a problem, suggest new features, or ask a question.\n\n"
"I will be happy to review every message and respond to it.\n\n"
"The developer accepts messages in English and Russian languages.\n\n"
"š§ Contact: @vrubelr\n\n"
"š¦ Bot version: {version}"
),
# Common
'period_minutes_suffix': "m",
}
}
def get_user_language(update) -> str:
"""
Always return English language.
"""
return 'en'
def t(key: str, lang: str = 'en', **kwargs) -> str:
"""
Translate a key (always English).
Args:
key: Translation key
lang: Language code (ignored, always uses English)
**kwargs: Format arguments for the translation string
Returns:
Translated string with formatted arguments
"""
translation = TRANSLATIONS['en'].get(key, key)
# Format the string if kwargs provided
if kwargs:
try:
return translation.format(**kwargs)
except KeyError:
# If formatting fails, return the translation as-is
return translation
return translation
def get_lang_from_update(update) -> str:
"""
Always return English.
"""
return 'en'