Repository navigation
telegram: follow the Studio language instead of defaulting to Ukrainian (#135) - #138
Merged
Merged
Conversation
…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.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #135.
The bug
The app's own language fallback is English:
GET /api/langanswersc.lang || 'en', so afresh install — no saved
langin the config — runs an English UI. The Telegram bot had itsown fallback of
'uk', in three places:telegram-bot.js(this.lang = opts.lang || 'uk')and both
new TelegramBot(...)calls inserver.js. A user who never touched the languagesetting therefore paired with a Ukrainian message, which is what #135 reports.
_t()alsofell back to
BOT_I18N.ukfor any key missing from the active dictionary.What changed
'en'), in the constructor and in bothserver.jscall sites._t()is_t(key, params, lang):langoverrides the instance language for one call, andthe last-resort dictionary is English — matching the SPA's
t(), which already prefers thelanguage, then English, then the key.
person writing may not be the Studio owner, so it answers in the writer's Telegram client
locale (
from.language_code, regional codes likehe-ILreduced to the base) when we shipit, and in the Studio language otherwise. Nothing after pairing changes: the configured
language still governs every message.
Tests
test/telegram-lang.test.js(added tonpm test) runs the real bot against a temp SQLitedatabase with
_callApirecorded — no network: an unconfigured bot speaks English, aconfigured
ukbot keeps Ukrainian, an unknown language and an unknown key fall back toEnglish,
/startfromfrgets the French pairing screen whiledeand no locale fall backto 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 onlyred step is
test/task-backlog.test.js, which fails identically on unmodifiedmain(measured on a clean worktree of 2d95fe4) and passes when run on its own — pre-existing flake,
outside this change.