Skip to content

telegram: follow the Studio language instead of defaulting to Ukrainian (#135) - #138

Merged
Lexus2016 merged 1 commit into
mainfrom
fix/telegram-lang-135
Nov 10, 2026
Merged

Lexus2016 merged 1 commit into
mainfrom
fix/telegram-lang-135

Conversation

@Lexus2016

Copy link
Copy Markdown
Owner

Fixes #135.

The bug

The app's own language fallback is English: GET /api/lang answers c.lang || 'en', so a
fresh install — no saved lang in the config — runs an English UI. The Telegram bot had its
own fallback of 'uk', in three places: telegram-bot.js (this.lang = opts.lang || 'uk')
and both new TelegramBot(...) calls in server.js. A user who never touched the language
setting therefore paired with a Ukrainian message, which is what #135 reports. _t() also
fell back to BOT_I18N.uk for any key missing from the active dictionary.

What changed

  • The bot takes the same default as the SPA ('en'), in the constructor and in both
    server.js call sites.
  • _t() is _t(key, params, lang): lang overrides the instance language for one call, and
    the last-resort dictionary is English — matching the SPA's t(), which already prefers the
    language, then English, then the key.
  • The pairing screen has no Studio preference to read before a device is paired, and the
    person writing may not be the Studio owner, so it answers in the writer's Telegram client
    locale (from.language_code, regional codes like he-IL reduced to the base) when we ship
    it, and in the Studio language otherwise. Nothing after pairing changes: the configured
    language still governs every message.

Tests

test/telegram-lang.test.js (added to npm test) runs the real bot against a temp SQLite
database with _callApi recorded — no network: an unconfigured bot speaks English, a
configured uk bot keeps Ukrainian, an unknown language and an unknown key fall back to
English, /start from fr gets the French pairing screen while de and no locale fall back
to the Studio language, a failed pairing code matches the screen it followed, and paired
messages stay in the Studio language.

Full local run on Node 24.22.1 (npm test, CI=1): 93 steps, the new file 13/13, and the only
red step is test/task-backlog.test.js, which fails identically on unmodified main
(measured on a clean worktree of 2d95fe4) and passes when run on its own — pre-existing flake,
outside this change.

…an (#135)

/api/lang answers `c.lang || 'en'`, and a fresh install has no saved `lang`, so the
bot's own 'uk' fallback made it answer in Ukrainian under an English UI — the pairing
screen first of all. The bot now takes the same default as the SPA and resolves a
missing key to English, never to Ukrainian.

The pairing screen is the one place with no Studio preference to read yet, so it
answers in the writer's Telegram client locale when we ship that language and in the
Studio language otherwise. Everything after pairing is unchanged: the configured
language still governs.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T18:16:20.311432Z e53047f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Lexus2016
Lexus2016 merged commit acb315f into main Nov 10, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Telegram Bot Messages Are Displayed in Ukrainian

1 participant