From 3d32fe3f0c97766ffdc09efd4df86c74743c009e Mon Sep 17 00:00:00 2001 From: Leo Li Date: Sun, 1 Nov 2026 07:57:29 +0000 Subject: [PATCH 1/2] fix(apps): Arabic zero/one/two forms of store.updates.available reference the number (base red from #30288) Xcode's string catalog compiler refuses a plural variation that doesn't reference its number ("Plural variation requires referencing the number in the string", ar: store.updates.available), so the CmuxNext package test build failed at e6bfd26de939 and every Swift suite run after it went red before any test ran. Co-Authored-By: Claude Opus 5.5 Agent-Session: https://cmux.com/deeplink/agent?id=aid-3a05ae6e302bba4a7be8 --- .../Sources/CmuxNextApps/Resources/Localizable.xcstrings | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Packages/macOS/CmuxNext/Sources/CmuxNextApps/Resources/Localizable.xcstrings b/Packages/macOS/CmuxNext/Sources/CmuxNextApps/Resources/Localizable.xcstrings index e4087e77281d..2b3b196c50eb 100644 --- a/Packages/macOS/CmuxNext/Sources/CmuxNextApps/Resources/Localizable.xcstrings +++ b/Packages/macOS/CmuxNext/Sources/CmuxNextApps/Resources/Localizable.xcstrings @@ -14952,19 +14952,19 @@ "zero" : { "stringUnit" : { "state" : "needs_review", - "value" : "لا تتوفر تحديثات" + "value" : "لا تتوفر تحديثات (%@)" } }, "one" : { "stringUnit" : { "state" : "needs_review", - "value" : "يتوفر تحديث واحد" + "value" : "يتوفر تحديث واحد (%@)" } }, "two" : { "stringUnit" : { "state" : "needs_review", - "value" : "يتوفر تحديثان" + "value" : "يتوفر تحديثان (%@)" } }, "few" : { From 1f7c1d28b2b235b5b33d12caeb848c1359ad74f6 Mon Sep 17 00:00:00 2001 From: Leo Li Date: Sun, 1 Nov 2026 08:01:58 +0000 Subject: [PATCH 2/2] fix(apps): store.updates.available's plural forms use %lld, which the page formatter now fills Xcode's catalog compiler wants an integer specifier in every plural variation, not %@: the package build failed on ar, then on bs, for every language of the key. formatString substitutes %d, %ld and %lld (and %N$lld) like %@. Co-Authored-By: Claude Opus 5.5 Agent-Session: https://cmux.com/deeplink/agent?id=aid-3a05ae6e302bba4a7be8 --- .../Resources/Localizable.xcstrings | 100 +++++++++--------- webviews/src/pages/shared/i18n.test.ts | 12 ++- webviews/src/pages/shared/i18n.ts | 6 +- 3 files changed, 65 insertions(+), 53 deletions(-) diff --git a/Packages/macOS/CmuxNext/Sources/CmuxNextApps/Resources/Localizable.xcstrings b/Packages/macOS/CmuxNext/Sources/CmuxNextApps/Resources/Localizable.xcstrings index 2b3b196c50eb..4b79a5a369dd 100644 --- a/Packages/macOS/CmuxNext/Sources/CmuxNextApps/Resources/Localizable.xcstrings +++ b/Packages/macOS/CmuxNext/Sources/CmuxNextApps/Resources/Localizable.xcstrings @@ -14952,37 +14952,37 @@ "zero" : { "stringUnit" : { "state" : "needs_review", - "value" : "لا تتوفر تحديثات (%@)" + "value" : "لا تتوفر تحديثات (%lld)" } }, "one" : { "stringUnit" : { "state" : "needs_review", - "value" : "يتوفر تحديث واحد (%@)" + "value" : "يتوفر تحديث واحد (%lld)" } }, "two" : { "stringUnit" : { "state" : "needs_review", - "value" : "يتوفر تحديثان (%@)" + "value" : "يتوفر تحديثان (%lld)" } }, "few" : { "stringUnit" : { "state" : "needs_review", - "value" : "تتوفر %@ تحديثات" + "value" : "تتوفر %lld تحديثات" } }, "many" : { "stringUnit" : { "state" : "needs_review", - "value" : "يتوفر %@ تحديثًا" + "value" : "يتوفر %lld تحديثًا" } }, "other" : { "stringUnit" : { "state" : "needs_review", - "value" : "يتوفر %@ تحديث" + "value" : "يتوفر %lld تحديث" } } } @@ -14994,19 +14994,19 @@ "one" : { "stringUnit" : { "state" : "needs_review", - "value" : "Dostupno je %@ ažuriranje" + "value" : "Dostupno je %lld ažuriranje" } }, "few" : { "stringUnit" : { "state" : "needs_review", - "value" : "Dostupna su %@ ažuriranja" + "value" : "Dostupna su %lld ažuriranja" } }, "other" : { "stringUnit" : { "state" : "needs_review", - "value" : "Dostupno je %@ ažuriranja" + "value" : "Dostupno je %lld ažuriranja" } } } @@ -15018,13 +15018,13 @@ "one" : { "stringUnit" : { "state" : "needs_review", - "value" : "%@ opdatering tilgængelig" + "value" : "%lld opdatering tilgængelig" } }, "other" : { "stringUnit" : { "state" : "needs_review", - "value" : "%@ opdateringer tilgængelige" + "value" : "%lld opdateringer tilgængelige" } } } @@ -15036,13 +15036,13 @@ "one" : { "stringUnit" : { "state" : "needs_review", - "value" : "%@ Update verfügbar" + "value" : "%lld Update verfügbar" } }, "other" : { "stringUnit" : { "state" : "needs_review", - "value" : "%@ Updates verfügbar" + "value" : "%lld Updates verfügbar" } } } @@ -15054,13 +15054,13 @@ "one" : { "stringUnit" : { "state" : "translated", - "value" : "%@ update available" + "value" : "%lld update available" } }, "other" : { "stringUnit" : { "state" : "translated", - "value" : "%@ updates available" + "value" : "%lld updates available" } } } @@ -15072,19 +15072,19 @@ "one" : { "stringUnit" : { "state" : "needs_review", - "value" : "%@ actualización disponible" + "value" : "%lld actualización disponible" } }, "many" : { "stringUnit" : { "state" : "needs_review", - "value" : "%@ de actualizaciones disponibles" + "value" : "%lld de actualizaciones disponibles" } }, "other" : { "stringUnit" : { "state" : "needs_review", - "value" : "%@ actualizaciones disponibles" + "value" : "%lld actualizaciones disponibles" } } } @@ -15096,19 +15096,19 @@ "one" : { "stringUnit" : { "state" : "needs_review", - "value" : "%@ mise à jour disponible" + "value" : "%lld mise à jour disponible" } }, "many" : { "stringUnit" : { "state" : "needs_review", - "value" : "%@ de mises à jour disponibles" + "value" : "%lld de mises à jour disponibles" } }, "other" : { "stringUnit" : { "state" : "needs_review", - "value" : "%@ mises à jour disponibles" + "value" : "%lld mises à jour disponibles" } } } @@ -15120,19 +15120,19 @@ "one" : { "stringUnit" : { "state" : "needs_review", - "value" : "%@ aggiornamento disponibile" + "value" : "%lld aggiornamento disponibile" } }, "many" : { "stringUnit" : { "state" : "needs_review", - "value" : "%@ di aggiornamenti disponibili" + "value" : "%lld di aggiornamenti disponibili" } }, "other" : { "stringUnit" : { "state" : "needs_review", - "value" : "%@ aggiornamenti disponibili" + "value" : "%lld aggiornamenti disponibili" } } } @@ -15144,7 +15144,7 @@ "other" : { "stringUnit" : { "state" : "needs_review", - "value" : "%@件のアップデートがあります" + "value" : "%lld件のアップデートがあります" } } } @@ -15156,7 +15156,7 @@ "other" : { "stringUnit" : { "state" : "needs_review", - "value" : "មានបច្ចុប្បន្នភាព %@" + "value" : "មានបច្ចុប្បន្នភាព %lld" } } } @@ -15168,7 +15168,7 @@ "other" : { "stringUnit" : { "state" : "needs_review", - "value" : "%@개 업데이트 가능" + "value" : "%lld개 업데이트 가능" } } } @@ -15180,13 +15180,13 @@ "one" : { "stringUnit" : { "state" : "needs_review", - "value" : "%@ oppdatering tilgjengelig" + "value" : "%lld oppdatering tilgjengelig" } }, "other" : { "stringUnit" : { "state" : "needs_review", - "value" : "%@ oppdateringer tilgjengelig" + "value" : "%lld oppdateringer tilgjengelig" } } } @@ -15198,25 +15198,25 @@ "one" : { "stringUnit" : { "state" : "needs_review", - "value" : "Dostępna aktualizacja: %@" + "value" : "Dostępna aktualizacja: %lld" } }, "few" : { "stringUnit" : { "state" : "needs_review", - "value" : "Dostępne aktualizacje: %@" + "value" : "Dostępne aktualizacje: %lld" } }, "many" : { "stringUnit" : { "state" : "needs_review", - "value" : "Dostępnych aktualizacji: %@" + "value" : "Dostępnych aktualizacji: %lld" } }, "other" : { "stringUnit" : { "state" : "needs_review", - "value" : "Dostępnych aktualizacji: %@" + "value" : "Dostępnych aktualizacji: %lld" } } } @@ -15228,19 +15228,19 @@ "one" : { "stringUnit" : { "state" : "needs_review", - "value" : "%@ atualização disponível" + "value" : "%lld atualização disponível" } }, "many" : { "stringUnit" : { "state" : "needs_review", - "value" : "%@ de atualizações disponíveis" + "value" : "%lld de atualizações disponíveis" } }, "other" : { "stringUnit" : { "state" : "needs_review", - "value" : "%@ atualizações disponíveis" + "value" : "%lld atualizações disponíveis" } } } @@ -15252,25 +15252,25 @@ "one" : { "stringUnit" : { "state" : "needs_review", - "value" : "Доступно обновление: %@" + "value" : "Доступно обновление: %lld" } }, "few" : { "stringUnit" : { "state" : "needs_review", - "value" : "Доступно обновления: %@" + "value" : "Доступно обновления: %lld" } }, "many" : { "stringUnit" : { "state" : "needs_review", - "value" : "Доступно обновлений: %@" + "value" : "Доступно обновлений: %lld" } }, "other" : { "stringUnit" : { "state" : "needs_review", - "value" : "Доступно обновлений: %@" + "value" : "Доступно обновлений: %lld" } } } @@ -15282,7 +15282,7 @@ "other" : { "stringUnit" : { "state" : "needs_review", - "value" : "มีการอัปเดต %@ รายการ" + "value" : "มีการอัปเดต %lld รายการ" } } } @@ -15294,13 +15294,13 @@ "one" : { "stringUnit" : { "state" : "needs_review", - "value" : "%@ güncelleme mevcut" + "value" : "%lld güncelleme mevcut" } }, "other" : { "stringUnit" : { "state" : "needs_review", - "value" : "%@ güncelleme mevcut" + "value" : "%lld güncelleme mevcut" } } } @@ -15312,25 +15312,25 @@ "one" : { "stringUnit" : { "state" : "needs_review", - "value" : "Доступне оновлення: %@" + "value" : "Доступне оновлення: %lld" } }, "few" : { "stringUnit" : { "state" : "needs_review", - "value" : "Доступно оновлення: %@" + "value" : "Доступно оновлення: %lld" } }, "many" : { "stringUnit" : { "state" : "needs_review", - "value" : "Доступно оновлень: %@" + "value" : "Доступно оновлень: %lld" } }, "other" : { "stringUnit" : { "state" : "needs_review", - "value" : "Доступно оновлень: %@" + "value" : "Доступно оновлень: %lld" } } } @@ -15342,7 +15342,7 @@ "other" : { "stringUnit" : { "state" : "needs_review", - "value" : "Có %@ bản cập nhật" + "value" : "Có %lld bản cập nhật" } } } @@ -15354,7 +15354,7 @@ "other" : { "stringUnit" : { "state" : "needs_review", - "value" : "有 %@ 项更新" + "value" : "有 %lld 项更新" } } } @@ -15366,7 +15366,7 @@ "other" : { "stringUnit" : { "state" : "needs_review", - "value" : "有 %@ 項更新" + "value" : "有 %lld 項更新" } } } diff --git a/webviews/src/pages/shared/i18n.test.ts b/webviews/src/pages/shared/i18n.test.ts index 16f6d86a60db..eafac7f51a2c 100644 --- a/webviews/src/pages/shared/i18n.test.ts +++ b/webviews/src/pages/shared/i18n.test.ts @@ -1,5 +1,5 @@ import { expect, test } from "bun:test"; -import { createStrings } from "./i18n"; +import { createStrings, formatString } from "./i18n"; // A plural string is `key#` for every category, in every locale (gen-strings.mjs). const table = { @@ -40,3 +40,13 @@ test("a language whose catalog gave it no plural forms uses its plain string, no const plain = { ...table, ja: { "updates.available": "%@件のアップデートがあります", "updates.version": "v%@" } }; expect(createStrings(plain, ["ja"]).format("updates.available", "1")).toBe("1件のアップデートがあります"); }); + +// Xcode's catalog compiler refuses a plural variation without an integer specifier, so a plural +// catalog string uses %lld (store.updates.available after #30288 broke the package build). +test("integer specifiers format like %@, in order and by position", () => { + expect(formatString("%lld updates available", ["3"])).toBe("3 updates available"); + expect(formatString("يتوفر تحديثان (%lld)", ["2"])).toBe("يتوفر تحديثان (2)"); + expect(formatString("%d of %ld, %@", ["1", "2", "x"])).toBe("1 of 2, x"); + expect(formatString("%2$lld before %1$@", ["a", "9"])).toBe("9 before a"); + expect(formatString("100%% of %lld", ["4"])).toBe("100% of 4"); +}); diff --git a/webviews/src/pages/shared/i18n.ts b/webviews/src/pages/shared/i18n.ts index ad92e676b9cf..e10fad8daff9 100644 --- a/webviews/src/pages/shared/i18n.ts +++ b/webviews/src/pages/shared/i18n.ts @@ -40,10 +40,12 @@ export interface Strings { format(key: string, ...args: string[]): string; } -/** Replaces `%@` (in order) and `%N$@` (by position) with `args`; `%%` is a percent sign. */ +/** Replaces `%@` and the integer specifiers `%d`, `%ld`, `%lld` (in order; `%N$@`, `%N$lld` by + * position) with `args`; `%%` is a percent sign. A plural catalog string must use an integer + * specifier, which Xcode's catalog compiler requires of a plural variation. */ export function formatString(text: string, args: readonly string[]): string { let next = 0; - return text.replace(/%(?:(\d+)\$)?@|%%/g, (match, position: string | undefined) => { + return text.replace(/%(?:(\d+)\$)?(?:@|l{0,2}d)|%%/g, (match, position: string | undefined) => { if (match === "%%") return "%"; const index = position ? Number(position) - 1 : next++; return args[index] ?? "";