diff --git a/gui-patches/online-shop/localize-vehicle-pack-titles/patch.json b/gui-patches/online-shop/localize-vehicle-pack-titles/patch.json new file mode 100644 index 0000000..0007a05 --- /dev/null +++ b/gui-patches/online-shop/localize-vehicle-pack-titles/patch.json @@ -0,0 +1,29 @@ +{ + "id": "online-shop/localize-vehicle-pack-titles", + "title": "Display localized titles for offline vehicle packs", + "file": "scripts/onlineshop/entitlements.nut", + "program_behaviour": { + "stock": "The entitlement name is looked up in the game's localization table by product ID, alias, or group.", + "patched": "Use the catalogue title for offline vehicle packs, selecting Chinese or English from the current game language. Products without a catalogue title use the existing name formatter." + }, + "derivation": { + "requirement": "The purchase receipt title matches the name of the vehicle pack shown in the local store.", + "cause": "The game's localization table has no entries for the locally generated vehicle pack IDs.", + "lighter_options_ruled_out": [ + "Supply the names in the price response alone. The original name formatter does not read those fields." + ], + "if_not_applied": "Vehicle pack receipts can show the raw localization key as the title." + }, + "features": [ + "G-Store" + ], + "evidence": [ + "2.61.0.37 scripts/onlineshop/entitlements.nut: getEntitlementConfig copies all price parameters, and getEntitlementName calls getEntitlementShortName.", + "2.61.0.37 scripts/onlineshop/entitlementrewardwnd.nut: getTitle uses getEntitlementName.", + "packages/local-service/src/char/actions/store-actions.ts: localized titles in the entitlement price response." + ], + "edit": { + "find": "function getEntitlementShortName(ent) {\r\n local name = \"\"", + "replace": "function getEntitlementShortName(ent) {\r\n let catalogueTitle = ent?.wtoTitleEn\r\n if (catalogueTitle != null) {\r\n let { isChineseVersion, isChineseHarmonized } = require(\"%scripts/langUtils/language.nut\")\r\n let isChinese = isChineseVersion() || isChineseHarmonized()\r\n return isChinese ? (ent?.wtoTitleZh ?? catalogueTitle) : catalogueTitle\r\n }\r\n\r\n local name = \"\"" + } +} diff --git a/packages/local-service/src/char/actions/store-actions.ts b/packages/local-service/src/char/actions/store-actions.ts index 93227b9..1a2b2ba 100644 --- a/packages/local-service/src/char/actions/store-actions.ts +++ b/packages/local-service/src/char/actions/store-actions.ts @@ -70,6 +70,8 @@ function buildEntitlementsPriceBlk(products: readonly StoreProduct[]): BlkBlock setParam(block, 'ttl', { type: 'int', value: product.premiumDays! }); } else if (product.kind === 'vehicle-pack' && product.vehicles) { setParam(block, 'onlinePurchase', { type: 'bool', value: true }); + setParam(block, 'wtoTitleEn', { type: 'string', value: product.title.en }); + setParam(block, 'wtoTitleZh', { type: 'string', value: product.title.zh }); for (const vehicle of product.vehicles) { appendParam(block, 'aircraftGift', { type: 'string', value: vehicle.name }); }