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
+24
-4
@@ -2,6 +2,8 @@ package i18n
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -77,8 +79,26 @@ func (b *Bundle) Sats(lang string, n int64) string {
|
||||
return b.T(lang, "unit.sats", Args{"Count": n, "N": b.Number(lang, n)})
|
||||
}
|
||||
|
||||
// DateTime formats a point in time. The numeric form reads the same in
|
||||
// every language and always states the time zone.
|
||||
func (b *Bundle) DateTime(_ string, t time.Time) string {
|
||||
return t.UTC().Format("2006-01-02 15:04") + " UTC"
|
||||
// DateTime formats a point in time the way the language writes dates,
|
||||
// from format.datetime and format.months in its catalog. It is always in
|
||||
// UTC and says so: the bot does not know the reader's time zone.
|
||||
func (b *Bundle) DateTime(lang string, t time.Time) string {
|
||||
return b.T(lang, "format.datetime", b.dateArgs(lang, t))
|
||||
}
|
||||
|
||||
// Date formats a day, from format.date and format.months.
|
||||
func (b *Bundle) Date(lang string, t time.Time) string {
|
||||
return b.T(lang, "format.date", b.dateArgs(lang, t))
|
||||
}
|
||||
|
||||
func (b *Bundle) dateArgs(lang string, t time.Time) Args {
|
||||
t = t.UTC()
|
||||
month := strconv.Itoa(int(t.Month()))
|
||||
if names := strings.Split(b.T(lang, "format.months", nil), ","); len(names) == 12 {
|
||||
month = strings.TrimSpace(names[t.Month()-1])
|
||||
}
|
||||
return Args{
|
||||
"Day": t.Day(), "Month": month, "MonthNumber": fmt.Sprintf("%02d", int(t.Month())), "Year": t.Year(),
|
||||
"Hour": fmt.Sprintf("%02d", t.Hour()), "Minute": fmt.Sprintf("%02d", t.Minute()),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user