From f1f2039556c0f4f13378bfbcd26e4abfa6074642 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 30 Nov 2026 11:43:58 -0800 Subject: [PATCH] perf(i18n): fast-path plain literal messages in @generaltranslation/icu --- patches/@generaltranslation__icu@0.1.2.patch | 10 ++++++++-- pnpm-lock.yaml | 10 +++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/patches/@generaltranslation__icu@0.1.2.patch b/patches/@generaltranslation__icu@0.1.2.patch index 8090190224215..e0c03b3b48dd1 100644 --- a/patches/@generaltranslation__icu@0.1.2.patch +++ b/patches/@generaltranslation__icu@0.1.2.patch @@ -2,7 +2,7 @@ diff --git a/dist/index.cjs b/dist/index.cjs index 1d257228877aeab6a04ee143c0aad5a209d3e6a5..7e68214329cb18e59fab0580df35d04da0522b7d 100644 --- a/dist/index.cjs +++ b/dist/index.cjs -@@ -750,11 +750,40 @@ const TIME_STYLES = { +@@ -750,11 +750,43 @@ const TIME_STYLES = { long: LONG_TIME_STYLE, full: LONG_TIME_STYLE }; @@ -33,6 +33,9 @@ index 1d257228877aeab6a04ee143c0aad5a209d3e6a5..7e68214329cb18e59fab0580df35d04d +} function formatMessage(message, locales = "en", variables = {}) { - const parts = formatElements(parse(message, { locale: resolveLocale(locales) }), { ++ if (typeof message === "string" && message.indexOf("{") === -1 && message.indexOf("}") === -1 && message.indexOf("'") === -1 && message.indexOf("<") === -1) { ++ return message; ++ } + const cache = localeCacheFor(locales); + const parts = formatElements(parseCached(cache, message), { message, @@ -49,7 +52,7 @@ diff --git a/dist/index.mjs b/dist/index.mjs index a54f2235227290efe761215b30da542562b2e77f..db5bcf2592340e7e9e96d26f89e3437018cfcd0f 100644 --- a/dist/index.mjs +++ b/dist/index.mjs -@@ -749,11 +749,40 @@ const TIME_STYLES = { +@@ -749,11 +749,43 @@ const TIME_STYLES = { long: LONG_TIME_STYLE, full: LONG_TIME_STYLE }; @@ -80,6 +83,9 @@ index a54f2235227290efe761215b30da542562b2e77f..db5bcf2592340e7e9e96d26f89e34370 +} function formatMessage(message, locales = "en", variables = {}) { - const parts = formatElements(parse(message, { locale: resolveLocale(locales) }), { ++ if (typeof message === "string" && message.indexOf("{") === -1 && message.indexOf("}") === -1 && message.indexOf("'") === -1 && message.indexOf("<") === -1) { ++ return message; ++ } + const cache = localeCacheFor(locales); + const parts = formatElements(parseCached(cache, message), { message, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 47114e45a42f3..7e389bec24a17 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -409,7 +409,7 @@ patchedDependencies: '@expo/ui@58.0.29': 2346ac02073363a401e85357e541055e9737bcbc1cdcb63e056cda9368fa79f6 '@ff-labs/fff-node@0.11.0': 93f62a76399b435a76588b2bef237db0a1e85880c1ac0d0759c416e9cc579252 '@generaltranslation/format@0.1.9': 5712dc73770a30134376f9ef883e1a2e1814f007f95532725ba5ecc7b7812db3 - '@generaltranslation/icu@0.1.2': 88fcf88d9660610fbafcbf89b4c7320009b836da05fc658955d50fec899d3d04 + '@generaltranslation/icu@0.1.2': b395e108a8692031c04bf2adac006c08cb929886907d44da0ce48ccf9e2b749c '@legendapp/list@3.9.0': c25646442029896901845e418ade4eaebb33cc101dc3bb4a38201f6923cf5e67 '@muse-code/sdk@1.4.6': 7b495b607fc5d76b444c7c4d58821e839726a30e6f3c53564f0d59f2d5b42101 '@pierre/diffs@1.7.0-beta.4': 7edcdd484a99c7ec0b2667499c4cb21d113ec9bea1f8570c0b0a030d33bbf1cd @@ -15623,9 +15623,9 @@ snapshots: '@generaltranslation/format@0.1.9(patch_hash=5712dc73770a30134376f9ef883e1a2e1814f007f95532725ba5ecc7b7812db3)': dependencies: - '@generaltranslation/icu': 0.1.2(patch_hash=88fcf88d9660610fbafcbf89b4c7320009b836da05fc658955d50fec899d3d04) + '@generaltranslation/icu': 0.1.2(patch_hash=b395e108a8692031c04bf2adac006c08cb929886907d44da0ce48ccf9e2b749c) - '@generaltranslation/icu@0.1.2(patch_hash=88fcf88d9660610fbafcbf89b4c7320009b836da05fc658955d50fec899d3d04)': {} + '@generaltranslation/icu@0.1.2(patch_hash=b395e108a8692031c04bf2adac006c08cb929886907d44da0ce48ccf9e2b749c)': {} '@generaltranslation/python-extractor@0.2.64': dependencies: @@ -20300,7 +20300,7 @@ snapshots: dependencies: '@generaltranslation/api': 0.5.6 '@generaltranslation/format': 0.1.9(patch_hash=5712dc73770a30134376f9ef883e1a2e1814f007f95532725ba5ecc7b7812db3) - '@generaltranslation/icu': 0.1.2(patch_hash=88fcf88d9660610fbafcbf89b4c7320009b836da05fc658955d50fec899d3d04) + '@generaltranslation/icu': 0.1.2(patch_hash=b395e108a8692031c04bf2adac006c08cb929886907d44da0ce48ccf9e2b749c) '@noble/hashes': 2.4.0 gensync@1.0.0-beta.2: {} @@ -20454,7 +20454,7 @@ snapshots: '@babel/types': 7.29.8 '@clack/prompts': 1.0.0-alpha.6 '@generaltranslation/format': 0.1.9(patch_hash=5712dc73770a30134376f9ef883e1a2e1814f007f95532725ba5ecc7b7812db3) - '@generaltranslation/icu': 0.1.2(patch_hash=88fcf88d9660610fbafcbf89b4c7320009b836da05fc658955d50fec899d3d04) + '@generaltranslation/icu': 0.1.2(patch_hash=b395e108a8692031c04bf2adac006c08cb929886907d44da0ce48ccf9e2b749c) '@generaltranslation/python-extractor': 0.2.64 '@generaltranslation/supported-locales': 2.1.45 '@generaltranslation/vue-extractor': 0.1.23(supports-color@8.1.1)