@wix/himalaya-cli 0.1652.0 → 0.1653.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/l10n.d.ts +3 -0
- package/dist/browser-plane/assets.json +5 -5
- package/dist/browser-plane/preview-deferred/{6ba3f2eb2ac29f4f9eeebd1294a8003820cd260274c5400149d76833b3171555.bin → 3912fa5f6ddb60106c630fb5e48edbf12ebfd57c616d8b7aee0d32088cd3bbdf.bin} +1 -1
- package/dist/browser-plane/sw.js +7 -7
- package/dist/cli.mjs +1911 -1683
- package/dist/preview-assets.generated.bin +0 -0
- package/guides/one-app-to-himi-app.md +13 -4
- package/package.json +2 -2
- package/templates/beauty-salon/dev/index.ts +263 -204
- package/templates/beauty-salon/l10n/en.json +2653 -0
- package/templates/beauty-salon/l10n/es.json +33 -0
- package/templates/beauty-salon/l10n/he.json +3756 -0
- package/templates/beauty-salon/tier5-src/_shared/engine-intl.ts +18 -10
- package/templates/beauty-salon/tier5-src/_shared/himi-account.ts +5 -4
- package/templates/beauty-salon/tier5-src/_shared/himi-bookings.ts +1 -1
- package/templates/beauty-salon/tier5-src/_shared/himi-copy.ts +30 -3
- package/templates/beauty-salon/tier5-src/himi-booking-bookings/index.ts +2 -4
- package/templates/beauty-salon/tier5-src/himi-booking-service/index.ts +2 -2
- package/templates/beauty-salon/tier5-src/himi-booking-time/index.ts +1 -1
- package/templates/beauty-salon-owner/tier5-src/_shared/engine-intl.ts +18 -10
- package/templates/beauty-salon-owner/tier5-src/_shared/himi-copy.ts +30 -3
- package/templates/branded-lite/dev/index.ts +263 -204
- package/templates/branded-lite/l10n/en.json +5024 -478
- package/templates/branded-lite/l10n/es.json +33 -0
- package/templates/branded-lite/l10n/he.json +6652 -0
- package/templates/branded-lite/tier5-src/_shared/engine-intl.ts +18 -10
- package/templates/branded-lite/tier5-src/_shared/himi-account.ts +5 -4
- package/templates/branded-lite/tier5-src/_shared/himi-bookings.ts +1 -1
- package/templates/branded-lite/tier5-src/_shared/himi-copy.ts +30 -3
- package/templates/branded-lite/tier5-src/himi-booking-bookings/index.ts +2 -4
- package/templates/branded-lite/tier5-src/himi-booking-service/index.ts +2 -2
- package/templates/branded-lite/tier5-src/himi-booking-time/index.ts +1 -1
- package/templates/brandy/tier5-src/_shared/himi-copy.ts +30 -3
- package/templates/community-club/l10n/en.json +1788 -0
- package/templates/community-club/l10n/es.json +10 -0
- package/templates/community-club/l10n/he.json +2397 -0
- package/templates/community-club/tier5-src/_shared/engine-intl.ts +18 -10
- package/templates/community-club/tier5-src/_shared/himi-account.ts +5 -4
- package/templates/community-club/tier5-src/_shared/himi-copy.ts +30 -3
- package/templates/community-club-owner/tier5-src/_shared/engine-intl.ts +18 -10
- package/templates/community-club-owner/tier5-src/_shared/himi-copy.ts +30 -3
- package/templates/conference/tier5-src/_shared/engine-intl.ts +18 -10
- package/templates/conference/tier5-src/_shared/himi-account.ts +5 -4
- package/templates/conference/tier5-src/_shared/himi-copy.ts +30 -3
- package/templates/events-meetups/l10n/en.json +1739 -0
- package/templates/events-meetups/l10n/es.json +10 -0
- package/templates/events-meetups/l10n/he.json +2326 -0
- package/templates/events-meetups/tier5-src/_shared/engine-intl.ts +18 -10
- package/templates/events-meetups/tier5-src/_shared/himi-account.ts +5 -4
- package/templates/events-meetups/tier5-src/_shared/himi-copy.ts +30 -3
- package/templates/events-meetups-owner/tier5-src/_shared/engine-intl.ts +18 -10
- package/templates/events-meetups-owner/tier5-src/_shared/himi-copy.ts +30 -3
- package/templates/gym-fitness/dev/index.ts +263 -204
- package/templates/gym-fitness/l10n/en.json +2964 -0
- package/templates/gym-fitness/l10n/es.json +33 -0
- package/templates/gym-fitness/l10n/he.json +4170 -0
- package/templates/gym-fitness/tier5-src/_shared/engine-intl.ts +18 -10
- package/templates/gym-fitness/tier5-src/_shared/himi-account.ts +5 -4
- package/templates/gym-fitness/tier5-src/_shared/himi-bookings.ts +1 -1
- package/templates/gym-fitness/tier5-src/_shared/himi-copy.ts +30 -3
- package/templates/gym-fitness/tier5-src/himi-booking-bookings/index.ts +2 -4
- package/templates/gym-fitness/tier5-src/himi-booking-service/index.ts +2 -2
- package/templates/gym-fitness/tier5-src/himi-booking-time/index.ts +1 -1
- package/templates/gym-fitness-owner/tier5-src/_shared/engine-intl.ts +18 -10
- package/templates/gym-fitness-owner/tier5-src/_shared/himi-copy.ts +30 -3
- package/templates/himi-chat/tier5-src/_shared/himi-copy.ts +30 -3
- package/templates/nonprofit-cause/l10n/en.json +1926 -0
- package/templates/nonprofit-cause/l10n/es.json +10 -0
- package/templates/nonprofit-cause/l10n/he.json +2577 -0
- package/templates/nonprofit-cause/tier5-src/_shared/engine-intl.ts +18 -10
- package/templates/nonprofit-cause/tier5-src/_shared/himi-account.ts +5 -4
- package/templates/nonprofit-cause/tier5-src/_shared/himi-copy.ts +30 -3
- package/templates/nonprofit-cause-owner/tier5-src/_shared/engine-intl.ts +18 -10
- package/templates/nonprofit-cause-owner/tier5-src/_shared/himi-copy.ts +30 -3
- package/templates/owner-lite/tier5-src/_shared/engine-intl.ts +18 -10
- package/templates/owner-lite/tier5-src/_shared/himi-copy.ts +30 -3
- package/templates/podcast-creator/l10n/en.json +1840 -0
- package/templates/podcast-creator/l10n/es.json +10 -0
- package/templates/podcast-creator/l10n/he.json +2444 -0
- package/templates/podcast-creator/tier5-src/_shared/engine-intl.ts +18 -10
- package/templates/podcast-creator/tier5-src/_shared/himi-account.ts +5 -4
- package/templates/podcast-creator/tier5-src/_shared/himi-copy.ts +30 -3
- package/templates/podcast-creator-owner/tier5-src/_shared/engine-intl.ts +18 -10
- package/templates/podcast-creator-owner/tier5-src/_shared/himi-copy.ts +30 -3
- package/templates/portfolio-creative/dev/index.ts +263 -204
- package/templates/portfolio-creative/l10n/en.json +2426 -0
- package/templates/portfolio-creative/l10n/es.json +33 -0
- package/templates/portfolio-creative/l10n/he.json +3149 -0
- package/templates/portfolio-creative/tier5-src/_shared/engine-intl.ts +18 -10
- package/templates/portfolio-creative/tier5-src/_shared/himi-account.ts +5 -4
- package/templates/portfolio-creative/tier5-src/_shared/himi-copy.ts +30 -3
- package/templates/portfolio-creative-owner/tier5-src/_shared/engine-intl.ts +18 -10
- package/templates/portfolio-creative-owner/tier5-src/_shared/himi-copy.ts +30 -3
- package/templates/restaurant/l10n/en.json +2204 -0
- package/templates/restaurant/l10n/es.json +10 -0
- package/templates/restaurant/l10n/he.json +2862 -0
- package/templates/restaurant/tier5-src/_shared/engine-intl.ts +18 -10
- package/templates/restaurant/tier5-src/_shared/himi-account.ts +5 -4
- package/templates/restaurant/tier5-src/_shared/himi-copy.ts +30 -3
- package/templates/restaurant-owner/tier5-src/_shared/engine-intl.ts +18 -10
- package/templates/restaurant-owner/tier5-src/_shared/himi-copy.ts +30 -3
- package/templates/retail-store/dev/index.ts +263 -204
- package/templates/retail-store/l10n/en.json +2029 -0
- package/templates/retail-store/l10n/es.json +33 -0
- package/templates/retail-store/l10n/he.json +2660 -0
- package/templates/retail-store/tier5-src/_shared/engine-intl.ts +18 -10
- package/templates/retail-store/tier5-src/_shared/himi-account.ts +5 -4
- package/templates/retail-store/tier5-src/_shared/himi-copy.ts +30 -3
- package/templates/retail-store-owner/tier5-src/_shared/engine-intl.ts +18 -10
- package/templates/retail-store-owner/tier5-src/_shared/himi-copy.ts +30 -3
- package/templates/salon-spa/tier5-src/_shared/engine-intl.ts +18 -10
- package/templates/salon-spa/tier5-src/_shared/himi-account.ts +5 -4
- package/templates/salon-spa/tier5-src/_shared/himi-bookings.ts +1 -1
- package/templates/salon-spa/tier5-src/_shared/himi-copy.ts +30 -3
- package/templates/salon-spa/tier5-src/himi-booking-bookings/index.ts +2 -4
- package/templates/salon-spa/tier5-src/himi-booking-service/index.ts +2 -2
- package/templates/salon-spa/tier5-src/himi-booking-time/index.ts +1 -1
- package/templates/wholesale-store/tier5-src/_shared/engine-intl.ts +18 -10
- package/templates/wholesale-store/tier5-src/_shared/himi-account.ts +5 -4
- package/templates/wholesale-store/tier5-src/_shared/himi-copy.ts +30 -3
- package/templates/yoga-studio/l10n/en.json +2213 -0
- package/templates/yoga-studio/l10n/es.json +10 -0
- package/templates/yoga-studio/l10n/he.json +3405 -0
- package/templates/yoga-studio/tier5-src/_shared/engine-intl.ts +18 -10
- package/templates/yoga-studio/tier5-src/_shared/himi-account.ts +5 -4
- package/templates/yoga-studio/tier5-src/_shared/himi-bookings.ts +1 -1
- package/templates/yoga-studio/tier5-src/_shared/himi-copy.ts +30 -3
- package/templates/yoga-studio/tier5-src/himi-booking-bookings/index.ts +2 -4
- package/templates/yoga-studio/tier5-src/himi-booking-service/index.ts +2 -2
- package/templates/yoga-studio/tier5-src/himi-booking-time/index.ts +1 -1
- package/templates/yoga-studio-owner/tier5-src/_shared/engine-intl.ts +18 -10
- package/templates/yoga-studio-owner/tier5-src/_shared/himi-copy.ts +30 -3
|
@@ -87,7 +87,7 @@ function dateFormat(locale: string, options: Intl.DateTimeFormatOptions, timeZon
|
|
|
87
87
|
// ECMA-402 in engine-intl-fallback.test.ts.
|
|
88
88
|
|
|
89
89
|
/** `{ month: "short", day: "numeric", year: "numeric" }` — "Jan 5, 2026". */
|
|
90
|
-
export function formatDateMedium(date: Date, locale =
|
|
90
|
+
export function formatDateMedium(date: Date, locale = appLocale(), timeZone?: string): string {
|
|
91
91
|
if (hasIntl()) {
|
|
92
92
|
return dateFormat(locale, { month: "short", day: "numeric", year: "numeric" }, timeZone).format(date);
|
|
93
93
|
}
|
|
@@ -95,7 +95,7 @@ export function formatDateMedium(date: Date, locale = "en-US", timeZone?: string
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
/** `{ month: "short", day: "numeric" }` — "Jan 5". */
|
|
98
|
-
export function formatMonthDay(date: Date, locale =
|
|
98
|
+
export function formatMonthDay(date: Date, locale = appLocale(), timeZone?: string): string {
|
|
99
99
|
if (hasIntl()) {
|
|
100
100
|
return dateFormat(locale, { month: "short", day: "numeric" }, timeZone).format(date);
|
|
101
101
|
}
|
|
@@ -103,7 +103,7 @@ export function formatMonthDay(date: Date, locale = "en-US", timeZone?: string):
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
/** `{ month: "long", day: "numeric" }` — "January 5". */
|
|
106
|
-
export function formatMonthDayLong(date: Date, locale =
|
|
106
|
+
export function formatMonthDayLong(date: Date, locale = appLocale(), timeZone?: string): string {
|
|
107
107
|
if (hasIntl()) {
|
|
108
108
|
return dateFormat(locale, { month: "long", day: "numeric" }, timeZone).format(date);
|
|
109
109
|
}
|
|
@@ -113,7 +113,7 @@ export function formatMonthDayLong(date: Date, locale = "en-US", timeZone?: stri
|
|
|
113
113
|
const WEEKDAYS_LONG = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] as const;
|
|
114
114
|
|
|
115
115
|
/** `{ weekday: "short", month: "short", day: "numeric" }` — "Mon, Jan 5". */
|
|
116
|
-
export function formatWeekdayMonthDay(date: Date, locale =
|
|
116
|
+
export function formatWeekdayMonthDay(date: Date, locale = appLocale(), timeZone?: string): string {
|
|
117
117
|
if (hasIntl()) {
|
|
118
118
|
return dateFormat(locale, { weekday: "short", month: "short", day: "numeric" }, timeZone).format(date);
|
|
119
119
|
}
|
|
@@ -121,7 +121,7 @@ export function formatWeekdayMonthDay(date: Date, locale = "en-US", timeZone?: s
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
/** `{ weekday: "long", month: "long", day: "numeric" }` — "Monday, January 5". */
|
|
124
|
-
export function formatWeekdayMonthDayLong(date: Date, locale =
|
|
124
|
+
export function formatWeekdayMonthDayLong(date: Date, locale = appLocale(), timeZone?: string): string {
|
|
125
125
|
if (hasIntl()) {
|
|
126
126
|
return dateFormat(locale, { weekday: "long", month: "long", day: "numeric" }, timeZone).format(date);
|
|
127
127
|
}
|
|
@@ -130,7 +130,7 @@ export function formatWeekdayMonthDayLong(date: Date, locale = "en-US", timeZone
|
|
|
130
130
|
|
|
131
131
|
/** `{ weekday: "short", month: "short", day: "numeric", hour: "numeric", minute: "2-digit" }`
|
|
132
132
|
* — "Mon, Jan 5, 3:07 PM". */
|
|
133
|
-
export function formatWeekdayDateTime(date: Date, locale =
|
|
133
|
+
export function formatWeekdayDateTime(date: Date, locale = appLocale(), timeZone?: string): string {
|
|
134
134
|
if (hasIntl()) {
|
|
135
135
|
return dateFormat(locale, {
|
|
136
136
|
weekday: "short", month: "short", day: "numeric", hour: "numeric", minute: "2-digit",
|
|
@@ -140,7 +140,7 @@ export function formatWeekdayDateTime(date: Date, locale = "en-US", timeZone?: s
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
/** `{ month: "short", day: "numeric", hour: "numeric", minute: "2-digit" }` — "Jan 5, 3:07 PM". */
|
|
143
|
-
export function formatMonthDayTime(date: Date, locale =
|
|
143
|
+
export function formatMonthDayTime(date: Date, locale = appLocale(), timeZone?: string): string {
|
|
144
144
|
if (hasIntl()) {
|
|
145
145
|
return dateFormat(locale, {
|
|
146
146
|
month: "short", day: "numeric", hour: "numeric", minute: "2-digit",
|
|
@@ -154,7 +154,7 @@ export function formatMonthDayTime(date: Date, locale = "en-US", timeZone?: stri
|
|
|
154
154
|
* Falls back to the same SHAPE (not a different one) so a screen does not visibly change
|
|
155
155
|
* character between a phone and a watch.
|
|
156
156
|
*/
|
|
157
|
-
export function formatDateTimeMedium(date: Date, locale =
|
|
157
|
+
export function formatDateTimeMedium(date: Date, locale = appLocale()): string {
|
|
158
158
|
if (hasIntl()) {
|
|
159
159
|
return new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short" }).format(date);
|
|
160
160
|
}
|
|
@@ -439,16 +439,24 @@ function clockParts(d: Date, locale: string, timeZone?: string): { time: string;
|
|
|
439
439
|
: clock12(d);
|
|
440
440
|
// ICU puts a narrow no-break space before the meridiem; normalize so callers can split on it.
|
|
441
441
|
const clean = full.replace(/[ ]/g, " ");
|
|
442
|
-
const m = /^(.*?)\s*([AP]
|
|
442
|
+
const m = /^(.*?)\s*([AP]\.?\s?M\.?)$/i.exec(clean);
|
|
443
443
|
return m ? { time: m[1], meridiem: m[2] } : { time: clean, meridiem: "" };
|
|
444
444
|
}
|
|
445
445
|
|
|
446
446
|
/** "8:00 PM" — the one clock every customer screen uses (12-hour, en-US shape). */
|
|
447
|
-
export function formatClock(date: Date, locale =
|
|
447
|
+
export function formatClock(date: Date, locale = appLocale(), timeZone?: string): string {
|
|
448
448
|
const { time, meridiem } = clockParts(date, locale, timeZone);
|
|
449
449
|
return meridiem ? `${time} ${meridiem}` : time;
|
|
450
450
|
}
|
|
451
451
|
|
|
452
|
+
/** "10:00 – 11:15 AM" when both ends share the meridiem, "11:30 AM – 12:45 PM" otherwise. The meridiem is whatever the
|
|
453
|
+
* locale writes (`AM`, `p. m.`), so it is compared as a whole, never as the last word of the text. */
|
|
454
|
+
export function formatClockRange(start: Date, end: Date, locale = appLocale(), timeZone?: string): string {
|
|
455
|
+
const a = clockParts(start, locale, timeZone), b = clockParts(end, locale, timeZone);
|
|
456
|
+
if (a.meridiem && a.meridiem === b.meridiem) return `${a.time} – ${b.time} ${b.meridiem}`;
|
|
457
|
+
return `${formatClock(start, locale, timeZone)} – ${formatClock(end, locale, timeZone)}`;
|
|
458
|
+
}
|
|
459
|
+
|
|
452
460
|
/** Is this ISO instant before `now`? A missing or unparseable value is NOT past — "no expiry"
|
|
453
461
|
* must never classify an offer as expired. */
|
|
454
462
|
export function isPastDate(iso: string | undefined | null, now: number = Date.now()): boolean {
|
|
@@ -4,6 +4,7 @@ import { displayName, getMyData, initials, type WixMyData } from "@himalaya/wix-
|
|
|
4
4
|
import { getMyMember } from "@himalaya/wix-members";
|
|
5
5
|
import { wixMediaUrl } from "@himalaya/wix-media";
|
|
6
6
|
import { formatDateMedium, formatWeekdayDateTime } from "../_shared/engine-intl.js";
|
|
7
|
+
import { copyParam } from "./himi-copy.js";
|
|
7
8
|
|
|
8
9
|
export interface AccountProfile {
|
|
9
10
|
isMember: boolean;
|
|
@@ -73,7 +74,7 @@ function profileFromData(data: WixMyData, fallbackEmail = ""): AccountProfile {
|
|
|
73
74
|
const image = profileImage(data);
|
|
74
75
|
return {
|
|
75
76
|
isMember: true,
|
|
76
|
-
identityLine: "Signed in",
|
|
77
|
+
identityLine: copyParam("account.signedIn", "Signed in"),
|
|
77
78
|
detailLine: email || name,
|
|
78
79
|
memberName: name,
|
|
79
80
|
memberEmail: email,
|
|
@@ -95,7 +96,7 @@ async function siteMemberProfile(email: string): Promise<AccountProfile | undefi
|
|
|
95
96
|
const image = wixMediaUrl(member?.profile?.photo?.url) || wixMediaUrl(member?.profile?.photo?.id) || "";
|
|
96
97
|
return {
|
|
97
98
|
isMember: true,
|
|
98
|
-
identityLine: "Signed in",
|
|
99
|
+
identityLine: copyParam("account.signedIn", "Signed in"),
|
|
99
100
|
detailLine: email || name,
|
|
100
101
|
memberName: name,
|
|
101
102
|
memberEmail: email || member?.loginEmail || "",
|
|
@@ -112,7 +113,7 @@ async function siteMemberProfile(email: string): Promise<AccountProfile | undefi
|
|
|
112
113
|
export function guestProfile(detailLine: string): AccountProfile {
|
|
113
114
|
return {
|
|
114
115
|
isMember: false,
|
|
115
|
-
identityLine: "Browsing as a guest",
|
|
116
|
+
identityLine: copyParam("account.guestIdentity", "Browsing as a guest"),
|
|
116
117
|
detailLine,
|
|
117
118
|
memberName: "",
|
|
118
119
|
memberEmail: "",
|
|
@@ -151,7 +152,7 @@ export async function loadMemberProfile(guestDetailLine: string): Promise<Accoun
|
|
|
151
152
|
if (member) return member;
|
|
152
153
|
return {
|
|
153
154
|
isMember: true,
|
|
154
|
-
identityLine: "Signed in",
|
|
155
|
+
identityLine: copyParam("account.signedIn", "Signed in"),
|
|
155
156
|
detailLine: storedEmail,
|
|
156
157
|
memberName: storedEmail,
|
|
157
158
|
memberEmail: storedEmail,
|
|
@@ -23,6 +23,10 @@ import { isSingular, setAppLocale, setBusinessTimeZone } from "./app-locale.js";
|
|
|
23
23
|
export type CopyPackValue = string | { source: string; translation: string };
|
|
24
24
|
|
|
25
25
|
let stashedCopy: Record<string, CopyPackValue> = Object.create(null);
|
|
26
|
+
/** Stock translations by the English text they replace, from the `textCopy` param. A pinned app's bake
|
|
27
|
+
* names each worker fallback its catalog translates by its text, because a catalog row for worker copy
|
|
28
|
+
* is often keyless. A key's own `copy` entry always wins over this. */
|
|
29
|
+
let stashedByText = new Map<string, string>();
|
|
26
30
|
let copyReceived = false;
|
|
27
31
|
|
|
28
32
|
/** Absorb the `copy` onAppear param (customer strings or stock translation records)
|
|
@@ -37,6 +41,11 @@ export function stashCopy(arg: unknown): void {
|
|
|
37
41
|
setAppLocale((arg as Record<string, unknown>).locale);
|
|
38
42
|
setBusinessTimeZone((arg as Record<string, unknown>).businessTimeZone);
|
|
39
43
|
}
|
|
44
|
+
const text = (arg as Record<string, unknown>).textCopy;
|
|
45
|
+
if (typeof text === "string" && text) {
|
|
46
|
+
const parsed = parseTextCopy(text);
|
|
47
|
+
if (parsed) { stashedByText = parsed; copyReceived = true; }
|
|
48
|
+
}
|
|
40
49
|
const raw = (arg as Record<string, unknown>).copy;
|
|
41
50
|
if (typeof raw !== "string" || !raw) return;
|
|
42
51
|
try {
|
|
@@ -59,15 +68,33 @@ export function stashCopy(arg: unknown): void {
|
|
|
59
68
|
}
|
|
60
69
|
}
|
|
61
70
|
|
|
71
|
+
/** `textCopy`: a JSON object from English text to its translation. A malformed one is ignored (the
|
|
72
|
+
* stock copy keeps rendering); an entry that is not a non-empty string is dropped. */
|
|
73
|
+
function parseTextCopy(text: string): Map<string, string> | undefined {
|
|
74
|
+
try {
|
|
75
|
+
const parsed = JSON.parse(text) as unknown;
|
|
76
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return undefined;
|
|
77
|
+
const out = new Map<string, string>();
|
|
78
|
+
for (const [source, translation] of Object.entries(parsed as Record<string, unknown>)) {
|
|
79
|
+
if (typeof translation === "string" && translation !== "") out.set(source, translation);
|
|
80
|
+
}
|
|
81
|
+
return out;
|
|
82
|
+
} catch {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
62
87
|
/** The provisioned override for `key`, or `fallback` (the stock copy). An optional
|
|
63
88
|
* restored label survives only until a current copy pack arrives. */
|
|
64
89
|
export function copyParam(key: string, fallback: string, restoredFallback = fallback): string {
|
|
65
90
|
const value = stashedCopy[key];
|
|
66
91
|
// A disk-restored row may paint before onAppear supplies its copy pack. Keep its
|
|
67
92
|
// last label only before a pack arrives; even an empty current pack selects stock copy.
|
|
68
|
-
if (value === undefined) return copyReceived ? fallback : restoredFallback;
|
|
69
|
-
|
|
70
|
-
|
|
93
|
+
if (value === undefined) return stashedByText.get(fallback) ?? (copyReceived ? fallback : restoredFallback);
|
|
94
|
+
// A key can serve two messages: a row for another source text, or an empty one, must not hide the stock translation
|
|
95
|
+
// the app's catalog has for the fallback actually passed.
|
|
96
|
+
if (typeof value === "string") return value !== "" ? value : stashedByText.get(fallback) ?? fallback;
|
|
97
|
+
return value?.source === fallback && value.translation !== "" ? value.translation : stashedByText.get(fallback) ?? fallback;
|
|
71
98
|
}
|
|
72
99
|
|
|
73
100
|
/** Interpolate `{name}` placeholders in a (possibly overridden) template:
|
|
@@ -87,7 +87,7 @@ function dateFormat(locale: string, options: Intl.DateTimeFormatOptions, timeZon
|
|
|
87
87
|
// ECMA-402 in engine-intl-fallback.test.ts.
|
|
88
88
|
|
|
89
89
|
/** `{ month: "short", day: "numeric", year: "numeric" }` — "Jan 5, 2026". */
|
|
90
|
-
export function formatDateMedium(date: Date, locale =
|
|
90
|
+
export function formatDateMedium(date: Date, locale = appLocale(), timeZone?: string): string {
|
|
91
91
|
if (hasIntl()) {
|
|
92
92
|
return dateFormat(locale, { month: "short", day: "numeric", year: "numeric" }, timeZone).format(date);
|
|
93
93
|
}
|
|
@@ -95,7 +95,7 @@ export function formatDateMedium(date: Date, locale = "en-US", timeZone?: string
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
/** `{ month: "short", day: "numeric" }` — "Jan 5". */
|
|
98
|
-
export function formatMonthDay(date: Date, locale =
|
|
98
|
+
export function formatMonthDay(date: Date, locale = appLocale(), timeZone?: string): string {
|
|
99
99
|
if (hasIntl()) {
|
|
100
100
|
return dateFormat(locale, { month: "short", day: "numeric" }, timeZone).format(date);
|
|
101
101
|
}
|
|
@@ -103,7 +103,7 @@ export function formatMonthDay(date: Date, locale = "en-US", timeZone?: string):
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
/** `{ month: "long", day: "numeric" }` — "January 5". */
|
|
106
|
-
export function formatMonthDayLong(date: Date, locale =
|
|
106
|
+
export function formatMonthDayLong(date: Date, locale = appLocale(), timeZone?: string): string {
|
|
107
107
|
if (hasIntl()) {
|
|
108
108
|
return dateFormat(locale, { month: "long", day: "numeric" }, timeZone).format(date);
|
|
109
109
|
}
|
|
@@ -113,7 +113,7 @@ export function formatMonthDayLong(date: Date, locale = "en-US", timeZone?: stri
|
|
|
113
113
|
const WEEKDAYS_LONG = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] as const;
|
|
114
114
|
|
|
115
115
|
/** `{ weekday: "short", month: "short", day: "numeric" }` — "Mon, Jan 5". */
|
|
116
|
-
export function formatWeekdayMonthDay(date: Date, locale =
|
|
116
|
+
export function formatWeekdayMonthDay(date: Date, locale = appLocale(), timeZone?: string): string {
|
|
117
117
|
if (hasIntl()) {
|
|
118
118
|
return dateFormat(locale, { weekday: "short", month: "short", day: "numeric" }, timeZone).format(date);
|
|
119
119
|
}
|
|
@@ -121,7 +121,7 @@ export function formatWeekdayMonthDay(date: Date, locale = "en-US", timeZone?: s
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
/** `{ weekday: "long", month: "long", day: "numeric" }` — "Monday, January 5". */
|
|
124
|
-
export function formatWeekdayMonthDayLong(date: Date, locale =
|
|
124
|
+
export function formatWeekdayMonthDayLong(date: Date, locale = appLocale(), timeZone?: string): string {
|
|
125
125
|
if (hasIntl()) {
|
|
126
126
|
return dateFormat(locale, { weekday: "long", month: "long", day: "numeric" }, timeZone).format(date);
|
|
127
127
|
}
|
|
@@ -130,7 +130,7 @@ export function formatWeekdayMonthDayLong(date: Date, locale = "en-US", timeZone
|
|
|
130
130
|
|
|
131
131
|
/** `{ weekday: "short", month: "short", day: "numeric", hour: "numeric", minute: "2-digit" }`
|
|
132
132
|
* — "Mon, Jan 5, 3:07 PM". */
|
|
133
|
-
export function formatWeekdayDateTime(date: Date, locale =
|
|
133
|
+
export function formatWeekdayDateTime(date: Date, locale = appLocale(), timeZone?: string): string {
|
|
134
134
|
if (hasIntl()) {
|
|
135
135
|
return dateFormat(locale, {
|
|
136
136
|
weekday: "short", month: "short", day: "numeric", hour: "numeric", minute: "2-digit",
|
|
@@ -140,7 +140,7 @@ export function formatWeekdayDateTime(date: Date, locale = "en-US", timeZone?: s
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
/** `{ month: "short", day: "numeric", hour: "numeric", minute: "2-digit" }` — "Jan 5, 3:07 PM". */
|
|
143
|
-
export function formatMonthDayTime(date: Date, locale =
|
|
143
|
+
export function formatMonthDayTime(date: Date, locale = appLocale(), timeZone?: string): string {
|
|
144
144
|
if (hasIntl()) {
|
|
145
145
|
return dateFormat(locale, {
|
|
146
146
|
month: "short", day: "numeric", hour: "numeric", minute: "2-digit",
|
|
@@ -154,7 +154,7 @@ export function formatMonthDayTime(date: Date, locale = "en-US", timeZone?: stri
|
|
|
154
154
|
* Falls back to the same SHAPE (not a different one) so a screen does not visibly change
|
|
155
155
|
* character between a phone and a watch.
|
|
156
156
|
*/
|
|
157
|
-
export function formatDateTimeMedium(date: Date, locale =
|
|
157
|
+
export function formatDateTimeMedium(date: Date, locale = appLocale()): string {
|
|
158
158
|
if (hasIntl()) {
|
|
159
159
|
return new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short" }).format(date);
|
|
160
160
|
}
|
|
@@ -439,16 +439,24 @@ function clockParts(d: Date, locale: string, timeZone?: string): { time: string;
|
|
|
439
439
|
: clock12(d);
|
|
440
440
|
// ICU puts a narrow no-break space before the meridiem; normalize so callers can split on it.
|
|
441
441
|
const clean = full.replace(/[ ]/g, " ");
|
|
442
|
-
const m = /^(.*?)\s*([AP]
|
|
442
|
+
const m = /^(.*?)\s*([AP]\.?\s?M\.?)$/i.exec(clean);
|
|
443
443
|
return m ? { time: m[1], meridiem: m[2] } : { time: clean, meridiem: "" };
|
|
444
444
|
}
|
|
445
445
|
|
|
446
446
|
/** "8:00 PM" — the one clock every customer screen uses (12-hour, en-US shape). */
|
|
447
|
-
export function formatClock(date: Date, locale =
|
|
447
|
+
export function formatClock(date: Date, locale = appLocale(), timeZone?: string): string {
|
|
448
448
|
const { time, meridiem } = clockParts(date, locale, timeZone);
|
|
449
449
|
return meridiem ? `${time} ${meridiem}` : time;
|
|
450
450
|
}
|
|
451
451
|
|
|
452
|
+
/** "10:00 – 11:15 AM" when both ends share the meridiem, "11:30 AM – 12:45 PM" otherwise. The meridiem is whatever the
|
|
453
|
+
* locale writes (`AM`, `p. m.`), so it is compared as a whole, never as the last word of the text. */
|
|
454
|
+
export function formatClockRange(start: Date, end: Date, locale = appLocale(), timeZone?: string): string {
|
|
455
|
+
const a = clockParts(start, locale, timeZone), b = clockParts(end, locale, timeZone);
|
|
456
|
+
if (a.meridiem && a.meridiem === b.meridiem) return `${a.time} – ${b.time} ${b.meridiem}`;
|
|
457
|
+
return `${formatClock(start, locale, timeZone)} – ${formatClock(end, locale, timeZone)}`;
|
|
458
|
+
}
|
|
459
|
+
|
|
452
460
|
/** Is this ISO instant before `now`? A missing or unparseable value is NOT past — "no expiry"
|
|
453
461
|
* must never classify an offer as expired. */
|
|
454
462
|
export function isPastDate(iso: string | undefined | null, now: number = Date.now()): boolean {
|
|
@@ -23,6 +23,10 @@ import { isSingular, setAppLocale, setBusinessTimeZone } from "./app-locale.js";
|
|
|
23
23
|
export type CopyPackValue = string | { source: string; translation: string };
|
|
24
24
|
|
|
25
25
|
let stashedCopy: Record<string, CopyPackValue> = Object.create(null);
|
|
26
|
+
/** Stock translations by the English text they replace, from the `textCopy` param. A pinned app's bake
|
|
27
|
+
* names each worker fallback its catalog translates by its text, because a catalog row for worker copy
|
|
28
|
+
* is often keyless. A key's own `copy` entry always wins over this. */
|
|
29
|
+
let stashedByText = new Map<string, string>();
|
|
26
30
|
let copyReceived = false;
|
|
27
31
|
|
|
28
32
|
/** Absorb the `copy` onAppear param (customer strings or stock translation records)
|
|
@@ -37,6 +41,11 @@ export function stashCopy(arg: unknown): void {
|
|
|
37
41
|
setAppLocale((arg as Record<string, unknown>).locale);
|
|
38
42
|
setBusinessTimeZone((arg as Record<string, unknown>).businessTimeZone);
|
|
39
43
|
}
|
|
44
|
+
const text = (arg as Record<string, unknown>).textCopy;
|
|
45
|
+
if (typeof text === "string" && text) {
|
|
46
|
+
const parsed = parseTextCopy(text);
|
|
47
|
+
if (parsed) { stashedByText = parsed; copyReceived = true; }
|
|
48
|
+
}
|
|
40
49
|
const raw = (arg as Record<string, unknown>).copy;
|
|
41
50
|
if (typeof raw !== "string" || !raw) return;
|
|
42
51
|
try {
|
|
@@ -59,15 +68,33 @@ export function stashCopy(arg: unknown): void {
|
|
|
59
68
|
}
|
|
60
69
|
}
|
|
61
70
|
|
|
71
|
+
/** `textCopy`: a JSON object from English text to its translation. A malformed one is ignored (the
|
|
72
|
+
* stock copy keeps rendering); an entry that is not a non-empty string is dropped. */
|
|
73
|
+
function parseTextCopy(text: string): Map<string, string> | undefined {
|
|
74
|
+
try {
|
|
75
|
+
const parsed = JSON.parse(text) as unknown;
|
|
76
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return undefined;
|
|
77
|
+
const out = new Map<string, string>();
|
|
78
|
+
for (const [source, translation] of Object.entries(parsed as Record<string, unknown>)) {
|
|
79
|
+
if (typeof translation === "string" && translation !== "") out.set(source, translation);
|
|
80
|
+
}
|
|
81
|
+
return out;
|
|
82
|
+
} catch {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
62
87
|
/** The provisioned override for `key`, or `fallback` (the stock copy). An optional
|
|
63
88
|
* restored label survives only until a current copy pack arrives. */
|
|
64
89
|
export function copyParam(key: string, fallback: string, restoredFallback = fallback): string {
|
|
65
90
|
const value = stashedCopy[key];
|
|
66
91
|
// A disk-restored row may paint before onAppear supplies its copy pack. Keep its
|
|
67
92
|
// last label only before a pack arrives; even an empty current pack selects stock copy.
|
|
68
|
-
if (value === undefined) return copyReceived ? fallback : restoredFallback;
|
|
69
|
-
|
|
70
|
-
|
|
93
|
+
if (value === undefined) return stashedByText.get(fallback) ?? (copyReceived ? fallback : restoredFallback);
|
|
94
|
+
// A key can serve two messages: a row for another source text, or an empty one, must not hide the stock translation
|
|
95
|
+
// the app's catalog has for the fallback actually passed.
|
|
96
|
+
if (typeof value === "string") return value !== "" ? value : stashedByText.get(fallback) ?? fallback;
|
|
97
|
+
return value?.source === fallback && value.translation !== "" ? value.translation : stashedByText.get(fallback) ?? fallback;
|
|
71
98
|
}
|
|
72
99
|
|
|
73
100
|
/** Interpolate `{name}` placeholders in a (possibly overridden) template:
|
|
@@ -87,7 +87,7 @@ function dateFormat(locale: string, options: Intl.DateTimeFormatOptions, timeZon
|
|
|
87
87
|
// ECMA-402 in engine-intl-fallback.test.ts.
|
|
88
88
|
|
|
89
89
|
/** `{ month: "short", day: "numeric", year: "numeric" }` — "Jan 5, 2026". */
|
|
90
|
-
export function formatDateMedium(date: Date, locale =
|
|
90
|
+
export function formatDateMedium(date: Date, locale = appLocale(), timeZone?: string): string {
|
|
91
91
|
if (hasIntl()) {
|
|
92
92
|
return dateFormat(locale, { month: "short", day: "numeric", year: "numeric" }, timeZone).format(date);
|
|
93
93
|
}
|
|
@@ -95,7 +95,7 @@ export function formatDateMedium(date: Date, locale = "en-US", timeZone?: string
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
/** `{ month: "short", day: "numeric" }` — "Jan 5". */
|
|
98
|
-
export function formatMonthDay(date: Date, locale =
|
|
98
|
+
export function formatMonthDay(date: Date, locale = appLocale(), timeZone?: string): string {
|
|
99
99
|
if (hasIntl()) {
|
|
100
100
|
return dateFormat(locale, { month: "short", day: "numeric" }, timeZone).format(date);
|
|
101
101
|
}
|
|
@@ -103,7 +103,7 @@ export function formatMonthDay(date: Date, locale = "en-US", timeZone?: string):
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
/** `{ month: "long", day: "numeric" }` — "January 5". */
|
|
106
|
-
export function formatMonthDayLong(date: Date, locale =
|
|
106
|
+
export function formatMonthDayLong(date: Date, locale = appLocale(), timeZone?: string): string {
|
|
107
107
|
if (hasIntl()) {
|
|
108
108
|
return dateFormat(locale, { month: "long", day: "numeric" }, timeZone).format(date);
|
|
109
109
|
}
|
|
@@ -113,7 +113,7 @@ export function formatMonthDayLong(date: Date, locale = "en-US", timeZone?: stri
|
|
|
113
113
|
const WEEKDAYS_LONG = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] as const;
|
|
114
114
|
|
|
115
115
|
/** `{ weekday: "short", month: "short", day: "numeric" }` — "Mon, Jan 5". */
|
|
116
|
-
export function formatWeekdayMonthDay(date: Date, locale =
|
|
116
|
+
export function formatWeekdayMonthDay(date: Date, locale = appLocale(), timeZone?: string): string {
|
|
117
117
|
if (hasIntl()) {
|
|
118
118
|
return dateFormat(locale, { weekday: "short", month: "short", day: "numeric" }, timeZone).format(date);
|
|
119
119
|
}
|
|
@@ -121,7 +121,7 @@ export function formatWeekdayMonthDay(date: Date, locale = "en-US", timeZone?: s
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
/** `{ weekday: "long", month: "long", day: "numeric" }` — "Monday, January 5". */
|
|
124
|
-
export function formatWeekdayMonthDayLong(date: Date, locale =
|
|
124
|
+
export function formatWeekdayMonthDayLong(date: Date, locale = appLocale(), timeZone?: string): string {
|
|
125
125
|
if (hasIntl()) {
|
|
126
126
|
return dateFormat(locale, { weekday: "long", month: "long", day: "numeric" }, timeZone).format(date);
|
|
127
127
|
}
|
|
@@ -130,7 +130,7 @@ export function formatWeekdayMonthDayLong(date: Date, locale = "en-US", timeZone
|
|
|
130
130
|
|
|
131
131
|
/** `{ weekday: "short", month: "short", day: "numeric", hour: "numeric", minute: "2-digit" }`
|
|
132
132
|
* — "Mon, Jan 5, 3:07 PM". */
|
|
133
|
-
export function formatWeekdayDateTime(date: Date, locale =
|
|
133
|
+
export function formatWeekdayDateTime(date: Date, locale = appLocale(), timeZone?: string): string {
|
|
134
134
|
if (hasIntl()) {
|
|
135
135
|
return dateFormat(locale, {
|
|
136
136
|
weekday: "short", month: "short", day: "numeric", hour: "numeric", minute: "2-digit",
|
|
@@ -140,7 +140,7 @@ export function formatWeekdayDateTime(date: Date, locale = "en-US", timeZone?: s
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
/** `{ month: "short", day: "numeric", hour: "numeric", minute: "2-digit" }` — "Jan 5, 3:07 PM". */
|
|
143
|
-
export function formatMonthDayTime(date: Date, locale =
|
|
143
|
+
export function formatMonthDayTime(date: Date, locale = appLocale(), timeZone?: string): string {
|
|
144
144
|
if (hasIntl()) {
|
|
145
145
|
return dateFormat(locale, {
|
|
146
146
|
month: "short", day: "numeric", hour: "numeric", minute: "2-digit",
|
|
@@ -154,7 +154,7 @@ export function formatMonthDayTime(date: Date, locale = "en-US", timeZone?: stri
|
|
|
154
154
|
* Falls back to the same SHAPE (not a different one) so a screen does not visibly change
|
|
155
155
|
* character between a phone and a watch.
|
|
156
156
|
*/
|
|
157
|
-
export function formatDateTimeMedium(date: Date, locale =
|
|
157
|
+
export function formatDateTimeMedium(date: Date, locale = appLocale()): string {
|
|
158
158
|
if (hasIntl()) {
|
|
159
159
|
return new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short" }).format(date);
|
|
160
160
|
}
|
|
@@ -439,16 +439,24 @@ function clockParts(d: Date, locale: string, timeZone?: string): { time: string;
|
|
|
439
439
|
: clock12(d);
|
|
440
440
|
// ICU puts a narrow no-break space before the meridiem; normalize so callers can split on it.
|
|
441
441
|
const clean = full.replace(/[ ]/g, " ");
|
|
442
|
-
const m = /^(.*?)\s*([AP]
|
|
442
|
+
const m = /^(.*?)\s*([AP]\.?\s?M\.?)$/i.exec(clean);
|
|
443
443
|
return m ? { time: m[1], meridiem: m[2] } : { time: clean, meridiem: "" };
|
|
444
444
|
}
|
|
445
445
|
|
|
446
446
|
/** "8:00 PM" — the one clock every customer screen uses (12-hour, en-US shape). */
|
|
447
|
-
export function formatClock(date: Date, locale =
|
|
447
|
+
export function formatClock(date: Date, locale = appLocale(), timeZone?: string): string {
|
|
448
448
|
const { time, meridiem } = clockParts(date, locale, timeZone);
|
|
449
449
|
return meridiem ? `${time} ${meridiem}` : time;
|
|
450
450
|
}
|
|
451
451
|
|
|
452
|
+
/** "10:00 – 11:15 AM" when both ends share the meridiem, "11:30 AM – 12:45 PM" otherwise. The meridiem is whatever the
|
|
453
|
+
* locale writes (`AM`, `p. m.`), so it is compared as a whole, never as the last word of the text. */
|
|
454
|
+
export function formatClockRange(start: Date, end: Date, locale = appLocale(), timeZone?: string): string {
|
|
455
|
+
const a = clockParts(start, locale, timeZone), b = clockParts(end, locale, timeZone);
|
|
456
|
+
if (a.meridiem && a.meridiem === b.meridiem) return `${a.time} – ${b.time} ${b.meridiem}`;
|
|
457
|
+
return `${formatClock(start, locale, timeZone)} – ${formatClock(end, locale, timeZone)}`;
|
|
458
|
+
}
|
|
459
|
+
|
|
452
460
|
/** Is this ISO instant before `now`? A missing or unparseable value is NOT past — "no expiry"
|
|
453
461
|
* must never classify an offer as expired. */
|
|
454
462
|
export function isPastDate(iso: string | undefined | null, now: number = Date.now()): boolean {
|
|
@@ -23,6 +23,10 @@ import { isSingular, setAppLocale, setBusinessTimeZone } from "./app-locale.js";
|
|
|
23
23
|
export type CopyPackValue = string | { source: string; translation: string };
|
|
24
24
|
|
|
25
25
|
let stashedCopy: Record<string, CopyPackValue> = Object.create(null);
|
|
26
|
+
/** Stock translations by the English text they replace, from the `textCopy` param. A pinned app's bake
|
|
27
|
+
* names each worker fallback its catalog translates by its text, because a catalog row for worker copy
|
|
28
|
+
* is often keyless. A key's own `copy` entry always wins over this. */
|
|
29
|
+
let stashedByText = new Map<string, string>();
|
|
26
30
|
let copyReceived = false;
|
|
27
31
|
|
|
28
32
|
/** Absorb the `copy` onAppear param (customer strings or stock translation records)
|
|
@@ -37,6 +41,11 @@ export function stashCopy(arg: unknown): void {
|
|
|
37
41
|
setAppLocale((arg as Record<string, unknown>).locale);
|
|
38
42
|
setBusinessTimeZone((arg as Record<string, unknown>).businessTimeZone);
|
|
39
43
|
}
|
|
44
|
+
const text = (arg as Record<string, unknown>).textCopy;
|
|
45
|
+
if (typeof text === "string" && text) {
|
|
46
|
+
const parsed = parseTextCopy(text);
|
|
47
|
+
if (parsed) { stashedByText = parsed; copyReceived = true; }
|
|
48
|
+
}
|
|
40
49
|
const raw = (arg as Record<string, unknown>).copy;
|
|
41
50
|
if (typeof raw !== "string" || !raw) return;
|
|
42
51
|
try {
|
|
@@ -59,15 +68,33 @@ export function stashCopy(arg: unknown): void {
|
|
|
59
68
|
}
|
|
60
69
|
}
|
|
61
70
|
|
|
71
|
+
/** `textCopy`: a JSON object from English text to its translation. A malformed one is ignored (the
|
|
72
|
+
* stock copy keeps rendering); an entry that is not a non-empty string is dropped. */
|
|
73
|
+
function parseTextCopy(text: string): Map<string, string> | undefined {
|
|
74
|
+
try {
|
|
75
|
+
const parsed = JSON.parse(text) as unknown;
|
|
76
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return undefined;
|
|
77
|
+
const out = new Map<string, string>();
|
|
78
|
+
for (const [source, translation] of Object.entries(parsed as Record<string, unknown>)) {
|
|
79
|
+
if (typeof translation === "string" && translation !== "") out.set(source, translation);
|
|
80
|
+
}
|
|
81
|
+
return out;
|
|
82
|
+
} catch {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
62
87
|
/** The provisioned override for `key`, or `fallback` (the stock copy). An optional
|
|
63
88
|
* restored label survives only until a current copy pack arrives. */
|
|
64
89
|
export function copyParam(key: string, fallback: string, restoredFallback = fallback): string {
|
|
65
90
|
const value = stashedCopy[key];
|
|
66
91
|
// A disk-restored row may paint before onAppear supplies its copy pack. Keep its
|
|
67
92
|
// last label only before a pack arrives; even an empty current pack selects stock copy.
|
|
68
|
-
if (value === undefined) return copyReceived ? fallback : restoredFallback;
|
|
69
|
-
|
|
70
|
-
|
|
93
|
+
if (value === undefined) return stashedByText.get(fallback) ?? (copyReceived ? fallback : restoredFallback);
|
|
94
|
+
// A key can serve two messages: a row for another source text, or an empty one, must not hide the stock translation
|
|
95
|
+
// the app's catalog has for the fallback actually passed.
|
|
96
|
+
if (typeof value === "string") return value !== "" ? value : stashedByText.get(fallback) ?? fallback;
|
|
97
|
+
return value?.source === fallback && value.translation !== "" ? value.translation : stashedByText.get(fallback) ?? fallback;
|
|
71
98
|
}
|
|
72
99
|
|
|
73
100
|
/** Interpolate `{name}` placeholders in a (possibly overridden) template:
|