@wix/himalaya-cli 0.1589.0 → 0.1591.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/sdk/wix-platform/src/index.d.ts +9 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/members-v1/src/index.d.ts +9 -5
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-members.mjs +9 -8
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-platform.mjs +2 -0
- package/dist/cli.mjs +90 -48
- package/dist/preview-assets.generated.bin +0 -0
- package/guides/one-app-to-himi-app.md +18 -4
- package/guides/sdk-reference.json +14 -2
- package/guides/tier-5-add-a-screen.md +48 -0
- package/package.json +2 -2
- package/templates/beauty-salon/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/beauty-salon/tier5-src/_shared/engine-intl.ts +5 -3
- package/templates/beauty-salon/tier5-src/_shared/group-member-count.ts +15 -0
- package/templates/beauty-salon/tier5-src/_shared/himi-bookings.ts +54 -13
- package/templates/beauty-salon/tier5-src/_shared/himi-copy.ts +10 -2
- package/templates/beauty-salon/tier5-src/_shared/himi-restaurants.ts +2 -2
- package/templates/beauty-salon/tier5-src/_shared/restaurant-ordering.ts +1 -1
- package/templates/beauty-salon/tier5-src/_shared/wix-service-price.ts +2 -2
- package/templates/beauty-salon/tier5-src/himi-booking-services/index.ts +8 -3
- package/templates/beauty-salon/tier5-src/himi-branded-lite-cart/index.ts +1 -1
- package/templates/beauty-salon/tier5-src/himi-branded-lite-home/index.ts +2 -1
- package/templates/beauty-salon/tier5-src/himi-branded-lite-plans/index.ts +1 -1
- package/templates/beauty-salon-owner/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/beauty-salon-owner/tier5-src/_shared/engine-intl.ts +5 -3
- package/templates/beauty-salon-owner/tier5-src/_shared/himi-copy.ts +10 -2
- package/templates/branded-lite/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/branded-lite/tier5-src/_shared/engine-intl.ts +5 -3
- package/templates/branded-lite/tier5-src/_shared/group-member-count.ts +15 -0
- package/templates/branded-lite/tier5-src/_shared/himi-bookings.ts +54 -13
- package/templates/branded-lite/tier5-src/_shared/himi-copy.ts +10 -2
- package/templates/branded-lite/tier5-src/_shared/himi-restaurants.ts +2 -2
- package/templates/branded-lite/tier5-src/_shared/restaurant-ordering.ts +1 -1
- package/templates/branded-lite/tier5-src/_shared/wix-service-price.ts +2 -2
- package/templates/branded-lite/tier5-src/himi-booking-services/index.ts +8 -3
- package/templates/branded-lite/tier5-src/himi-branded-lite-cart/index.ts +1 -1
- package/templates/branded-lite/tier5-src/himi-branded-lite-group/index.ts +9 -3
- package/templates/branded-lite/tier5-src/himi-branded-lite-group-about/index.ts +2 -1
- package/templates/branded-lite/tier5-src/himi-branded-lite-groups/index.ts +6 -2
- package/templates/branded-lite/tier5-src/himi-branded-lite-home/index.ts +2 -1
- package/templates/branded-lite/tier5-src/himi-branded-lite-loyalty/index.ts +3 -2
- package/templates/branded-lite/tier5-src/himi-branded-lite-my-groups/index.ts +2 -1
- package/templates/branded-lite/tier5-src/himi-branded-lite-plans/index.ts +1 -1
- package/templates/branded-lite/tier5-src/himi-branded-lite-program/index.ts +1 -1
- package/templates/branded-lite/tier5-src/himi-events-detail/index.ts +5 -5
- package/templates/branded-lite/tier5-src/wix-spaces-member-detail/index.ts +5 -1
- package/templates/brandy/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/brandy/tier5-src/_shared/himi-copy.ts +10 -2
- package/templates/community-club/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/community-club/tier5-src/_shared/engine-intl.ts +5 -3
- package/templates/community-club/tier5-src/_shared/group-member-count.ts +15 -0
- package/templates/community-club/tier5-src/_shared/himi-copy.ts +10 -2
- package/templates/community-club/tier5-src/_shared/himi-restaurants.ts +2 -2
- package/templates/community-club/tier5-src/_shared/wix-service-price.ts +2 -2
- package/templates/community-club/tier5-src/himi-branded-lite-group/index.ts +9 -3
- package/templates/community-club/tier5-src/himi-branded-lite-group-about/index.ts +2 -1
- package/templates/community-club/tier5-src/himi-branded-lite-groups/index.ts +6 -2
- package/templates/community-club/tier5-src/himi-branded-lite-home/index.ts +2 -1
- package/templates/community-club/tier5-src/himi-branded-lite-my-groups/index.ts +2 -1
- package/templates/community-club/tier5-src/himi-events-detail/index.ts +5 -5
- package/templates/community-club-owner/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/community-club-owner/tier5-src/_shared/engine-intl.ts +5 -3
- package/templates/community-club-owner/tier5-src/_shared/himi-copy.ts +10 -2
- package/templates/events-meetups/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/events-meetups/tier5-src/_shared/engine-intl.ts +5 -3
- package/templates/events-meetups/tier5-src/_shared/group-member-count.ts +15 -0
- package/templates/events-meetups/tier5-src/_shared/himi-copy.ts +10 -2
- package/templates/events-meetups/tier5-src/_shared/himi-restaurants.ts +2 -2
- package/templates/events-meetups/tier5-src/_shared/wix-service-price.ts +2 -2
- package/templates/events-meetups/tier5-src/himi-branded-lite-group/index.ts +9 -3
- package/templates/events-meetups/tier5-src/himi-branded-lite-group-about/index.ts +2 -1
- package/templates/events-meetups/tier5-src/himi-branded-lite-groups/index.ts +6 -2
- package/templates/events-meetups/tier5-src/himi-branded-lite-home/index.ts +2 -1
- package/templates/events-meetups/tier5-src/himi-branded-lite-my-groups/index.ts +2 -1
- package/templates/events-meetups/tier5-src/himi-events-detail/index.ts +5 -5
- package/templates/events-meetups-owner/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/events-meetups-owner/tier5-src/_shared/engine-intl.ts +5 -3
- package/templates/events-meetups-owner/tier5-src/_shared/himi-copy.ts +10 -2
- package/templates/gym-fitness/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/gym-fitness/tier5-src/_shared/engine-intl.ts +5 -3
- package/templates/gym-fitness/tier5-src/_shared/group-member-count.ts +15 -0
- package/templates/gym-fitness/tier5-src/_shared/himi-bookings.ts +54 -13
- package/templates/gym-fitness/tier5-src/_shared/himi-copy.ts +10 -2
- package/templates/gym-fitness/tier5-src/_shared/himi-restaurants.ts +2 -2
- package/templates/gym-fitness/tier5-src/_shared/restaurant-ordering.ts +1 -1
- package/templates/gym-fitness/tier5-src/_shared/wix-service-price.ts +2 -2
- package/templates/gym-fitness/tier5-src/himi-booking-services/index.ts +8 -3
- package/templates/gym-fitness/tier5-src/himi-branded-lite-cart/index.ts +1 -1
- package/templates/gym-fitness/tier5-src/himi-branded-lite-home/index.ts +2 -1
- package/templates/gym-fitness/tier5-src/himi-branded-lite-plans/index.ts +1 -1
- package/templates/gym-fitness/tier5-src/himi-events-detail/index.ts +5 -5
- package/templates/gym-fitness-owner/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/gym-fitness-owner/tier5-src/_shared/engine-intl.ts +5 -3
- package/templates/gym-fitness-owner/tier5-src/_shared/himi-copy.ts +10 -2
- package/templates/himi-chat/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/himi-chat/tier5-src/_shared/himi-copy.ts +10 -2
- package/templates/nonprofit-cause/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/nonprofit-cause/tier5-src/_shared/engine-intl.ts +5 -3
- package/templates/nonprofit-cause/tier5-src/_shared/group-member-count.ts +15 -0
- package/templates/nonprofit-cause/tier5-src/_shared/himi-copy.ts +10 -2
- package/templates/nonprofit-cause/tier5-src/_shared/himi-restaurants.ts +2 -2
- package/templates/nonprofit-cause/tier5-src/_shared/wix-service-price.ts +2 -2
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-group/index.ts +9 -3
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-group-about/index.ts +2 -1
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-groups/index.ts +6 -2
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-home/index.ts +2 -1
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-my-groups/index.ts +2 -1
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-plans/index.ts +1 -1
- package/templates/nonprofit-cause/tier5-src/himi-events-detail/index.ts +5 -5
- package/templates/nonprofit-cause-owner/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/nonprofit-cause-owner/tier5-src/_shared/engine-intl.ts +5 -3
- package/templates/nonprofit-cause-owner/tier5-src/_shared/himi-copy.ts +10 -2
- package/templates/owner-lite/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/owner-lite/tier5-src/_shared/engine-intl.ts +5 -3
- package/templates/owner-lite/tier5-src/_shared/himi-copy.ts +10 -2
- package/templates/podcast-creator/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/podcast-creator/tier5-src/_shared/engine-intl.ts +5 -3
- package/templates/podcast-creator/tier5-src/_shared/group-member-count.ts +15 -0
- package/templates/podcast-creator/tier5-src/_shared/himi-copy.ts +10 -2
- package/templates/podcast-creator/tier5-src/_shared/himi-restaurants.ts +2 -2
- package/templates/podcast-creator/tier5-src/_shared/wix-service-price.ts +2 -2
- package/templates/podcast-creator/tier5-src/himi-branded-lite-home/index.ts +2 -1
- package/templates/podcast-creator/tier5-src/himi-branded-lite-plans/index.ts +1 -1
- package/templates/podcast-creator/tier5-src/himi-events-detail/index.ts +5 -5
- package/templates/podcast-creator-owner/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/podcast-creator-owner/tier5-src/_shared/engine-intl.ts +5 -3
- package/templates/podcast-creator-owner/tier5-src/_shared/himi-copy.ts +10 -2
- package/templates/portfolio-creative/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/portfolio-creative/tier5-src/_shared/engine-intl.ts +5 -3
- package/templates/portfolio-creative/tier5-src/_shared/group-member-count.ts +15 -0
- package/templates/portfolio-creative/tier5-src/_shared/himi-copy.ts +10 -2
- package/templates/portfolio-creative/tier5-src/_shared/himi-restaurants.ts +2 -2
- package/templates/portfolio-creative/tier5-src/_shared/restaurant-ordering.ts +1 -1
- package/templates/portfolio-creative/tier5-src/_shared/wix-service-price.ts +2 -2
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-cart/index.ts +1 -1
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-home/index.ts +2 -1
- package/templates/portfolio-creative/tier5-src/himi-events-detail/index.ts +5 -5
- package/templates/portfolio-creative-owner/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/portfolio-creative-owner/tier5-src/_shared/engine-intl.ts +5 -3
- package/templates/portfolio-creative-owner/tier5-src/_shared/himi-copy.ts +10 -2
- package/templates/restaurant/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/restaurant/tier5-src/_shared/engine-intl.ts +5 -3
- package/templates/restaurant/tier5-src/_shared/group-member-count.ts +15 -0
- package/templates/restaurant/tier5-src/_shared/himi-copy.ts +10 -2
- package/templates/restaurant/tier5-src/_shared/himi-restaurants.ts +2 -2
- package/templates/restaurant/tier5-src/_shared/restaurant-ordering.ts +1 -1
- package/templates/restaurant/tier5-src/_shared/wix-service-price.ts +2 -2
- package/templates/restaurant/tier5-src/himi-branded-lite-home/index.ts +2 -1
- package/templates/restaurant/tier5-src/himi-events-detail/index.ts +5 -5
- package/templates/restaurant-owner/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/restaurant-owner/tier5-src/_shared/engine-intl.ts +5 -3
- package/templates/restaurant-owner/tier5-src/_shared/himi-copy.ts +10 -2
- package/templates/retail-store/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/retail-store/tier5-src/_shared/engine-intl.ts +5 -3
- package/templates/retail-store/tier5-src/_shared/group-member-count.ts +15 -0
- package/templates/retail-store/tier5-src/_shared/himi-copy.ts +10 -2
- package/templates/retail-store/tier5-src/_shared/himi-restaurants.ts +2 -2
- package/templates/retail-store/tier5-src/_shared/restaurant-ordering.ts +1 -1
- package/templates/retail-store/tier5-src/_shared/wix-service-price.ts +2 -2
- package/templates/retail-store/tier5-src/himi-branded-lite-cart/index.ts +1 -1
- package/templates/retail-store/tier5-src/himi-branded-lite-home/index.ts +2 -1
- package/templates/retail-store-owner/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/retail-store-owner/tier5-src/_shared/engine-intl.ts +5 -3
- package/templates/retail-store-owner/tier5-src/_shared/himi-copy.ts +10 -2
- package/templates/yoga-studio/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/yoga-studio/tier5-src/_shared/engine-intl.ts +5 -3
- package/templates/yoga-studio/tier5-src/_shared/group-member-count.ts +15 -0
- package/templates/yoga-studio/tier5-src/_shared/himi-bookings.ts +54 -13
- package/templates/yoga-studio/tier5-src/_shared/himi-copy.ts +10 -2
- package/templates/yoga-studio/tier5-src/_shared/himi-restaurants.ts +2 -2
- package/templates/yoga-studio/tier5-src/_shared/wix-service-price.ts +2 -2
- package/templates/yoga-studio/tier5-src/himi-booking-services/index.ts +8 -3
- package/templates/yoga-studio/tier5-src/himi-branded-lite-home/index.ts +2 -1
- package/templates/yoga-studio/tier5-src/himi-branded-lite-plans/index.ts +1 -1
- package/templates/yoga-studio/tier5-src/himi-branded-lite-program/index.ts +1 -1
- package/templates/yoga-studio/tier5-src/himi-events-detail/index.ts +5 -5
- package/templates/yoga-studio-owner/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/yoga-studio-owner/tier5-src/_shared/engine-intl.ts +5 -3
- package/templates/yoga-studio-owner/tier5-src/_shared/himi-copy.ts +10 -2
|
@@ -243,7 +243,7 @@ function tierPrice(t: WixAvailableTicket): string {
|
|
|
243
243
|
// as "25" — a price that reads as a quantity, and nothing downstream could tell it was a
|
|
244
244
|
// formatting failure. `formatCurrency` uses real Intl where it exists and a symbol-carrying
|
|
245
245
|
// fallback where it does not, diffed against ECMA-402 in engine-intl-fallback.test.ts.
|
|
246
|
-
return formatCurrency(Number(raw), t.price?.currency || "USD"
|
|
246
|
+
return formatCurrency(Number(raw), t.price?.currency || "USD");
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
function tierAvailable(t: WixAvailableTicket): boolean {
|
|
@@ -286,7 +286,7 @@ function tierRows(defs: WixAvailableTicket[], selectedId: string): TicketTierRow
|
|
|
286
286
|
priceAmount: Number(t.price?.amount ?? 0),
|
|
287
287
|
...(isGuestPrice ? { priceLine: detailCopy("event.payWhatYouWant", "Pay what you want") } : {}),
|
|
288
288
|
...(isGuestPrice ? { priceAmount: minPrice, isGuestPrice: true } : {}),
|
|
289
|
-
...(isGuestPrice ? { minimumPriceLabel: detailCopy("event.minPrice", "Minimum {price}").replace("{price}", formatCurrency(minPrice, t.price?.currency || "USD"
|
|
289
|
+
...(isGuestPrice ? { minimumPriceLabel: detailCopy("event.minPrice", "Minimum {price}").replace("{price}", formatCurrency(minPrice, t.price?.currency || "USD")) } : {}),
|
|
290
290
|
};
|
|
291
291
|
});
|
|
292
292
|
}
|
|
@@ -399,7 +399,7 @@ function derive(s: S): S {
|
|
|
399
399
|
noFooterCaption: !s.footerCaption,
|
|
400
400
|
hideFooter: s.status !== "ready" || s.errored || !s.footerLabel || s.rsvpState !== "none",
|
|
401
401
|
checkoutDisabled: count === 0 || count > s.ticketLimitPerOrder || ticketCheckoutInFlight || !ticketCheckoutAllowed || s.ticketTiers.some((row) => row.isGuestPrice && (row.quantity ?? 0) > 0 && (!String(row.guestPrice ?? "").trim() || Number(row.guestPrice) < (row.minPrice ?? 0) || !Number.isFinite(Number(row.guestPrice)))) || s.ticketTiers.some((row) => (row.quantity ?? 0) > (row.maxQuantity ?? 99)),
|
|
402
|
-
ticketTotal: formatCurrency(total, s.ticketCurrency || "USD"
|
|
402
|
+
ticketTotal: formatCurrency(total, s.ticketCurrency || "USD"),
|
|
403
403
|
ticketCountLabel: copyParam("event.ticketCount", "{n} tickets, plus fees").replace("{n}", String(count)),
|
|
404
404
|
noSchedule: s.schedule.length === 0,
|
|
405
405
|
noFullSchedule: s.fullSchedule.length === 0,
|
|
@@ -494,7 +494,7 @@ function detailMoney(money?: EventDetailMoney): string {
|
|
|
494
494
|
if (money?.formattedValue) return money.formattedValue;
|
|
495
495
|
const value = money?.value;
|
|
496
496
|
if (value == null || String(value).trim() === "" || !money?.currency || !Number.isFinite(Number(value))) return "";
|
|
497
|
-
return formatCurrency(Number(value), money.currency
|
|
497
|
+
return formatCurrency(Number(value), money.currency);
|
|
498
498
|
}
|
|
499
499
|
|
|
500
500
|
function detailPlace(e: WixEvent): { value: string; mapUrl: string; hideMapTap: boolean; icon: string } {
|
|
@@ -617,7 +617,7 @@ const svc: ReturnType<typeof defineService<S, DetailActions>> = defineService<S,
|
|
|
617
617
|
ticketSheetOpen: false,
|
|
618
618
|
rsvpActionsOpen: false,
|
|
619
619
|
cancelConfirmOpen: false,
|
|
620
|
-
ticketTotal: formatCurrency(0, "USD"
|
|
620
|
+
ticketTotal: formatCurrency(0, "USD"),
|
|
621
621
|
ticketCountLabel: copyParam("event.ticketCount", "{n} tickets, plus fees").replace("{n}", "0"),
|
|
622
622
|
checkoutDisabled: true,
|
|
623
623
|
schedule: [],
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// The language a worker formats numbers, money and plurals in, and the business's time zone. A worker has no host locale to read,
|
|
2
|
+
// so the screen's `onAppear` hands it over: `appear()` adds `locale` to the load params when the app
|
|
3
|
+
// pins its language, and `stashCopy` stores it here. Absent, every formatter stays on "en" — the
|
|
4
|
+
// house pattern every English app was approved with — so an unpinned app is unchanged.
|
|
5
|
+
//
|
|
6
|
+
// The business time zone comes the same way, from the app's provisioning (`businessTimeZone`, collected
|
|
7
|
+
// at migration time while the site's properties are readable): a worker cannot read it itself, because
|
|
8
|
+
// the site-properties route is owner-scoped. Absent, it is "" and no worker guesses one.
|
|
9
|
+
//
|
|
10
|
+
// Pure, no host globals: bundled into every worker that formats, copied into generated templates.
|
|
11
|
+
|
|
12
|
+
const TAG = /^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/;
|
|
13
|
+
let tag = "en";
|
|
14
|
+
|
|
15
|
+
/** Set from a load argument's `locale`; anything that is not a language tag resets to "en". */
|
|
16
|
+
export function setAppLocale(value: unknown): void {
|
|
17
|
+
tag = typeof value === "string" && TAG.test(value) ? value : "en";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function appLocale(): string {
|
|
21
|
+
return tag;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** An IANA zone such as "Asia/Jerusalem" (or "UTC") that this engine knows. A bare offset, a lowercase
|
|
25
|
+
* alias or an engine without ECMA-402 is not one: a zone is never guessed. */
|
|
26
|
+
export function isIanaTimeZone(value: unknown): value is string {
|
|
27
|
+
if (typeof value !== "string" || !/^(?:UTC|[A-Za-z]+(?:\/[A-Za-z0-9_+-]+)+)$/.test(value)) return false;
|
|
28
|
+
// An engine without ECMA-402 has no zone database: nothing it holds is a zone it knows.
|
|
29
|
+
if (typeof Intl === "object" && typeof Intl.DateTimeFormat === "function") {
|
|
30
|
+
try {
|
|
31
|
+
new Intl.DateTimeFormat("en-US", { timeZone: value });
|
|
32
|
+
return true;
|
|
33
|
+
} catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let zone = "";
|
|
41
|
+
|
|
42
|
+
/** Set from a load argument's `businessTimeZone`; anything that is not an IANA zone clears it. */
|
|
43
|
+
export function setBusinessTimeZone(value: unknown): void {
|
|
44
|
+
zone = isIanaTimeZone(value) ? value : "";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The business's IANA zone, or "" when the app has none provisioned. */
|
|
48
|
+
export function businessTimeZone(): string {
|
|
49
|
+
return zone;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Does `count` take the singular form in the app language? CLDR plural rules, so French "0 point"
|
|
53
|
+
* and "1,5 point" are singular and Hebrew "2" is not. An engine without PluralRules keeps the
|
|
54
|
+
* English rule (exactly one). */
|
|
55
|
+
export function isSingular(count: number, locale = appLocale()): boolean {
|
|
56
|
+
try {
|
|
57
|
+
// An engine without ECMA-402 has no `Intl` at all: it keeps the English rule.
|
|
58
|
+
if (typeof Intl === "object" && typeof Intl.PluralRules === "function") return new Intl.PluralRules(locale).select(count) === "one";
|
|
59
|
+
} catch { /* malformed tag — use the English rule */ }
|
|
60
|
+
return count === 1;
|
|
61
|
+
}
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
// These helpers are the sanctioned way to format across the whole fleet: real ECMA-402 where it
|
|
21
21
|
// exists, a deterministic en-US-shaped fallback where it does not, and never a throw.
|
|
22
22
|
|
|
23
|
+
import { appLocale } from "./app-locale.js";
|
|
24
|
+
|
|
23
25
|
/** Is ECMA-402 actually present in THIS engine? Cheap, and safe in a realm without `Intl`. */
|
|
24
26
|
export function hasIntl(): boolean {
|
|
25
27
|
return typeof Intl !== "undefined";
|
|
@@ -189,7 +191,7 @@ const CURRENCY_DIGITS: Record<string, number> = {
|
|
|
189
191
|
export function formatCurrency(
|
|
190
192
|
amount: number,
|
|
191
193
|
currency = "USD",
|
|
192
|
-
locale =
|
|
194
|
+
locale = appLocale(),
|
|
193
195
|
/** Omit for the currency's natural digits. Pass 0 to render a whole amount as "$25" rather
|
|
194
196
|
* than "$25.00" — Intl clamps the minimum down to match, so max<min does not throw here. */
|
|
195
197
|
maximumFractionDigits?: number,
|
|
@@ -258,7 +260,7 @@ function groupThousands(fixed: string): string {
|
|
|
258
260
|
* inserted commas into the exponent — `1e21` came out as "1e,+21" and `1e-7` as "1,e-7".
|
|
259
261
|
* Garbage, and silently so, because nothing in the corpus's tidy test numbers reached it.
|
|
260
262
|
*/
|
|
261
|
-
export function formatNumber(value: number, locale =
|
|
263
|
+
export function formatNumber(value: number, locale = appLocale()): string {
|
|
262
264
|
if (!Number.isFinite(value)) return "";
|
|
263
265
|
if (hasIntl()) return new Intl.NumberFormat(locale).format(value);
|
|
264
266
|
// `toFixed` itself returns exponential notation at >=1e21, so anything that big keeps the
|
|
@@ -409,7 +411,7 @@ export function compareDateDesc(a: string, b: string): number {
|
|
|
409
411
|
// Customers read that as sloppiness, and a whole "₪70" beside "₪69.50" reads as a different
|
|
410
412
|
// kind of number. So: one money pattern, one clock, one range.
|
|
411
413
|
|
|
412
|
-
// Money uses `formatCurrency(amount, currency
|
|
414
|
+
// Money uses `formatCurrency(amount, currency)` — English unless the app pins another language, see app-locale — the currency's NATURAL decimals
|
|
413
415
|
// ("₪70.00", "¥500") — for Shop, Menu and every other price. The one exception is a Bookings
|
|
414
416
|
// SERVICE price (`_shared/wix-service-price.ts`): it drops the cents of a whole amount ("₪70",
|
|
415
417
|
// "₪69.50"), the format the redesigned service screen and services list were approved with. It
|
|
@@ -12,10 +12,12 @@
|
|
|
12
12
|
// and every read returns `fallback` verbatim — routing a worker string through
|
|
13
13
|
// copyParam is byte-for-byte behavior-preserving.
|
|
14
14
|
//
|
|
15
|
-
// Pure + Hermes-safe (no host globals, no Node APIs
|
|
15
|
+
// Pure + Hermes-safe (no host globals, no Node APIs; its only import is the pure `app-locale` sibling): bundled into
|
|
16
16
|
// every worker that emits user-facing copy, and copied verbatim into the
|
|
17
17
|
// generated templates' tier5-src/_shared/.
|
|
18
18
|
|
|
19
|
+
import { isSingular, setAppLocale, setBusinessTimeZone } from "./app-locale.js";
|
|
20
|
+
|
|
19
21
|
/** Customer strings override every read; translated stock is valid only for its
|
|
20
22
|
* original English fallback. Some existing keys serve more than one message. */
|
|
21
23
|
export type CopyPackValue = string | { source: string; translation: string };
|
|
@@ -29,6 +31,12 @@ let copyReceived = false;
|
|
|
29
31
|
* stock fallbacks keep rendering. */
|
|
30
32
|
export function stashCopy(arg: unknown): void {
|
|
31
33
|
if (!arg || typeof arg !== "object") return;
|
|
34
|
+
// A param-carrying dispatch names the app language and business zone too (absent: the English house
|
|
35
|
+
// pattern, and no zone).
|
|
36
|
+
if ("copy" in arg || "locale" in arg || "businessTimeZone" in arg) {
|
|
37
|
+
setAppLocale((arg as Record<string, unknown>).locale);
|
|
38
|
+
setBusinessTimeZone((arg as Record<string, unknown>).businessTimeZone);
|
|
39
|
+
}
|
|
32
40
|
const raw = (arg as Record<string, unknown>).copy;
|
|
33
41
|
if (typeof raw !== "string" || !raw) return;
|
|
34
42
|
try {
|
|
@@ -77,5 +85,5 @@ export function copyPlural(key: string, fallback: string, count: number): string
|
|
|
77
85
|
const pattern = copyParam(key, fallback);
|
|
78
86
|
const match = /^\{n, plural, one \{([^{}]*)\} other \{([^{}]*)\}\}$/.exec(pattern);
|
|
79
87
|
if (!match) return copyTemplate(key, fallback, { n: count });
|
|
80
|
-
return (count
|
|
88
|
+
return (isSingular(count) ? match[1] : match[2])!.replace(/#/g, String(count));
|
|
81
89
|
}
|