fix: localize app status and backup timestamps - #1124
Conversation
Greptile SummaryThis PR localizes App Status and Backup timestamps using the active default locale.
Confidence Score: 4/5The application-locale mismatch needs to be fixed before merging because timestamps remain in the device language when users select a different language within Bitkit.
Files Needing Attention: app/src/main/java/to/bitkit/ext/DateTime.kt
|
| Filename | Overview |
|---|---|
| app/src/main/java/to/bitkit/ext/DateTime.kt | Makes timestamp formatting locale-aware, but the new default reads the device/JVM locale rather than Bitkit's application-specific locale. |
| app/src/test/java/to/bitkit/ext/DateTimeExtTest.kt | Adds focused formatter tests, but the default-locale test uses Locale.setDefault() rather than exercising the app-specific locale path. |
| changelog.d/next/1112.fixed.md | Documents the user-visible timestamp localization change. |
Reviews (1): Last reviewed commit: "fix: localize app status and backup time..." | Re-trigger Greptile
| } | ||
|
|
||
| fun Long.toLocalizedTimestamp(locale: Locale = Locale.US): String { | ||
| fun Long.toLocalizedTimestamp(locale: Locale = Locale.getDefault()): String { |
There was a problem hiding this comment.
When the app language differs from the device language, Locale.getDefault() still supplies the device locale because AppLocaleManager changes the application resource configuration without changing the JVM default. The no-argument callers therefore continue rendering App Status and Backup timestamps in the device language instead of the language selected in Bitkit.
Knowledge Base Used: Extension Utilities (to.bitkit.ext)
There was a problem hiding this comment.
AppCompat keeps those in sync: on API 28 to 32 setApplicationLocales ends in setDefaultLocalesForLocaleList, which calls LocaleList.setDefault, and on 33+ the platform LocaleManager does it. Verified the German row on an emulator.
There was a problem hiding this comment.
You're right — I was wrong about this. AppCompat's backport path does call LocaleList.setDefault, which in turn calls Locale.setDefault, so Locale.getDefault() does reflect the in-app language selection. Combined with your emulator verification on German, my concern doesn't hold.
The change is correct as written.
Shall I remember this as a rule: "do not flag Locale.getDefault() as ignoring the in-app locale when AppCompatDelegate is used, because AppCompat syncs it via LocaleList.setDefault on all supported API levels"?
Tip: You can customize Greptile's behavior for this repo with .greptile/rules.md and .greptile/config.json.
Fixes #1112
This PR makes the App Status and Backup timestamps follow the device language instead of always formatting them in US English.
Description
toLocalizedTimestampdefaulted toLocale.US, and all three call sites take the default. On a German device App Status therefore readJuly 31, 2026 at 8:08 PMdirectly under the translated labelVollständiges Backup.toRelativeTimeStringin the same file already defaults toLocale.getDefault(), so this was the one date helper that did not.Locale.getDefault()is the right source rather than the system configuration, becauseAppLocaleManagersets the language throughAppCompatDelegate.setApplicationLocales. Bitkit's own Language setting therefore moves the timestamps too, not only a change of device language.toLocalizedTimestamptoLocale.getDefault(), which fixes App Status, Backup metadata and the App Status preview in one line.MMMM d, yyyy 'at' h:mm a, withjava.text.DateFormat.getDateTimeInstance(LONG, SHORT, locale). The old pattern was English word order with a literalat, so on the fallback path a German locale still producedJuli 27, 2026 at 9:26 PM.Locale.USuses alone:utcDateFormatterOf,Logger,TrezorDebugLog, and thelowercase(Locale.US)calls inmodels/that are locale-invariant on purpose.The clock format here follows the locale rather than the device's 12/24-hour setting, which is what
DateFormat.SHORTmeans:deprints20:08,en-USprints8:08 PM. That differs from the activity and connection rows, where the pattern is fixed by design and the 12/24-hour setting decides.Preview
QA Notes
Manual Tests
31. Juli 2026 um 20:10, matching the surrounding translated labels. The issue asked for27. Juli 2026, 21:26; ICU joins German long dates withumrather than a comma.regression:set the language back to English: the same row still readsJuly 31, 2026 at 8:08 PM.Automated Checks
DateTimeExtTest.kt: the supplied locale, the default locale, and the day-before-month ordering German uses. All three fail on master and pass here.cmd locale set-app-locales.just compile,just test,just lintall pass, no new detekt findings.