Phase 7: languages
- Complete Spanish (neutral Latin American, Paraguay friendly, no inverted marks) and Dutch catalogs, including the Mini App and owner texts - Command menus per language in three scopes (private, group members, group admins); per-chat menus follow a user's /language and a group's /grouplang, from chat and from the Mini App - Bot name, description and short description per language, sent only when the catalog text changes (TELEGRAM_SET_PROFILE) - Dates from the catalog, numbers, sizes and durations per locale - Pseudo-locale en-XA generated from English (I18N_PSEUDO), owners only - Catalog checks: completeness, placeholders, tags, commands, plurals, Telegram length limits, untranslated text, unused and missing IDs - CI workflow; make i18n-check; docs/TRANSLATING.md - Test fix: the queued-download helper could match another chat's status Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
4f11f939a0
commit
f1f9c6156c
@@ -655,3 +655,118 @@ Checked against https://core.telegram.org/bots/webapps on 2026-11-18.
|
||||
retry's file, and the job failed with an internal error. It showed up as
|
||||
a rare test failure on a busy machine. Every attempt now has its own
|
||||
directory, and a test holds the two slots in exactly that order.
|
||||
|
||||
## Phase 7
|
||||
|
||||
### Verified Bot API facts
|
||||
|
||||
Checked against https://core.telegram.org/bots/api (Bot API 10.4) on
|
||||
2026-11-18, and against telego v1.13.0.
|
||||
|
||||
- `setMyCommands` takes at most 100 commands, a scope, and a two-letter
|
||||
ISO 639-1 `language_code`. Without a code the list applies to users
|
||||
whose language has no list of its own. A command is 1 to 32 lowercase
|
||||
letters, digits or underscores; a description 1 to 256 characters.
|
||||
- Telegram picks the menu in this order: chat scope with the user's
|
||||
language, chat scope, then all private chats (or, in groups, chat
|
||||
administrators, chat, all chat administrators, all group chats), then
|
||||
default, each with and then without the language.
|
||||
- `setMyName` (0 to 64 characters), `setMyDescription` (0 to 512, shown
|
||||
in an empty chat) and `setMyShortDescription` (0 to 120, shown on the
|
||||
profile and when the bot is shared) take the same `language_code`.
|
||||
- `deleteMyCommands` removes the list of a scope and language.
|
||||
|
||||
### Languages
|
||||
|
||||
- English is the source and the fallback. Spanish and Dutch ship
|
||||
complete. A user gets their Telegram language when a catalog matches
|
||||
it, regional variants included (es-PY uses Spanish), and English
|
||||
otherwise. `/language` (or the Mini App) overrides that per user;
|
||||
`/grouplang` per group.
|
||||
- Spanish: neutral Latin American with "tú". Paraguay speaks "vos", but
|
||||
"tú" is what written Spanish across the region expects and is read
|
||||
without friction in Paraguay; the vocabulary avoids words that sound
|
||||
odd there. No opening `¿` or `¡`, as asked; a test enforces it.
|
||||
- Dutch: informal "je".
|
||||
- Owner texts are translated too. Owners pick their language like anyone.
|
||||
- Command names, their arguments (`/spending admins`) and product IDs
|
||||
stay English in every language. The bot parses them.
|
||||
- The invoice memo, which wallets show, is the brand name plus the
|
||||
product in the payer's language.
|
||||
|
||||
### Menus and profile
|
||||
|
||||
- At startup the core publishes three menus in every language: private
|
||||
chats (download, account and preference commands), group members
|
||||
(download commands, the group wallet and pass) and group admins (the
|
||||
same plus the settings commands). Owner commands are never listed.
|
||||
`/app` is listed only when the Mini App is on.
|
||||
- The source language is published without a language code, so it is
|
||||
also the menu for languages without a catalog.
|
||||
- Telegram chooses menus by the language of the user's app, not by the
|
||||
bot's setting. So when a user picks a language in the bot, the core
|
||||
sets a menu for that private chat alone; "follow my Telegram language"
|
||||
deletes it. `/grouplang` does the same for the group's member and
|
||||
admin menus. These calls are limited to six per minute per chat.
|
||||
- Chat menus are not rewritten when a catalog changes. They refresh the
|
||||
next time that user or group changes language. The general menus are
|
||||
rewritten at every start and on `/reload i18n`.
|
||||
- The bot's name, description and short description are set per
|
||||
language from `profile.*`, but only when the text changed since the
|
||||
last time it went through, because Telegram limits these calls
|
||||
hard. `TELEGRAM_SET_PROFILE=false` leaves what was set in @BotFather.
|
||||
A change made in @BotFather is overwritten only when the catalog text
|
||||
changes.
|
||||
|
||||
### Formatting
|
||||
|
||||
- Numbers use the language's grouping and decimal marks (Go's
|
||||
`golang.org/x/text`, and `Intl` in the Mini App): "1.000 sats",
|
||||
"10,0 MB" in Spanish and Dutch.
|
||||
- Dates are written from the catalog (`format.date`, `format.datetime`,
|
||||
`format.months`): "18 nov 2026, 12:05 UTC". Always UTC, and labeled:
|
||||
the bot does not know the reader's time zone. Limits reset at midnight
|
||||
UTC, which the texts say.
|
||||
- Durations in words use the plural rules of the language ("5 minutos").
|
||||
Media lengths are written as 4:05 everywhere.
|
||||
|
||||
### Completeness check
|
||||
|
||||
- `locales/catalog_test.go` is the check CI runs (`make i18n-check`).
|
||||
For every catalog it fails on: a message missing or extra compared with
|
||||
the source, a plural that is plain elsewhere or lacks `one`, a changed
|
||||
set of placeholders, HTML tags or commands, broken braces, empty
|
||||
texts, stray spaces, em dashes, inverted marks in Spanish, menu and
|
||||
profile texts over Telegram's limits, button labels over 40
|
||||
characters, a month list that is not twelve long, and a duplicate
|
||||
language name. It also flags longer texts identical to English, except
|
||||
where they are meant to be (the brand name in the invoice memo).
|
||||
- It also reads the code. Every message of the source must be used,
|
||||
either by its full ID or by a prefix or suffix the code builds IDs from
|
||||
(`"error." + code`, `name + ".list"`), and every ID-shaped string in the
|
||||
code whose table exists must be in the catalog. Tests are not counted.
|
||||
`web/miniapp/embed_test.go` does the same for the Mini App.
|
||||
- `.github/workflows/ci.yml` runs this, the whole suite with the race
|
||||
detector, the suite on Postgres, and the Mini App build and browser
|
||||
test. It was written for GitHub Actions and has not run there yet;
|
||||
every step in it was run here by hand.
|
||||
|
||||
### Pseudo-locale
|
||||
|
||||
- `I18N_PSEUDO=true` makes `en-XA` from the English catalog at load time:
|
||||
accented letters, brackets, a third longer, with placeholders, tags,
|
||||
entities, commands, links and mentions kept. Plurals and dates keep
|
||||
working.
|
||||
- It is hidden from users and offered to owners only, in `/language`,
|
||||
`/grouplang` and the Mini App. It is never published to Telegram
|
||||
(not a two-letter code).
|
||||
|
||||
### Fixed on the way
|
||||
|
||||
- The test helper that sets up a waiting download picked the first "In
|
||||
the queue" status edit after the second user's press, from any chat.
|
||||
Under load a late edit of the first user's status could match, and the
|
||||
test then pressed the wrong button. It now matches the second user's
|
||||
chat only. This is the likely cause of the one Postgres failure of
|
||||
`TestSkipTheQueueWithInvoice` reported in Phase 4, which uses the same
|
||||
helper. The bot itself was right in both cases.
|
||||
|
||||
Reference in New Issue
Block a user