mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 05:16:23 -06:00
fix: skip native Swift conditional interpolations
This commit is contained in:
@@ -5577,14 +5577,6 @@
|
||||
"surface": "apple",
|
||||
"id": "native.apple.95300e4dfd7aad42"
|
||||
},
|
||||
{
|
||||
"kind": "ui-call",
|
||||
"line": 306,
|
||||
"path": "apps/ios/Sources/Design/AgentProDreamingDestination.swift",
|
||||
"source": "\\(day.entryCount) \\(day.entryCount == 1 ? \"entry\" : \"entries\")",
|
||||
"surface": "apple",
|
||||
"id": "native.apple.21d92f01c5cc2412"
|
||||
},
|
||||
{
|
||||
"kind": "ui-named-argument",
|
||||
"line": 343,
|
||||
|
||||
@@ -3488,11 +3488,6 @@
|
||||
"source": "Dream diary day",
|
||||
"translated": "Traumtagebuch-Tag"
|
||||
},
|
||||
{
|
||||
"id": "native.apple.21d92f01c5cc2412",
|
||||
"source": "\\(day.entryCount) \\(day.entryCount == 1 ? \"entry\" : \"entries\")",
|
||||
"translated": "\\(day.entryCount) \\(day.entryCount == 1 ? \"entry\" : \"entries\")"
|
||||
},
|
||||
{
|
||||
"id": "native.apple.f0df95f0790fe675",
|
||||
"source": "Connect a gateway to load dreaming entries.",
|
||||
|
||||
@@ -3488,11 +3488,6 @@
|
||||
"source": "Dream diary day",
|
||||
"translated": "Día del diario de sueños"
|
||||
},
|
||||
{
|
||||
"id": "native.apple.21d92f01c5cc2412",
|
||||
"source": "\\(day.entryCount) \\(day.entryCount == 1 ? \"entry\" : \"entries\")",
|
||||
"translated": "\\(day.entryCount) \\(day.entryCount == 1 ? \"entry\" : \"entries\")"
|
||||
},
|
||||
{
|
||||
"id": "native.apple.f0df95f0790fe675",
|
||||
"source": "Connect a gateway to load dreaming entries.",
|
||||
|
||||
@@ -3488,11 +3488,6 @@
|
||||
"source": "Dream diary day",
|
||||
"translated": "梦境日记日期"
|
||||
},
|
||||
{
|
||||
"id": "native.apple.21d92f01c5cc2412",
|
||||
"source": "\\(day.entryCount) \\(day.entryCount == 1 ? \"entry\" : \"entries\")",
|
||||
"translated": "\\(day.entryCount) \\(day.entryCount == 1 ? \"entry\" : \"entries\")"
|
||||
},
|
||||
{
|
||||
"id": "native.apple.f0df95f0790fe675",
|
||||
"source": "Connect a gateway to load dreaming entries.",
|
||||
|
||||
@@ -3488,11 +3488,6 @@
|
||||
"source": "Dream diary day",
|
||||
"translated": "Dream diary 日期"
|
||||
},
|
||||
{
|
||||
"id": "native.apple.21d92f01c5cc2412",
|
||||
"source": "\\(day.entryCount) \\(day.entryCount == 1 ? \"entry\" : \"entries\")",
|
||||
"translated": "\\(day.entryCount) \\(day.entryCount == 1 ? \"entry\" : \"entries\")"
|
||||
},
|
||||
{
|
||||
"id": "native.apple.f0df95f0790fe675",
|
||||
"source": "Connect a gateway to load dreaming entries.",
|
||||
|
||||
@@ -176,6 +176,9 @@ function isTranslatableCandidate(source: string, kind: string): boolean {
|
||||
return false;
|
||||
}
|
||||
BUILD_SETTING_RE.lastIndex = 0;
|
||||
if (hasQuotedConditionalSwiftInterpolation(source)) {
|
||||
return false;
|
||||
}
|
||||
const isDirectUiText = kind.startsWith("ui-") || kind.startsWith("resource-");
|
||||
if (!isDirectUiText && (/^[a-z0-9_.:/$-]+$/u.test(source) || /^[A-Z0-9_.:/$-]+$/u.test(source))) {
|
||||
return false;
|
||||
@@ -189,6 +192,18 @@ function isTranslatableCandidate(source: string, kind: string): boolean {
|
||||
return kind !== "plist-string" || /\s/u.test(source);
|
||||
}
|
||||
|
||||
function hasQuotedConditionalSwiftInterpolation(source: string): boolean {
|
||||
return (
|
||||
extractSwiftInterpolations(source)?.some(
|
||||
(interpolation) =>
|
||||
/\?\s*"((?:\\.|[^"\\])*)"\s*:\s*"((?:\\.|[^"\\])*)"/u.test(interpolation) ||
|
||||
/\bif\b[\s\S]*"((?:\\.|[^"\\])*)"[\s\S]*\belse\b[\s\S]*"((?:\\.|[^"\\])*)"/u.test(
|
||||
interpolation,
|
||||
),
|
||||
) ?? false
|
||||
);
|
||||
}
|
||||
|
||||
function extractSwiftInterpolations(source: string): string[] | null {
|
||||
const values: string[] = [];
|
||||
for (let index = 0; index < source.length; index += 1) {
|
||||
|
||||
@@ -91,7 +91,7 @@ describe("native app i18n inventory", () => {
|
||||
(entry) =>
|
||||
entry.source === '\\(day.entryCount) \\(day.entryCount == 1 ? "entry" : "entries")',
|
||||
),
|
||||
).toBe(true);
|
||||
).toBe(false);
|
||||
expect(
|
||||
entries.some(
|
||||
(entry) =>
|
||||
|
||||
Reference in New Issue
Block a user