The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 07:15 UTC
fix(mobile): custom snooze date label follows the app language on Android (#38663)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Wout Stiens committed
Nov 19, 2026 at 04:17 UTC
80142c0cc313a8880ea3aeb48ac6f336018be506
5 files changed
+76
-22
apps/mobile/src/features/threads/CustomSnoozeSheet.android.tsx
+6
-12
@@ -32,12 +32,14 @@ import { useEffect, useState } from "react";
32
import { AppState, useWindowDimensions } from "react-native";
33
34
import { OverlayPortal } from "../../components/ui/OverlayPortal";
35
+import { useFormattingLocale } from "../../i18n/I18nProvider";
36
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
37
import { useScaledTextRole } from "../settings/appearance/useScaledTextRole";
38
import {
39
applySnoozePickerDate,
40
applySnoozePickerTime,
41
snoozeDateToPickerDate,
42
+ snoozePickerLabels,
43
} from "./customSnoozeDate";
44
45
type Props = {
@@ -64,6 +66,7 @@ function systemUses24HourClock() {
66
export function CustomSnoozeSheet(props: Props) {
67
const gt = useGT();
68
const m = useMessages();
69
+ const locale = useFormattingLocale();
70
const { themeAppearance, themeVariables: colors } = useAppearancePreferences();
71
const [is24Hour, setIs24Hour] = useState(systemUses24HourClock);
72
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- subscribes to AppState to re-read the native 24-hour clock setting when the app resumes
@@ -82,6 +85,7 @@ export function CustomSnoozeSheet(props: Props) {
85
const [amount, setAmount] = useState(2);
86
const [unit, setUnit] = useState<"minutes" | "hours" | "days">("hours");
87
const [error, setError] = useState<string | null>(null);
88
+ const pickerLabels = snoozePickerLabels(date, locale, is24Hour);
89
const submit = () => {
90
const input: CustomSnoozeInput =
91
mode === "date"
@@ -166,18 +170,8 @@ export function CustomSnoozeSheet(props: Props) {
170
<SegmentedControl
171
variant="card"
172
options={[
169
- {
170
- value: "date",
171
- label: date.toLocaleDateString([], { month: "short", day: "numeric" }),
172
- },
173
- {
174
- value: "time",
175
- label: date.toLocaleTimeString([], {
176
- hour: "numeric",
177
- minute: "2-digit",
178
- hourCycle: is24Hour ? "h23" : "h12",
179
- }),
180
- },
173
+ { value: "date", label: pickerLabels.date },
174
+ { value: "time", label: pickerLabels.time },
175
]}
176
selected={picker}
177
onSelect={setPicker}
apps/mobile/src/features/threads/customSnoozeDate.test.ts
+25
-1
@@ -1,6 +1,12 @@
1
+import { resolveLocaleSelection, SYSTEM_LANGUAGE } from "@t3tools/client-runtime/locales";
2
import { describe, expect, it } from "vite-plus/test";
3
3
-import { applySnoozePickerDate, snoozeDateToPickerDate } from "./customSnoozeDate";
4
+import { DEFAULT_LOCALE, SUPPORTED_LOCALES } from "../../i18n/locales";
5
+import {
6
+ applySnoozePickerDate,
7
+ snoozeDateToPickerDate,
8
+ snoozePickerLabels,
9
+} from "./customSnoozeDate";
10
11
describe("custom snooze calendar conversion", () => {
12
it("passes the local calendar day to Compose without shifting it across time zones", () => {
@@ -20,4 +26,22 @@ describe("custom snooze calendar conversion", () => {
26
]).toEqual([2026, 8, 20, 23, 45]);
27
expect(date.getDate()).toBe(16);
28
});
29
+
30
+ it.each([
31
+ { language: SYSTEM_LANGUAGE, catalog: "en", dateLabel: "5 May" },
32
+ { language: "fr", catalog: "fr", dateLabel: "5 mai" },
33
+ ])("labels the picked date and time for the $language preference", (test) => {
34
+ const date = new Date(2027, 4, 5, 14, 30);
35
+ const { catalogLocale, formattingLocale } = resolveLocaleSelection(
36
+ test.language,
37
+ ["it-IT", "en-GB"],
38
+ SUPPORTED_LOCALES,
39
+ DEFAULT_LOCALE,
40
+ );
41
+ expect(catalogLocale).toBe(test.catalog);
42
+ expect(snoozePickerLabels(date, formattingLocale, true)).toEqual({
43
+ date: test.dateLabel,
44
+ time: "14:30",
45
+ });
46
+ });
47
});
apps/mobile/src/features/threads/customSnoozeDate.ts
+12
@@ -14,3 +14,15 @@ export function applySnoozePickerTime(date: Date, selected: Date): Date {
14
next.setHours(selected.getHours(), selected.getMinutes(), 0, 0);
15
return next;
16
}
17
+
18
+/** Format the segment labels without changing the device's hour-cycle setting. */
19
+export function snoozePickerLabels(date: Date, locale: string, is24Hour: boolean) {
20
+ return {
21
+ date: date.toLocaleDateString(locale, { month: "short", day: "numeric" }),
22
+ time: date.toLocaleTimeString(locale, {
23
+ hour: "numeric",
24
+ minute: "2-digit",
25
+ hourCycle: is24Hour ? "h23" : "h12",
26
+ }),
27
+ };
28
+}
apps/mobile/src/i18n/I18nProvider.tsx
+20
-6
@@ -1,15 +1,21 @@
1
import "./intl-polyfills";
2
-import { resolveLocale } from "@t3tools/client-runtime/locales";
2
+import { resolveLocaleSelection } from "@t3tools/client-runtime/locales";
3
import { useAtomValue } from "@effect/atom-react";
4
import { AsyncResult } from "effect/reactivity";
5
import { GTProvider, initializeGT, useLocale } from "gt-react-native";
6
-import { useDeferredValue, useEffect, type ReactNode } from "react";
6
+import { createContext, use, useDeferredValue, useEffect, useMemo, type ReactNode } from "react";
7
import { Platform, TurboModuleRegistry, View, type TurboModule } from "react-native";
8
9
import { mobilePreferencesAtom } from "../state/preferences";
10
import { DEFAULT_LOCALE, SUPPORTED_LOCALES } from "./locales";
11
import { setActiveLocale } from "./messages";
12
13
+const FormattingLocaleContext = createContext(DEFAULT_LOCALE);
14
+
15
+export function useFormattingLocale(): string {
16
+ return use(FormattingLocaleContext);
17
+}
18
+
19
// Committed catalogs, so forks and offline installs never reach GT's CDN. English is the source.
20
// Required on demand: Metro runs every statically imported module at startup, and only one
21
// locale's catalog is ever used.
@@ -58,15 +64,23 @@ export function useLanguagePreference(): string {
64
65
/** Translates the app into the saved language; "system" follows the device. Mounted once in App. */
66
export function I18nProvider(props: { readonly children: ReactNode }) {
67
+ const { catalogLocale, formattingLocale } = resolveLocaleSelection(
68
+ useLanguagePreference(),
69
+ readSystemLocales(),
70
+ SUPPORTED_LOCALES,
71
+ DEFAULT_LOCALE,
72
+ );
73
// GT suspends while a locale's catalog loads. Deferring the switch keeps the current language
74
// on screen until then, instead of GT's full-screen spinner.
63
- const locale = useDeferredValue(
64
- resolveLocale(useLanguagePreference(), readSystemLocales(), SUPPORTED_LOCALES, DEFAULT_LOCALE),
75
+ const selection = useDeferredValue(
76
+ useMemo(() => ({ catalogLocale, formattingLocale }), [catalogLocale, formattingLocale]),
77
);
78
return (
67
- <GTProvider locale={locale} fallback={<View className="flex-1 bg-screen" />}>
79
+ <GTProvider locale={selection.catalogLocale} fallback={<View className="flex-1 bg-screen" />}>
80
<ActiveLocale />
69
- {props.children}
81
+ <FormattingLocaleContext value={selection.formattingLocale}>
82
+ {props.children}
83
+ </FormattingLocaleContext>
84
</GTProvider>
85
);
86
}
packages/client-runtime/src/locales.ts
+13
-3
@@ -36,10 +36,20 @@ export function resolveLocale(
36
supported: ReadonlyArray<string>,
37
fallback: string,
38
): string {
39
- if (supported.includes(language)) return language;
39
+ return resolveLocaleSelection(language, systemLocales, supported, fallback).catalogLocale;
40
+}
41
+
42
+/** Keep the matching system tag for regional formats while loading a supported catalog. */
43
+export function resolveLocaleSelection(
44
+ language: string,
45
+ systemLocales: ReadonlyArray<string>,
46
+ supported: ReadonlyArray<string>,
47
+ fallback: string,
48
+): { readonly catalogLocale: string; readonly formattingLocale: string } {
49
+ if (supported.includes(language)) return { catalogLocale: language, formattingLocale: language };
50
for (const tag of systemLocales) {
51
const match = matchSupportedLocale(tag, supported);
42
- if (match) return match;
52
+ if (match) return { catalogLocale: match, formattingLocale: tag.trim().replaceAll("_", "-") };
53
}
44
- return fallback;
54
+ return { catalogLocale: fallback, formattingLocale: fallback };
55
}