lingo.dev 0.116.1 → 0.116.3
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/build/cli.cjs +417 -501
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +421 -505
- package/build/cli.mjs.map +1 -1
- package/package.json +1 -1
package/build/cli.cjs
CHANGED
|
@@ -26,17 +26,17 @@ function getSettings(explicitApiKey) {
|
|
|
26
26
|
_envVarsInfo();
|
|
27
27
|
return {
|
|
28
28
|
auth: {
|
|
29
|
-
apiKey: explicitApiKey || env.LINGODOTDEV_API_KEY || _optionalChain([systemFile, 'access',
|
|
30
|
-
apiUrl: env.LINGODOTDEV_API_URL || _optionalChain([systemFile, 'access',
|
|
31
|
-
webUrl: env.LINGODOTDEV_WEB_URL || _optionalChain([systemFile, 'access',
|
|
29
|
+
apiKey: explicitApiKey || env.LINGODOTDEV_API_KEY || _optionalChain([systemFile, 'access', _38 => _38.auth, 'optionalAccess', _39 => _39.apiKey]) || defaults2.auth.apiKey,
|
|
30
|
+
apiUrl: env.LINGODOTDEV_API_URL || _optionalChain([systemFile, 'access', _40 => _40.auth, 'optionalAccess', _41 => _41.apiUrl]) || defaults2.auth.apiUrl,
|
|
31
|
+
webUrl: env.LINGODOTDEV_WEB_URL || _optionalChain([systemFile, 'access', _42 => _42.auth, 'optionalAccess', _43 => _43.webUrl]) || defaults2.auth.webUrl
|
|
32
32
|
},
|
|
33
33
|
llm: {
|
|
34
|
-
openaiApiKey: env.OPENAI_API_KEY || _optionalChain([systemFile, 'access',
|
|
35
|
-
anthropicApiKey: env.ANTHROPIC_API_KEY || _optionalChain([systemFile, 'access',
|
|
36
|
-
groqApiKey: env.GROQ_API_KEY || _optionalChain([systemFile, 'access',
|
|
37
|
-
googleApiKey: env.GOOGLE_API_KEY || _optionalChain([systemFile, 'access',
|
|
38
|
-
openrouterApiKey: env.OPENROUTER_API_KEY || _optionalChain([systemFile, 'access',
|
|
39
|
-
mistralApiKey: env.MISTRAL_API_KEY || _optionalChain([systemFile, 'access',
|
|
34
|
+
openaiApiKey: env.OPENAI_API_KEY || _optionalChain([systemFile, 'access', _44 => _44.llm, 'optionalAccess', _45 => _45.openaiApiKey]),
|
|
35
|
+
anthropicApiKey: env.ANTHROPIC_API_KEY || _optionalChain([systemFile, 'access', _46 => _46.llm, 'optionalAccess', _47 => _47.anthropicApiKey]),
|
|
36
|
+
groqApiKey: env.GROQ_API_KEY || _optionalChain([systemFile, 'access', _48 => _48.llm, 'optionalAccess', _49 => _49.groqApiKey]),
|
|
37
|
+
googleApiKey: env.GOOGLE_API_KEY || _optionalChain([systemFile, 'access', _50 => _50.llm, 'optionalAccess', _51 => _51.googleApiKey]),
|
|
38
|
+
openrouterApiKey: env.OPENROUTER_API_KEY || _optionalChain([systemFile, 'access', _52 => _52.llm, 'optionalAccess', _53 => _53.openrouterApiKey]),
|
|
39
|
+
mistralApiKey: env.MISTRAL_API_KEY || _optionalChain([systemFile, 'access', _54 => _54.llm, 'optionalAccess', _55 => _55.mistralApiKey])
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
}
|
|
@@ -145,43 +145,43 @@ Please use LINGODOTDEV_API_KEY instead.
|
|
|
145
145
|
function _envVarsInfo() {
|
|
146
146
|
const env = _loadEnv();
|
|
147
147
|
const systemFile = _loadSystemFile();
|
|
148
|
-
if (env.LINGODOTDEV_API_KEY && _optionalChain([systemFile, 'access',
|
|
148
|
+
if (env.LINGODOTDEV_API_KEY && _optionalChain([systemFile, 'access', _56 => _56.auth, 'optionalAccess', _57 => _57.apiKey])) {
|
|
149
149
|
console.info(
|
|
150
150
|
"\x1B[36m%s\x1B[0m",
|
|
151
151
|
`\u2139\uFE0F Using LINGODOTDEV_API_KEY env var instead of credentials from user config`
|
|
152
152
|
);
|
|
153
153
|
}
|
|
154
|
-
if (env.OPENAI_API_KEY && _optionalChain([systemFile, 'access',
|
|
154
|
+
if (env.OPENAI_API_KEY && _optionalChain([systemFile, 'access', _58 => _58.llm, 'optionalAccess', _59 => _59.openaiApiKey])) {
|
|
155
155
|
console.info(
|
|
156
156
|
"\x1B[36m%s\x1B[0m",
|
|
157
157
|
`\u2139\uFE0F Using OPENAI_API_KEY env var instead of key from user config.`
|
|
158
158
|
);
|
|
159
159
|
}
|
|
160
|
-
if (env.ANTHROPIC_API_KEY && _optionalChain([systemFile, 'access',
|
|
160
|
+
if (env.ANTHROPIC_API_KEY && _optionalChain([systemFile, 'access', _60 => _60.llm, 'optionalAccess', _61 => _61.anthropicApiKey])) {
|
|
161
161
|
console.info(
|
|
162
162
|
"\x1B[36m%s\x1B[0m",
|
|
163
163
|
`\u2139\uFE0F Using ANTHROPIC_API_KEY env var instead of key from user config`
|
|
164
164
|
);
|
|
165
165
|
}
|
|
166
|
-
if (env.GROQ_API_KEY && _optionalChain([systemFile, 'access',
|
|
166
|
+
if (env.GROQ_API_KEY && _optionalChain([systemFile, 'access', _62 => _62.llm, 'optionalAccess', _63 => _63.groqApiKey])) {
|
|
167
167
|
console.info(
|
|
168
168
|
"\x1B[36m%s\x1B[0m",
|
|
169
169
|
`\u2139\uFE0F Using GROQ_API_KEY env var instead of key from user config`
|
|
170
170
|
);
|
|
171
171
|
}
|
|
172
|
-
if (env.GOOGLE_API_KEY && _optionalChain([systemFile, 'access',
|
|
172
|
+
if (env.GOOGLE_API_KEY && _optionalChain([systemFile, 'access', _64 => _64.llm, 'optionalAccess', _65 => _65.googleApiKey])) {
|
|
173
173
|
console.info(
|
|
174
174
|
"\x1B[36m%s\x1B[0m",
|
|
175
175
|
`\u2139\uFE0F Using GOOGLE_API_KEY env var instead of key from user config`
|
|
176
176
|
);
|
|
177
177
|
}
|
|
178
|
-
if (env.OPENROUTER_API_KEY && _optionalChain([systemFile, 'access',
|
|
178
|
+
if (env.OPENROUTER_API_KEY && _optionalChain([systemFile, 'access', _66 => _66.llm, 'optionalAccess', _67 => _67.openrouterApiKey])) {
|
|
179
179
|
console.info(
|
|
180
180
|
"\x1B[36m%s\x1B[0m",
|
|
181
181
|
`\u2139\uFE0F Using OPENROUTER_API_KEY env var instead of key from user config`
|
|
182
182
|
);
|
|
183
183
|
}
|
|
184
|
-
if (env.MISTRAL_API_KEY && _optionalChain([systemFile, 'access',
|
|
184
|
+
if (env.MISTRAL_API_KEY && _optionalChain([systemFile, 'access', _68 => _68.llm, 'optionalAccess', _69 => _69.mistralApiKey])) {
|
|
185
185
|
console.info(
|
|
186
186
|
"\x1B[36m%s\x1B[0m",
|
|
187
187
|
`\u2139\uFE0F Using MISTRAL_API_KEY env var instead of key from user config`
|
|
@@ -264,10 +264,10 @@ var LocalizationError = (_class5 = class extends Error {
|
|
|
264
264
|
constructor(message, context) {
|
|
265
265
|
super(message);_class5.prototype.__init5.call(this);;
|
|
266
266
|
this.name = "LocalizationError";
|
|
267
|
-
this.bucket = _optionalChain([context, 'optionalAccess',
|
|
268
|
-
this.sourceLocale = _optionalChain([context, 'optionalAccess',
|
|
269
|
-
this.targetLocale = _optionalChain([context, 'optionalAccess',
|
|
270
|
-
this.pathPattern = _optionalChain([context, 'optionalAccess',
|
|
267
|
+
this.bucket = _optionalChain([context, 'optionalAccess', _70 => _70.bucket]);
|
|
268
|
+
this.sourceLocale = _optionalChain([context, 'optionalAccess', _71 => _71.sourceLocale]);
|
|
269
|
+
this.targetLocale = _optionalChain([context, 'optionalAccess', _72 => _72.targetLocale]);
|
|
270
|
+
this.pathPattern = _optionalChain([context, 'optionalAccess', _73 => _73.pathPattern]);
|
|
271
271
|
}
|
|
272
272
|
}, _class5);
|
|
273
273
|
var BucketProcessingError = (_class6 = class extends Error {
|
|
@@ -403,7 +403,7 @@ function createAuthenticator(params) {
|
|
|
403
403
|
});
|
|
404
404
|
if (res.ok) {
|
|
405
405
|
const payload = await res.json();
|
|
406
|
-
if (!_optionalChain([payload, 'optionalAccess',
|
|
406
|
+
if (!_optionalChain([payload, 'optionalAccess', _74 => _74.email])) {
|
|
407
407
|
return null;
|
|
408
408
|
}
|
|
409
409
|
return {
|
|
@@ -598,7 +598,7 @@ async function renderSummary(results) {
|
|
|
598
598
|
if (succeededResults.length > 0) {
|
|
599
599
|
console.log(_chalk2.default.hex(colors.green)("\n[Processed Files]"));
|
|
600
600
|
for (const result of succeededResults) {
|
|
601
|
-
const displayPath = _optionalChain([result, 'access',
|
|
601
|
+
const displayPath = _optionalChain([result, 'access', _75 => _75.pathPattern, 'optionalAccess', _76 => _76.replace, 'call', _77 => _77("[locale]", result.targetLocale)]) || "unknown";
|
|
602
602
|
console.log(
|
|
603
603
|
` \u2713 ${_chalk2.default.dim(displayPath)} ${_chalk2.default.hex(colors.yellow)(`(${result.sourceLocale} \u2192 ${result.targetLocale})`)}`
|
|
604
604
|
);
|
|
@@ -607,7 +607,7 @@ async function renderSummary(results) {
|
|
|
607
607
|
if (skippedResults.length > 0) {
|
|
608
608
|
console.log(_chalk2.default.hex(colors.blue)("\n[Cached Files]"));
|
|
609
609
|
for (const result of skippedResults) {
|
|
610
|
-
const displayPath = _optionalChain([result, 'access',
|
|
610
|
+
const displayPath = _optionalChain([result, 'access', _78 => _78.pathPattern, 'optionalAccess', _79 => _79.replace, 'call', _80 => _80("[locale]", result.targetLocale)]) || "unknown";
|
|
611
611
|
console.log(
|
|
612
612
|
` \u26A1 ${_chalk2.default.dim(displayPath)} ${_chalk2.default.hex(colors.yellow)(`(${result.sourceLocale} \u2192 ${result.targetLocale})`)}`
|
|
613
613
|
);
|
|
@@ -616,12 +616,12 @@ async function renderSummary(results) {
|
|
|
616
616
|
if (failedResults.length > 0) {
|
|
617
617
|
console.log(_chalk2.default.hex(colors.orange)("\n[Failed Files]"));
|
|
618
618
|
for (const result of failedResults) {
|
|
619
|
-
const displayPath = _optionalChain([result, 'access',
|
|
619
|
+
const displayPath = _optionalChain([result, 'access', _81 => _81.pathPattern, 'optionalAccess', _82 => _82.replace, 'call', _83 => _83("[locale]", result.targetLocale)]) || "unknown";
|
|
620
620
|
console.log(
|
|
621
621
|
` \u274C ${_chalk2.default.dim(displayPath)} ${_chalk2.default.hex(colors.yellow)(`(${result.sourceLocale} \u2192 ${result.targetLocale})`)}`
|
|
622
622
|
);
|
|
623
623
|
console.log(
|
|
624
|
-
` ${_chalk2.default.hex(colors.white)(String(_optionalChain([result, 'access',
|
|
624
|
+
` ${_chalk2.default.hex(colors.white)(String(_optionalChain([result, 'access', _84 => _84.error, 'optionalAccess', _85 => _85.message]) || "Unknown error"))}`
|
|
625
625
|
);
|
|
626
626
|
}
|
|
627
627
|
}
|
|
@@ -1267,7 +1267,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
1267
1267
|
});
|
|
1268
1268
|
const auth2 = await newAuthenticator.whoami();
|
|
1269
1269
|
if (auth2) {
|
|
1270
|
-
_ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess',
|
|
1270
|
+
_ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess', _86 => _86.email])}`);
|
|
1271
1271
|
} else {
|
|
1272
1272
|
_ora2.default.call(void 0, ).fail("Authentication failed.");
|
|
1273
1273
|
}
|
|
@@ -1357,7 +1357,7 @@ function getBuckets(i18nConfig) {
|
|
|
1357
1357
|
const includeItems = bucketEntry.include.map(
|
|
1358
1358
|
(item) => resolveBucketItem(item)
|
|
1359
1359
|
);
|
|
1360
|
-
const excludeItems = _optionalChain([bucketEntry, 'access',
|
|
1360
|
+
const excludeItems = _optionalChain([bucketEntry, 'access', _87 => _87.exclude, 'optionalAccess', _88 => _88.map, 'call', _89 => _89(
|
|
1361
1361
|
(item) => resolveBucketItem(item)
|
|
1362
1362
|
)]);
|
|
1363
1363
|
const config = {
|
|
@@ -1395,7 +1395,7 @@ function extractPathPatterns(sourceLocale, include, exclude) {
|
|
|
1395
1395
|
delimiter: pattern.delimiter
|
|
1396
1396
|
}))
|
|
1397
1397
|
);
|
|
1398
|
-
const excludedPatterns = _optionalChain([exclude, 'optionalAccess',
|
|
1398
|
+
const excludedPatterns = _optionalChain([exclude, 'optionalAccess', _90 => _90.flatMap, 'call', _91 => _91(
|
|
1399
1399
|
(pattern) => expandPlaceholderedGlob(
|
|
1400
1400
|
pattern.path,
|
|
1401
1401
|
__spec.resolveOverriddenLocale.call(void 0, sourceLocale, pattern.delimiter)
|
|
@@ -1561,12 +1561,12 @@ function composeLoaders(...loaders) {
|
|
|
1561
1561
|
return {
|
|
1562
1562
|
init: async () => {
|
|
1563
1563
|
for (const loader of loaders) {
|
|
1564
|
-
await _optionalChain([loader, 'access',
|
|
1564
|
+
await _optionalChain([loader, 'access', _92 => _92.init, 'optionalCall', _93 => _93()]);
|
|
1565
1565
|
}
|
|
1566
1566
|
},
|
|
1567
1567
|
setDefaultLocale(locale) {
|
|
1568
1568
|
for (const loader of loaders) {
|
|
1569
|
-
_optionalChain([loader, 'access',
|
|
1569
|
+
_optionalChain([loader, 'access', _94 => _94.setDefaultLocale, 'optionalCall', _95 => _95(locale)]);
|
|
1570
1570
|
}
|
|
1571
1571
|
return this;
|
|
1572
1572
|
},
|
|
@@ -1587,7 +1587,7 @@ function composeLoaders(...loaders) {
|
|
|
1587
1587
|
pullHints: async (originalInput) => {
|
|
1588
1588
|
let result = originalInput;
|
|
1589
1589
|
for (let i = 0; i < loaders.length; i++) {
|
|
1590
|
-
const subResult = await _optionalChain([loaders, 'access',
|
|
1590
|
+
const subResult = await _optionalChain([loaders, 'access', _96 => _96[i], 'access', _97 => _97.pullHints, 'optionalCall', _98 => _98(result)]);
|
|
1591
1591
|
if (subResult) {
|
|
1592
1592
|
result = subResult;
|
|
1593
1593
|
}
|
|
@@ -1609,7 +1609,7 @@ function createLoader(lDefinition) {
|
|
|
1609
1609
|
if (state.initCtx) {
|
|
1610
1610
|
return state.initCtx;
|
|
1611
1611
|
}
|
|
1612
|
-
state.initCtx = await _optionalChain([lDefinition, 'access',
|
|
1612
|
+
state.initCtx = await _optionalChain([lDefinition, 'access', _99 => _99.init, 'optionalCall', _100 => _100()]);
|
|
1613
1613
|
return state.initCtx;
|
|
1614
1614
|
},
|
|
1615
1615
|
setDefaultLocale(locale) {
|
|
@@ -1620,7 +1620,7 @@ function createLoader(lDefinition) {
|
|
|
1620
1620
|
return this;
|
|
1621
1621
|
},
|
|
1622
1622
|
async pullHints() {
|
|
1623
|
-
return _optionalChain([lDefinition, 'access',
|
|
1623
|
+
return _optionalChain([lDefinition, 'access', _101 => _101.pullHints, 'optionalCall', _102 => _102(state.originalInput)]);
|
|
1624
1624
|
},
|
|
1625
1625
|
async pull(locale, input2) {
|
|
1626
1626
|
if (!state.defaultLocale) {
|
|
@@ -1906,7 +1906,7 @@ function createDenormalizeLoader(options) {
|
|
|
1906
1906
|
const preservedObjects = {};
|
|
1907
1907
|
const nonPreservedInput = {};
|
|
1908
1908
|
for (const [key, value] of Object.entries(inputDenormalized)) {
|
|
1909
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
1909
|
+
if (_optionalChain([options, 'optionalAccess', _103 => _103.shouldPreserveObject, 'optionalCall', _104 => _104(value)])) {
|
|
1910
1910
|
preservedObjects[key] = value;
|
|
1911
1911
|
} else {
|
|
1912
1912
|
nonPreservedInput[key] = value;
|
|
@@ -1939,7 +1939,7 @@ function createNormalizeLoader() {
|
|
|
1939
1939
|
return normalized;
|
|
1940
1940
|
},
|
|
1941
1941
|
push: async (locale, data, originalInput) => {
|
|
1942
|
-
const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess',
|
|
1942
|
+
const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess', _105 => _105.keysMap]), () => ( {}));
|
|
1943
1943
|
const input2 = mapDenormalizedKeys(data, keysMap);
|
|
1944
1944
|
const denormalized = _flat.unflatten.call(void 0, input2, {
|
|
1945
1945
|
delimiter: "/",
|
|
@@ -2040,7 +2040,7 @@ function createTextFileLoader(pathPattern) {
|
|
|
2040
2040
|
const trimmedResult = result.trim();
|
|
2041
2041
|
return trimmedResult;
|
|
2042
2042
|
},
|
|
2043
|
-
async push(locale, data,
|
|
2043
|
+
async push(locale, data, _37, originalLocale) {
|
|
2044
2044
|
const draftPath = pathPattern.replaceAll("[locale]", locale);
|
|
2045
2045
|
const finalPath = path14.default.resolve(draftPath);
|
|
2046
2046
|
const dirPath = path14.default.dirname(finalPath);
|
|
@@ -2073,8 +2073,8 @@ async function getTrailingNewLine(pathPattern, locale, originalLocale) {
|
|
|
2073
2073
|
if (!templateData) {
|
|
2074
2074
|
templateData = await readFileForLocale(pathPattern, originalLocale);
|
|
2075
2075
|
}
|
|
2076
|
-
if (_optionalChain([templateData, 'optionalAccess',
|
|
2077
|
-
const ending = _optionalChain([templateData, 'optionalAccess',
|
|
2076
|
+
if (_optionalChain([templateData, 'optionalAccess', _106 => _106.match, 'call', _107 => _107(/[\r\n]$/)])) {
|
|
2077
|
+
const ending = _optionalChain([templateData, 'optionalAccess', _108 => _108.includes, 'call', _109 => _109("\r\n")]) ? "\r\n" : _optionalChain([templateData, 'optionalAccess', _110 => _110.includes, 'call', _111 => _111("\r")]) ? "\r" : "\n";
|
|
2078
2078
|
return ending;
|
|
2079
2079
|
}
|
|
2080
2080
|
return "";
|
|
@@ -2268,7 +2268,7 @@ async function parseAndroidDocument(input2) {
|
|
|
2268
2268
|
const resourceNodes = [];
|
|
2269
2269
|
let metaIndex = 0;
|
|
2270
2270
|
for (const child of resourcesNode.$$) {
|
|
2271
|
-
const elementName = _optionalChain([child, 'optionalAccess',
|
|
2271
|
+
const elementName = _optionalChain([child, 'optionalAccess', _112 => _112["#name"]]);
|
|
2272
2272
|
if (!isResourceElementName(elementName)) {
|
|
2273
2273
|
continue;
|
|
2274
2274
|
}
|
|
@@ -2276,11 +2276,11 @@ async function parseAndroidDocument(input2) {
|
|
|
2276
2276
|
if (!meta || meta.type !== elementName) {
|
|
2277
2277
|
continue;
|
|
2278
2278
|
}
|
|
2279
|
-
const name = _nullishCoalesce(_optionalChain([child, 'optionalAccess',
|
|
2279
|
+
const name = _nullishCoalesce(_optionalChain([child, 'optionalAccess', _113 => _113.$, 'optionalAccess', _114 => _114.name]), () => ( meta.name));
|
|
2280
2280
|
if (!name) {
|
|
2281
2281
|
continue;
|
|
2282
2282
|
}
|
|
2283
|
-
const translatable = (_nullishCoalesce(_optionalChain([child, 'optionalAccess',
|
|
2283
|
+
const translatable = (_nullishCoalesce(_optionalChain([child, 'optionalAccess', _115 => _115.$, 'optionalAccess', _116 => _116.translatable]), () => ( ""))).toLowerCase() !== "false";
|
|
2284
2284
|
switch (meta.type) {
|
|
2285
2285
|
case "string": {
|
|
2286
2286
|
resourceNodes.push({
|
|
@@ -2293,7 +2293,7 @@ async function parseAndroidDocument(input2) {
|
|
|
2293
2293
|
break;
|
|
2294
2294
|
}
|
|
2295
2295
|
case "string-array": {
|
|
2296
|
-
const itemNodes = _nullishCoalesce(_optionalChain([child, 'optionalAccess',
|
|
2296
|
+
const itemNodes = _nullishCoalesce(_optionalChain([child, 'optionalAccess', _117 => _117.item]), () => ( []));
|
|
2297
2297
|
const items = [];
|
|
2298
2298
|
const templateItems = meta.items;
|
|
2299
2299
|
for (let i = 0; i < Math.max(itemNodes.length, templateItems.length); i++) {
|
|
@@ -2317,7 +2317,7 @@ async function parseAndroidDocument(input2) {
|
|
|
2317
2317
|
break;
|
|
2318
2318
|
}
|
|
2319
2319
|
case "plurals": {
|
|
2320
|
-
const itemNodes = _nullishCoalesce(_optionalChain([child, 'optionalAccess',
|
|
2320
|
+
const itemNodes = _nullishCoalesce(_optionalChain([child, 'optionalAccess', _118 => _118.item]), () => ( []));
|
|
2321
2321
|
const templateItems = meta.items;
|
|
2322
2322
|
const items = [];
|
|
2323
2323
|
for (const templateItem of templateItems) {
|
|
@@ -2326,7 +2326,7 @@ async function parseAndroidDocument(input2) {
|
|
|
2326
2326
|
continue;
|
|
2327
2327
|
}
|
|
2328
2328
|
const nodeItem = itemNodes.find(
|
|
2329
|
-
(item) => _optionalChain([item, 'optionalAccess',
|
|
2329
|
+
(item) => _optionalChain([item, 'optionalAccess', _119 => _119.$, 'optionalAccess', _120 => _120.quantity]) === quantity
|
|
2330
2330
|
);
|
|
2331
2331
|
if (!nodeItem) {
|
|
2332
2332
|
continue;
|
|
@@ -2607,7 +2607,7 @@ function cloneResourceNode(resource) {
|
|
|
2607
2607
|
const nodeClone = deepClone(resource.node);
|
|
2608
2608
|
const itemNodes = _nullishCoalesce(nodeClone.item, () => ( []));
|
|
2609
2609
|
const items = itemNodes.map((itemNode, index) => {
|
|
2610
|
-
const templateMeta = _nullishCoalesce(_nullishCoalesce(_optionalChain([resource, 'access',
|
|
2610
|
+
const templateMeta = _nullishCoalesce(_nullishCoalesce(_optionalChain([resource, 'access', _121 => _121.items, 'access', _122 => _122[index], 'optionalAccess', _123 => _123.meta]), () => ( _optionalChain([resource, 'access', _124 => _124.items, 'access', _125 => _125[resource.items.length - 1], 'optionalAccess', _126 => _126.meta]))), () => ( makeTextMeta([])));
|
|
2611
2611
|
return {
|
|
2612
2612
|
node: itemNode,
|
|
2613
2613
|
meta: cloneTextMeta(templateMeta)
|
|
@@ -2627,7 +2627,7 @@ function cloneResourceNode(resource) {
|
|
|
2627
2627
|
const items = [];
|
|
2628
2628
|
for (const templateItem of resource.items) {
|
|
2629
2629
|
const cloneNode = itemNodes.find(
|
|
2630
|
-
(item) => _optionalChain([item, 'optionalAccess',
|
|
2630
|
+
(item) => _optionalChain([item, 'optionalAccess', _127 => _127.$, 'optionalAccess', _128 => _128.quantity]) === templateItem.quantity
|
|
2631
2631
|
);
|
|
2632
2632
|
if (!cloneNode) {
|
|
2633
2633
|
continue;
|
|
@@ -2883,8 +2883,8 @@ function cloneDocumentStructure(document) {
|
|
|
2883
2883
|
resourceNodes.map((r) => resourceLookupKey(r.type, r.name))
|
|
2884
2884
|
);
|
|
2885
2885
|
let filtered = resourcesClone.$$.filter((child) => {
|
|
2886
|
-
const elementName = _optionalChain([child, 'optionalAccess',
|
|
2887
|
-
const name = _optionalChain([child, 'optionalAccess',
|
|
2886
|
+
const elementName = _optionalChain([child, 'optionalAccess', _129 => _129["#name"]]);
|
|
2887
|
+
const name = _optionalChain([child, 'optionalAccess', _130 => _130.$, 'optionalAccess', _131 => _131.name]);
|
|
2888
2888
|
if (!isResourceElementName(elementName) || !name) {
|
|
2889
2889
|
return true;
|
|
2890
2890
|
}
|
|
@@ -2893,7 +2893,7 @@ function cloneDocumentStructure(document) {
|
|
|
2893
2893
|
const cleaned = [];
|
|
2894
2894
|
let lastWasWhitespace = false;
|
|
2895
2895
|
for (const child of filtered) {
|
|
2896
|
-
const isWhitespace = _optionalChain([child, 'optionalAccess',
|
|
2896
|
+
const isWhitespace = _optionalChain([child, 'optionalAccess', _132 => _132["#name"]]) === "__text__" && (!child._ || child._.trim() === "");
|
|
2897
2897
|
if (isWhitespace) {
|
|
2898
2898
|
if (!lastWasWhitespace) {
|
|
2899
2899
|
cleaned.push(child);
|
|
@@ -2915,8 +2915,8 @@ function buildResourceLookup(resources) {
|
|
|
2915
2915
|
const lookup = /* @__PURE__ */ new Map();
|
|
2916
2916
|
const children = Array.isArray(resources.$$) ? resources.$$ : [];
|
|
2917
2917
|
for (const child of children) {
|
|
2918
|
-
const type = _optionalChain([child, 'optionalAccess',
|
|
2919
|
-
const name = _optionalChain([child, 'optionalAccess',
|
|
2918
|
+
const type = _optionalChain([child, 'optionalAccess', _133 => _133["#name"]]);
|
|
2919
|
+
const name = _optionalChain([child, 'optionalAccess', _134 => _134.$, 'optionalAccess', _135 => _135.name]);
|
|
2920
2920
|
if (!type || !name || !isResourceElementName(type)) {
|
|
2921
2921
|
continue;
|
|
2922
2922
|
}
|
|
@@ -2945,7 +2945,7 @@ function cloneResourceNodeFromLookup(resource, lookup) {
|
|
|
2945
2945
|
}
|
|
2946
2946
|
case "string-array": {
|
|
2947
2947
|
const childItems = (Array.isArray(node.$$) ? node.$$ : []).filter(
|
|
2948
|
-
(child) => _optionalChain([child, 'optionalAccess',
|
|
2948
|
+
(child) => _optionalChain([child, 'optionalAccess', _136 => _136["#name"]]) === "item"
|
|
2949
2949
|
);
|
|
2950
2950
|
node.item = childItems;
|
|
2951
2951
|
if (childItems.length < resource.items.length) {
|
|
@@ -2974,12 +2974,12 @@ function cloneResourceNodeFromLookup(resource, lookup) {
|
|
|
2974
2974
|
}
|
|
2975
2975
|
case "plurals": {
|
|
2976
2976
|
const childItems = (Array.isArray(node.$$) ? node.$$ : []).filter(
|
|
2977
|
-
(child) => _optionalChain([child, 'optionalAccess',
|
|
2977
|
+
(child) => _optionalChain([child, 'optionalAccess', _137 => _137["#name"]]) === "item"
|
|
2978
2978
|
);
|
|
2979
2979
|
node.item = childItems;
|
|
2980
2980
|
const itemMap = /* @__PURE__ */ new Map();
|
|
2981
2981
|
for (const item of childItems) {
|
|
2982
|
-
if (_optionalChain([item, 'optionalAccess',
|
|
2982
|
+
if (_optionalChain([item, 'optionalAccess', _138 => _138.$, 'optionalAccess', _139 => _139.quantity])) {
|
|
2983
2983
|
itemMap.set(item.$.quantity, item);
|
|
2984
2984
|
}
|
|
2985
2985
|
}
|
|
@@ -3269,7 +3269,7 @@ var _sync3 = require('csv-stringify/sync');
|
|
|
3269
3269
|
|
|
3270
3270
|
function detectKeyColumnName(csvString) {
|
|
3271
3271
|
const row = _sync.parse.call(void 0, csvString)[0];
|
|
3272
|
-
const firstColumn = _optionalChain([row, 'optionalAccess',
|
|
3272
|
+
const firstColumn = _optionalChain([row, 'optionalAccess', _140 => _140[0], 'optionalAccess', _141 => _141.trim, 'call', _142 => _142()]);
|
|
3273
3273
|
return firstColumn || "KEY";
|
|
3274
3274
|
}
|
|
3275
3275
|
function createCsvLoader() {
|
|
@@ -3371,7 +3371,7 @@ function createHtmlLoader() {
|
|
|
3371
3371
|
break;
|
|
3372
3372
|
}
|
|
3373
3373
|
const siblings = Array.from(parent.childNodes).filter(
|
|
3374
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
3374
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _143 => _143.textContent, 'optionalAccess', _144 => _144.trim, 'call', _145 => _145()])
|
|
3375
3375
|
);
|
|
3376
3376
|
const index = siblings.indexOf(current);
|
|
3377
3377
|
if (index !== -1) {
|
|
@@ -3407,15 +3407,15 @@ function createHtmlLoader() {
|
|
|
3407
3407
|
}
|
|
3408
3408
|
});
|
|
3409
3409
|
Array.from(element.childNodes).filter(
|
|
3410
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
3410
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _146 => _146.textContent, 'optionalAccess', _147 => _147.trim, 'call', _148 => _148()])
|
|
3411
3411
|
).forEach(processNode);
|
|
3412
3412
|
}
|
|
3413
3413
|
};
|
|
3414
3414
|
Array.from(document.head.childNodes).filter(
|
|
3415
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
3415
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _149 => _149.textContent, 'optionalAccess', _150 => _150.trim, 'call', _151 => _151()])
|
|
3416
3416
|
).forEach(processNode);
|
|
3417
3417
|
Array.from(document.body.childNodes).filter(
|
|
3418
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
3418
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _152 => _152.textContent, 'optionalAccess', _153 => _153.trim, 'call', _154 => _154()])
|
|
3419
3419
|
).forEach(processNode);
|
|
3420
3420
|
return result;
|
|
3421
3421
|
},
|
|
@@ -3440,7 +3440,7 @@ function createHtmlLoader() {
|
|
|
3440
3440
|
for (let i = 0; i < indices.length; i++) {
|
|
3441
3441
|
const index = parseInt(indices[i]);
|
|
3442
3442
|
const siblings = Array.from(parent.childNodes).filter(
|
|
3443
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
3443
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _155 => _155.textContent, 'optionalAccess', _156 => _156.trim, 'call', _157 => _157()])
|
|
3444
3444
|
);
|
|
3445
3445
|
if (index >= siblings.length) {
|
|
3446
3446
|
if (i === indices.length - 1) {
|
|
@@ -3491,7 +3491,7 @@ function createMarkdownLoader() {
|
|
|
3491
3491
|
yaml: yamlEngine
|
|
3492
3492
|
}
|
|
3493
3493
|
});
|
|
3494
|
-
const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess',
|
|
3494
|
+
const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess', _158 => _158.trim, 'call', _159 => _159()]), () => ( ""))).filter(Boolean);
|
|
3495
3495
|
return {
|
|
3496
3496
|
...Object.fromEntries(
|
|
3497
3497
|
sections.map((section, index) => [`${MD_SECTION_PREFIX}${index}`, section]).filter(([, section]) => Boolean(section))
|
|
@@ -3510,7 +3510,7 @@ function createMarkdownLoader() {
|
|
|
3510
3510
|
);
|
|
3511
3511
|
let content = Object.entries(data).filter(([key]) => key.startsWith(MD_SECTION_PREFIX)).sort(
|
|
3512
3512
|
([a], [b]) => Number(a.split("-").pop()) - Number(b.split("-").pop())
|
|
3513
|
-
).map(([, value]) => _nullishCoalesce(_optionalChain([value, 'optionalAccess',
|
|
3513
|
+
).map(([, value]) => _nullishCoalesce(_optionalChain([value, 'optionalAccess', _160 => _160.trim, 'call', _161 => _161()]), () => ( ""))).filter(Boolean).join("\n\n");
|
|
3514
3514
|
if (Object.keys(frontmatter).length > 0) {
|
|
3515
3515
|
content = `
|
|
3516
3516
|
${content}`;
|
|
@@ -3535,7 +3535,7 @@ function createMarkdocLoader() {
|
|
|
3535
3535
|
const result = {};
|
|
3536
3536
|
const counters = {};
|
|
3537
3537
|
traverseAndExtract(ast, "", result, counters);
|
|
3538
|
-
if (_optionalChain([ast, 'access',
|
|
3538
|
+
if (_optionalChain([ast, 'access', _162 => _162.attributes, 'optionalAccess', _163 => _163.frontmatter])) {
|
|
3539
3539
|
const frontmatter = _yaml2.default.parse(ast.attributes.frontmatter);
|
|
3540
3540
|
Object.entries(frontmatter).forEach(([key, value]) => {
|
|
3541
3541
|
if (typeof value === "string") {
|
|
@@ -3581,7 +3581,7 @@ function traverseAndExtract(node, path19, result, counters, parentType) {
|
|
|
3581
3581
|
if (nodeSemanticType && !["text", "strong", "em", "inline", "link"].includes(nodeSemanticType)) {
|
|
3582
3582
|
semanticType = nodeSemanticType;
|
|
3583
3583
|
}
|
|
3584
|
-
if (node.type === "text" && _optionalChain([node, 'access',
|
|
3584
|
+
if (node.type === "text" && _optionalChain([node, 'access', _164 => _164.attributes, 'optionalAccess', _165 => _165.content])) {
|
|
3585
3585
|
const content = node.attributes.content;
|
|
3586
3586
|
if (typeof content === "string" && content.trim()) {
|
|
3587
3587
|
if (semanticType) {
|
|
@@ -3608,7 +3608,7 @@ function buildPathMap(node, path19, counters, pathMap, parentType) {
|
|
|
3608
3608
|
if (nodeSemanticType && !["text", "strong", "em", "inline", "link"].includes(nodeSemanticType)) {
|
|
3609
3609
|
semanticType = nodeSemanticType;
|
|
3610
3610
|
}
|
|
3611
|
-
if (node.type === "text" && _optionalChain([node, 'access',
|
|
3611
|
+
if (node.type === "text" && _optionalChain([node, 'access', _166 => _166.attributes, 'optionalAccess', _167 => _167.content])) {
|
|
3612
3612
|
const content = node.attributes.content;
|
|
3613
3613
|
if (typeof content === "string" && content.trim()) {
|
|
3614
3614
|
if (semanticType) {
|
|
@@ -3631,7 +3631,7 @@ function applyTranslations(node, path19, data, pathMap) {
|
|
|
3631
3631
|
if (!node || typeof node !== "object") {
|
|
3632
3632
|
return;
|
|
3633
3633
|
}
|
|
3634
|
-
if (node.type === "text" && _optionalChain([node, 'access',
|
|
3634
|
+
if (node.type === "text" && _optionalChain([node, 'access', _168 => _168.attributes, 'optionalAccess', _169 => _169.content])) {
|
|
3635
3635
|
const content = node.attributes.content;
|
|
3636
3636
|
if (typeof content === "string") {
|
|
3637
3637
|
const contentPath = path19 ? `${path19}/attributes/content` : "attributes/content";
|
|
@@ -3670,7 +3670,7 @@ function createPropertiesLoader() {
|
|
|
3670
3670
|
return result;
|
|
3671
3671
|
},
|
|
3672
3672
|
async push(locale, payload) {
|
|
3673
|
-
const result = Object.entries(payload).filter(([
|
|
3673
|
+
const result = Object.entries(payload).filter(([_37, value]) => value != null).map(([key, value]) => `${key}=${value}`).join("\n");
|
|
3674
3674
|
return result;
|
|
3675
3675
|
}
|
|
3676
3676
|
});
|
|
@@ -3681,7 +3681,7 @@ function isSkippableLine(line) {
|
|
|
3681
3681
|
function parsePropertyLine(line) {
|
|
3682
3682
|
const [key, ...valueParts] = line.split("=");
|
|
3683
3683
|
return {
|
|
3684
|
-
key: _optionalChain([key, 'optionalAccess',
|
|
3684
|
+
key: _optionalChain([key, 'optionalAccess', _170 => _170.trim, 'call', _171 => _171()]) || "",
|
|
3685
3685
|
value: valueParts.join("=").trim()
|
|
3686
3686
|
};
|
|
3687
3687
|
}
|
|
@@ -3973,7 +3973,7 @@ var Parser = class {
|
|
|
3973
3973
|
}
|
|
3974
3974
|
}
|
|
3975
3975
|
expect(type) {
|
|
3976
|
-
if (_optionalChain([this, 'access',
|
|
3976
|
+
if (_optionalChain([this, 'access', _172 => _172.current, 'call', _173 => _173(), 'optionalAccess', _174 => _174.type]) === type) {
|
|
3977
3977
|
this.advance();
|
|
3978
3978
|
return true;
|
|
3979
3979
|
}
|
|
@@ -3992,7 +3992,7 @@ function createXcodeStringsLoader() {
|
|
|
3992
3992
|
return result;
|
|
3993
3993
|
},
|
|
3994
3994
|
async push(locale, payload) {
|
|
3995
|
-
const lines = Object.entries(payload).filter(([
|
|
3995
|
+
const lines = Object.entries(payload).filter(([_37, value]) => value != null).map(([key, value]) => {
|
|
3996
3996
|
const escapedValue = escapeString(value);
|
|
3997
3997
|
return `"${key}" = "${escapedValue}";`;
|
|
3998
3998
|
});
|
|
@@ -4050,16 +4050,21 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
4050
4050
|
if (rootTranslationEntity.shouldTranslate === false) {
|
|
4051
4051
|
continue;
|
|
4052
4052
|
}
|
|
4053
|
-
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess',
|
|
4053
|
+
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _175 => _175.localizations, 'optionalAccess', _176 => _176[locale]]);
|
|
4054
4054
|
if (langTranslationEntity) {
|
|
4055
4055
|
if ("stringUnit" in langTranslationEntity) {
|
|
4056
4056
|
resultData[translationKey] = langTranslationEntity.stringUnit.value;
|
|
4057
|
+
} else if ("stringSet" in langTranslationEntity) {
|
|
4058
|
+
const values = langTranslationEntity.stringSet.values;
|
|
4059
|
+
if (Array.isArray(values) && values.length > 0) {
|
|
4060
|
+
resultData[translationKey] = values;
|
|
4061
|
+
}
|
|
4057
4062
|
} else if ("variations" in langTranslationEntity) {
|
|
4058
4063
|
if ("plural" in langTranslationEntity.variations) {
|
|
4059
4064
|
resultData[translationKey] = {};
|
|
4060
4065
|
const pluralForms = langTranslationEntity.variations.plural;
|
|
4061
4066
|
for (const form in pluralForms) {
|
|
4062
|
-
if (_optionalChain([pluralForms, 'access',
|
|
4067
|
+
if (_optionalChain([pluralForms, 'access', _177 => _177[form], 'optionalAccess', _178 => _178.stringUnit, 'optionalAccess', _179 => _179.value])) {
|
|
4063
4068
|
resultData[translationKey][form] = pluralForms[form].stringUnit.value;
|
|
4064
4069
|
}
|
|
4065
4070
|
}
|
|
@@ -4085,7 +4090,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
4085
4090
|
const hasDoNotTranslateFlag = originalInput && originalInput.strings && originalInput.strings[key] && originalInput.strings[key].shouldTranslate === false;
|
|
4086
4091
|
if (typeof value === "string") {
|
|
4087
4092
|
langDataToMerge.strings[key] = {
|
|
4088
|
-
extractionState: _optionalChain([originalInput, 'optionalAccess',
|
|
4093
|
+
extractionState: _optionalChain([originalInput, 'optionalAccess', _180 => _180.strings, 'optionalAccess', _181 => _181[key], 'optionalAccess', _182 => _182.extractionState]),
|
|
4089
4094
|
localizations: {
|
|
4090
4095
|
[locale]: {
|
|
4091
4096
|
stringUnit: {
|
|
@@ -4098,6 +4103,21 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
4098
4103
|
if (hasDoNotTranslateFlag) {
|
|
4099
4104
|
langDataToMerge.strings[key].shouldTranslate = false;
|
|
4100
4105
|
}
|
|
4106
|
+
} else if (Array.isArray(value)) {
|
|
4107
|
+
langDataToMerge.strings[key] = {
|
|
4108
|
+
extractionState: _optionalChain([originalInput, 'optionalAccess', _183 => _183.strings, 'optionalAccess', _184 => _184[key], 'optionalAccess', _185 => _185.extractionState]),
|
|
4109
|
+
localizations: {
|
|
4110
|
+
[locale]: {
|
|
4111
|
+
stringSet: {
|
|
4112
|
+
state: "translated",
|
|
4113
|
+
values: value
|
|
4114
|
+
}
|
|
4115
|
+
}
|
|
4116
|
+
}
|
|
4117
|
+
};
|
|
4118
|
+
if (hasDoNotTranslateFlag) {
|
|
4119
|
+
langDataToMerge.strings[key].shouldTranslate = false;
|
|
4120
|
+
}
|
|
4101
4121
|
} else {
|
|
4102
4122
|
const updatedVariations = {};
|
|
4103
4123
|
for (const form in value) {
|
|
@@ -4143,7 +4163,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
4143
4163
|
for (const [locale, localization] of Object.entries(
|
|
4144
4164
|
entity.localizations
|
|
4145
4165
|
)) {
|
|
4146
|
-
if (_optionalChain([localization, 'access',
|
|
4166
|
+
if (_optionalChain([localization, 'access', _186 => _186.variations, 'optionalAccess', _187 => _187.plural])) {
|
|
4147
4167
|
const pluralForms = localization.variations.plural;
|
|
4148
4168
|
for (const form in pluralForms) {
|
|
4149
4169
|
const pluralKey = `${translationKey}/${form}`;
|
|
@@ -4163,225 +4183,28 @@ function _removeLocale(input2, locale) {
|
|
|
4163
4183
|
const { strings } = input2;
|
|
4164
4184
|
const newStrings = _lodash2.default.cloneDeep(strings);
|
|
4165
4185
|
for (const [key, value] of Object.entries(newStrings)) {
|
|
4166
|
-
if (_optionalChain([value, 'access',
|
|
4186
|
+
if (_optionalChain([value, 'access', _188 => _188.localizations, 'optionalAccess', _189 => _189[locale]])) {
|
|
4167
4187
|
delete value.localizations[locale];
|
|
4168
4188
|
}
|
|
4169
4189
|
}
|
|
4170
4190
|
return { ...input2, strings: newStrings };
|
|
4171
4191
|
}
|
|
4172
4192
|
|
|
4173
|
-
// src/cli/loaders/xcode-xcstrings-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
"two",
|
|
4179
|
-
"few",
|
|
4180
|
-
"many",
|
|
4181
|
-
"other"
|
|
4182
|
-
]);
|
|
4183
|
-
function isICUPluralObject(value) {
|
|
4184
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
4185
|
-
return false;
|
|
4186
|
-
}
|
|
4187
|
-
if (ICU_TYPE_MARKER in value) {
|
|
4188
|
-
return true;
|
|
4189
|
-
}
|
|
4190
|
-
if (!("icu" in value) || typeof value.icu !== "string") {
|
|
4191
|
-
return false;
|
|
4192
|
-
}
|
|
4193
|
-
const icuPluralPattern = /^\{[\w]+,\s*plural,\s*.+\}$/;
|
|
4194
|
-
if (!icuPluralPattern.test(value.icu)) {
|
|
4195
|
-
return false;
|
|
4196
|
-
}
|
|
4197
|
-
if (value._meta !== void 0) {
|
|
4198
|
-
if (typeof value._meta !== "object" || !value._meta.variables || typeof value._meta.variables !== "object") {
|
|
4199
|
-
return false;
|
|
4200
|
-
}
|
|
4201
|
-
for (const [varName, varMeta] of Object.entries(value._meta.variables)) {
|
|
4202
|
-
if (!varMeta || typeof varMeta !== "object" || typeof varMeta.format !== "string" || varMeta.role !== "plural" && varMeta.role !== "other") {
|
|
4203
|
-
return false;
|
|
4204
|
-
}
|
|
4205
|
-
}
|
|
4206
|
-
}
|
|
4207
|
-
return true;
|
|
4208
|
-
}
|
|
4209
|
-
function isPluralFormsObject(value) {
|
|
4210
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
4211
|
-
return false;
|
|
4212
|
-
}
|
|
4213
|
-
const keys = Object.keys(value);
|
|
4214
|
-
if (keys.length === 0) {
|
|
4215
|
-
return false;
|
|
4216
|
-
}
|
|
4217
|
-
const allKeysAreCldr = keys.every((key) => CLDR_PLURAL_CATEGORIES.has(key));
|
|
4218
|
-
if (!allKeysAreCldr) {
|
|
4219
|
-
return false;
|
|
4220
|
-
}
|
|
4221
|
-
const allValuesAreStrings = keys.every(
|
|
4222
|
-
(key) => typeof value[key] === "string"
|
|
4193
|
+
// src/cli/loaders/xcode-xcstrings-v2.ts
|
|
4194
|
+
|
|
4195
|
+
function buildIcuPluralString(forms) {
|
|
4196
|
+
const parts = Object.entries(forms).map(
|
|
4197
|
+
([form, text]) => `${form} {${text}}`
|
|
4223
4198
|
);
|
|
4224
|
-
|
|
4225
|
-
return false;
|
|
4226
|
-
}
|
|
4227
|
-
if (!("other" in value)) {
|
|
4228
|
-
return false;
|
|
4229
|
-
}
|
|
4230
|
-
return true;
|
|
4199
|
+
return `{count, plural, ${parts.join(" ")}}`;
|
|
4231
4200
|
}
|
|
4232
|
-
function
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
if (!categories || categories.length === 0) {
|
|
4237
|
-
throw new Error(`No plural categories found for locale: ${locale}`);
|
|
4238
|
-
}
|
|
4239
|
-
return categories;
|
|
4240
|
-
} catch (error) {
|
|
4241
|
-
console.warn(
|
|
4242
|
-
`[xcode-xcstrings-icu] Failed to resolve plural categories for locale "${locale}". Using fallback ["one", "other"]. Error: ${error instanceof Error ? error.message : String(error)}`
|
|
4243
|
-
);
|
|
4244
|
-
return ["one", "other"];
|
|
4245
|
-
}
|
|
4246
|
-
}
|
|
4247
|
-
var CLDR_CATEGORY_TO_NUMBER = {
|
|
4248
|
-
zero: 0,
|
|
4249
|
-
one: 1,
|
|
4250
|
-
two: 2
|
|
4251
|
-
};
|
|
4252
|
-
var NUMBER_TO_CLDR_CATEGORY = {
|
|
4253
|
-
0: "zero",
|
|
4254
|
-
1: "one",
|
|
4255
|
-
2: "two"
|
|
4256
|
-
};
|
|
4257
|
-
function xcstringsToPluralWithMeta(pluralForms, sourceLocale = "en") {
|
|
4258
|
-
if (!pluralForms || Object.keys(pluralForms).length === 0) {
|
|
4259
|
-
throw new Error("pluralForms cannot be empty");
|
|
4260
|
-
}
|
|
4261
|
-
const requiredCategories = getRequiredPluralCategories(sourceLocale);
|
|
4262
|
-
const variables = {};
|
|
4263
|
-
const formatRegex = /(%(?:(\d+)\$)?(?:[+-])?(?:\d+)?(?:\.(\d+))?([lhqLzjt]*)([diuoxXfFeEgGaAcspn@]))/g;
|
|
4264
|
-
let maxMatches = [];
|
|
4265
|
-
let maxMatchText = "";
|
|
4266
|
-
for (const [form, text] of Object.entries(pluralForms)) {
|
|
4267
|
-
if (typeof text !== "string") {
|
|
4268
|
-
console.warn(
|
|
4269
|
-
`Warning: Plural form "${form}" has non-string value:`,
|
|
4270
|
-
text
|
|
4271
|
-
);
|
|
4272
|
-
continue;
|
|
4273
|
-
}
|
|
4274
|
-
const matches = [...text.matchAll(formatRegex)];
|
|
4275
|
-
if (matches.length > maxMatches.length) {
|
|
4276
|
-
maxMatches = matches;
|
|
4277
|
-
maxMatchText = text;
|
|
4278
|
-
}
|
|
4279
|
-
}
|
|
4280
|
-
let lastNumericIndex = -1;
|
|
4281
|
-
maxMatches.forEach((match2, idx) => {
|
|
4282
|
-
const specifier = match2[5];
|
|
4283
|
-
if (/[diuoxXfFeE]/.test(specifier)) {
|
|
4284
|
-
lastNumericIndex = idx;
|
|
4285
|
-
}
|
|
4286
|
-
});
|
|
4287
|
-
let nonPluralCounter = 0;
|
|
4288
|
-
maxMatches.forEach((match2, idx) => {
|
|
4289
|
-
const fullFormat = match2[1];
|
|
4290
|
-
const position = match2[2];
|
|
4291
|
-
const precision = match2[3];
|
|
4292
|
-
const lengthMod = match2[4];
|
|
4293
|
-
const specifier = match2[5];
|
|
4294
|
-
const isPluralVar = idx === lastNumericIndex;
|
|
4295
|
-
const varName = isPluralVar ? "count" : `var${nonPluralCounter++}`;
|
|
4296
|
-
variables[varName] = {
|
|
4297
|
-
format: fullFormat,
|
|
4298
|
-
role: isPluralVar ? "plural" : "other"
|
|
4299
|
-
};
|
|
4300
|
-
});
|
|
4301
|
-
const variableKeys = Object.keys(variables);
|
|
4302
|
-
const icuForms = Object.entries(pluralForms).filter(([form, text]) => {
|
|
4303
|
-
if (typeof text !== "string") {
|
|
4304
|
-
return false;
|
|
4305
|
-
}
|
|
4306
|
-
return true;
|
|
4307
|
-
}).map(([form, text]) => {
|
|
4308
|
-
let processed = text;
|
|
4309
|
-
let vIdx = 0;
|
|
4310
|
-
processed = processed.replace(formatRegex, () => {
|
|
4311
|
-
if (vIdx >= variableKeys.length) {
|
|
4312
|
-
vIdx++;
|
|
4313
|
-
return "#";
|
|
4314
|
-
}
|
|
4315
|
-
const varName = variableKeys[vIdx];
|
|
4316
|
-
const varMeta = variables[varName];
|
|
4317
|
-
vIdx++;
|
|
4318
|
-
if (varMeta.role === "plural") {
|
|
4319
|
-
return "#";
|
|
4320
|
-
} else {
|
|
4321
|
-
return `{${varName}}`;
|
|
4322
|
-
}
|
|
4323
|
-
});
|
|
4324
|
-
const isRequired = requiredCategories.includes(form);
|
|
4325
|
-
const formKey = !isRequired && form in CLDR_CATEGORY_TO_NUMBER ? `=${CLDR_CATEGORY_TO_NUMBER[form]}` : form;
|
|
4326
|
-
return `${formKey} {${processed}}`;
|
|
4327
|
-
}).join(" ");
|
|
4328
|
-
const pluralVarName = Object.keys(variables).find((name) => variables[name].role === "plural") || "count";
|
|
4329
|
-
const icu = `{${pluralVarName}, plural, ${icuForms}}`;
|
|
4330
|
-
const result = {
|
|
4331
|
-
icu,
|
|
4332
|
-
_meta: Object.keys(variables).length > 0 ? { variables } : void 0,
|
|
4333
|
-
[ICU_TYPE_MARKER]: true
|
|
4334
|
-
// Add type marker for robust detection
|
|
4335
|
-
};
|
|
4336
|
-
return result;
|
|
4337
|
-
}
|
|
4338
|
-
function pluralWithMetaToXcstrings(data) {
|
|
4339
|
-
if (!data.icu) {
|
|
4340
|
-
throw new Error("ICU string is required");
|
|
4341
|
-
}
|
|
4342
|
-
const ast = parseICU(data.icu);
|
|
4343
|
-
if (!ast || ast.length === 0) {
|
|
4344
|
-
throw new Error("Invalid ICU format");
|
|
4345
|
-
}
|
|
4346
|
-
const pluralNode = ast.find((node) => node.type === "plural");
|
|
4347
|
-
if (!pluralNode) {
|
|
4348
|
-
throw new Error("No plural found in ICU format");
|
|
4201
|
+
function parseIcuPluralString(icuString) {
|
|
4202
|
+
const pluralMatch = icuString.match(/\{[\w]+,\s*plural,\s*(.+)\}$/);
|
|
4203
|
+
if (!pluralMatch) {
|
|
4204
|
+
throw new Error(`Invalid ICU plural format: ${icuString}`);
|
|
4349
4205
|
}
|
|
4206
|
+
const formsText = pluralMatch[1];
|
|
4350
4207
|
const forms = {};
|
|
4351
|
-
for (const [form, option] of Object.entries(pluralNode.options)) {
|
|
4352
|
-
let text = "";
|
|
4353
|
-
const optionValue = option.value;
|
|
4354
|
-
for (const element of optionValue) {
|
|
4355
|
-
if (element.type === "literal") {
|
|
4356
|
-
text += element.value;
|
|
4357
|
-
} else if (element.type === "pound") {
|
|
4358
|
-
const pluralVar = Object.entries(_optionalChain([data, 'access', _186 => _186._meta, 'optionalAccess', _187 => _187.variables]) || {}).find(
|
|
4359
|
-
([_36, meta]) => meta.role === "plural"
|
|
4360
|
-
);
|
|
4361
|
-
text += _optionalChain([pluralVar, 'optionalAccess', _188 => _188[1], 'access', _189 => _189.format]) || "%lld";
|
|
4362
|
-
} else if (element.type === "argument") {
|
|
4363
|
-
const varName = element.value;
|
|
4364
|
-
const varMeta = _optionalChain([data, 'access', _190 => _190._meta, 'optionalAccess', _191 => _191.variables, 'optionalAccess', _192 => _192[varName]]);
|
|
4365
|
-
text += _optionalChain([varMeta, 'optionalAccess', _193 => _193.format]) || "%@";
|
|
4366
|
-
}
|
|
4367
|
-
}
|
|
4368
|
-
let xcstringsFormName = form;
|
|
4369
|
-
if (form.startsWith("=")) {
|
|
4370
|
-
const numValue = parseInt(form.substring(1), 10);
|
|
4371
|
-
xcstringsFormName = NUMBER_TO_CLDR_CATEGORY[numValue] || form;
|
|
4372
|
-
}
|
|
4373
|
-
forms[xcstringsFormName] = text;
|
|
4374
|
-
}
|
|
4375
|
-
return forms;
|
|
4376
|
-
}
|
|
4377
|
-
function parseICU(icu) {
|
|
4378
|
-
const match2 = icu.match(/\{(\w+),\s*plural,\s*(.+)\}$/);
|
|
4379
|
-
if (!match2) {
|
|
4380
|
-
throw new Error("Invalid ICU plural format");
|
|
4381
|
-
}
|
|
4382
|
-
const varName = match2[1];
|
|
4383
|
-
const formsText = match2[2];
|
|
4384
|
-
const options = {};
|
|
4385
4208
|
let i = 0;
|
|
4386
4209
|
while (i < formsText.length) {
|
|
4387
4210
|
while (i < formsText.length && /\s/.test(formsText[i])) {
|
|
@@ -4427,119 +4250,198 @@ function parseICU(icu) {
|
|
|
4427
4250
|
i++;
|
|
4428
4251
|
}
|
|
4429
4252
|
if (braceCount !== 0) {
|
|
4430
|
-
const preview = formsText.substring(
|
|
4431
|
-
Math.max(0, i - 50),
|
|
4432
|
-
Math.min(formsText.length, i + 50)
|
|
4433
|
-
);
|
|
4434
4253
|
throw new Error(
|
|
4435
|
-
`Unclosed brace for form '${formName}' in ICU
|
|
4436
|
-
Expected ${braceCount} more closing brace(s).
|
|
4437
|
-
Context: ...${preview}...
|
|
4438
|
-
Full ICU: {${varName}, plural, ${formsText}}`
|
|
4254
|
+
`Unclosed brace for form '${formName}' in ICU: ${icuString}`
|
|
4439
4255
|
);
|
|
4440
4256
|
}
|
|
4441
|
-
|
|
4442
|
-
options[formName] = {
|
|
4443
|
-
value: elements
|
|
4444
|
-
};
|
|
4257
|
+
forms[formName] = formText;
|
|
4445
4258
|
}
|
|
4446
|
-
return
|
|
4447
|
-
{
|
|
4448
|
-
type: "plural",
|
|
4449
|
-
value: varName,
|
|
4450
|
-
options
|
|
4451
|
-
}
|
|
4452
|
-
];
|
|
4259
|
+
return forms;
|
|
4453
4260
|
}
|
|
4454
|
-
function
|
|
4455
|
-
|
|
4456
|
-
let currentText = "";
|
|
4457
|
-
let i = 0;
|
|
4458
|
-
while (i < text.length) {
|
|
4459
|
-
if (text[i] === "#") {
|
|
4460
|
-
if (currentText) {
|
|
4461
|
-
elements.push({ type: "literal", value: currentText });
|
|
4462
|
-
currentText = "";
|
|
4463
|
-
}
|
|
4464
|
-
elements.push({ type: "pound" });
|
|
4465
|
-
i++;
|
|
4466
|
-
} else if (text[i] === "{") {
|
|
4467
|
-
if (currentText) {
|
|
4468
|
-
elements.push({ type: "literal", value: currentText });
|
|
4469
|
-
currentText = "";
|
|
4470
|
-
}
|
|
4471
|
-
let braceCount = 1;
|
|
4472
|
-
let j = i + 1;
|
|
4473
|
-
while (j < text.length && braceCount > 0) {
|
|
4474
|
-
if (text[j] === "{") {
|
|
4475
|
-
braceCount++;
|
|
4476
|
-
} else if (text[j] === "}") {
|
|
4477
|
-
braceCount--;
|
|
4478
|
-
}
|
|
4479
|
-
j++;
|
|
4480
|
-
}
|
|
4481
|
-
if (braceCount !== 0) {
|
|
4482
|
-
throw new Error("Unclosed variable reference");
|
|
4483
|
-
}
|
|
4484
|
-
const varName = text.slice(i + 1, j - 1);
|
|
4485
|
-
elements.push({ type: "argument", value: varName });
|
|
4486
|
-
i = j;
|
|
4487
|
-
} else {
|
|
4488
|
-
currentText += text[i];
|
|
4489
|
-
i++;
|
|
4490
|
-
}
|
|
4491
|
-
}
|
|
4492
|
-
if (currentText) {
|
|
4493
|
-
elements.push({ type: "literal", value: currentText });
|
|
4494
|
-
}
|
|
4495
|
-
return elements;
|
|
4261
|
+
function isIcuPluralString(value) {
|
|
4262
|
+
return typeof value === "string" && /^\{[\w]+,\s*plural,\s*.+\}$/.test(value);
|
|
4496
4263
|
}
|
|
4497
|
-
|
|
4498
|
-
// src/cli/loaders/xcode-xcstrings-v2-loader.ts
|
|
4499
|
-
function createXcodeXcstringsV2Loader(defaultLocale = "en") {
|
|
4264
|
+
function createXcodeXcstringsV2Loader(defaultLocale) {
|
|
4500
4265
|
return createLoader({
|
|
4501
|
-
async pull(locale, input2) {
|
|
4502
|
-
const
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
`
|
|
4516
|
-
);
|
|
4517
|
-
result[key] = value;
|
|
4266
|
+
async pull(locale, input2, initCtx) {
|
|
4267
|
+
const resultData = {};
|
|
4268
|
+
const isSourceLanguage = locale === defaultLocale;
|
|
4269
|
+
for (const [translationKey, _translationEntity] of Object.entries(
|
|
4270
|
+
input2.strings
|
|
4271
|
+
)) {
|
|
4272
|
+
const rootTranslationEntity = _translationEntity;
|
|
4273
|
+
if (rootTranslationEntity.shouldTranslate === false) {
|
|
4274
|
+
continue;
|
|
4275
|
+
}
|
|
4276
|
+
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _190 => _190.localizations, 'optionalAccess', _191 => _191[locale]]);
|
|
4277
|
+
if (langTranslationEntity) {
|
|
4278
|
+
if (!resultData[translationKey]) {
|
|
4279
|
+
resultData[translationKey] = {};
|
|
4518
4280
|
}
|
|
4519
|
-
|
|
4520
|
-
|
|
4281
|
+
if ("stringUnit" in langTranslationEntity) {
|
|
4282
|
+
resultData[translationKey].stringUnit = langTranslationEntity.stringUnit.value;
|
|
4283
|
+
if ("substitutions" in langTranslationEntity) {
|
|
4284
|
+
resultData[translationKey].substitutions = {};
|
|
4285
|
+
for (const [subName, subData] of Object.entries(
|
|
4286
|
+
langTranslationEntity.substitutions
|
|
4287
|
+
)) {
|
|
4288
|
+
const pluralForms = _optionalChain([subData, 'access', _192 => _192.variations, 'optionalAccess', _193 => _193.plural]);
|
|
4289
|
+
if (pluralForms) {
|
|
4290
|
+
const forms = {};
|
|
4291
|
+
for (const [form, formData] of Object.entries(pluralForms)) {
|
|
4292
|
+
forms[form] = formData.stringUnit.value;
|
|
4293
|
+
}
|
|
4294
|
+
const icuString = buildIcuPluralString(forms);
|
|
4295
|
+
resultData[translationKey].substitutions[subName] = {
|
|
4296
|
+
variations: {
|
|
4297
|
+
plural: icuString
|
|
4298
|
+
}
|
|
4299
|
+
};
|
|
4300
|
+
}
|
|
4301
|
+
}
|
|
4302
|
+
}
|
|
4303
|
+
} else if ("stringSet" in langTranslationEntity) {
|
|
4304
|
+
const values = langTranslationEntity.stringSet.values;
|
|
4305
|
+
if (Array.isArray(values) && values.length > 0) {
|
|
4306
|
+
resultData[translationKey].stringSet = values;
|
|
4307
|
+
}
|
|
4308
|
+
} else if ("variations" in langTranslationEntity) {
|
|
4309
|
+
if ("plural" in langTranslationEntity.variations) {
|
|
4310
|
+
const pluralForms = langTranslationEntity.variations.plural;
|
|
4311
|
+
const forms = {};
|
|
4312
|
+
for (const [form, formData] of Object.entries(pluralForms)) {
|
|
4313
|
+
if (_optionalChain([formData, 'optionalAccess', _194 => _194.stringUnit, 'optionalAccess', _195 => _195.value])) {
|
|
4314
|
+
forms[form] = formData.stringUnit.value;
|
|
4315
|
+
}
|
|
4316
|
+
}
|
|
4317
|
+
const icuString = buildIcuPluralString(forms);
|
|
4318
|
+
resultData[translationKey].variations = {
|
|
4319
|
+
plural: icuString
|
|
4320
|
+
};
|
|
4321
|
+
}
|
|
4322
|
+
}
|
|
4323
|
+
} else if (isSourceLanguage) {
|
|
4324
|
+
if (!resultData[translationKey]) {
|
|
4325
|
+
resultData[translationKey] = {};
|
|
4326
|
+
}
|
|
4327
|
+
resultData[translationKey].stringUnit = translationKey;
|
|
4521
4328
|
}
|
|
4522
4329
|
}
|
|
4523
|
-
return
|
|
4330
|
+
return resultData;
|
|
4524
4331
|
},
|
|
4525
|
-
async push(locale, payload) {
|
|
4526
|
-
const
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4332
|
+
async push(locale, payload, originalInput) {
|
|
4333
|
+
const langDataToMerge = {};
|
|
4334
|
+
langDataToMerge.strings = {};
|
|
4335
|
+
const input2 = _lodash2.default.cloneDeep(originalInput) || {
|
|
4336
|
+
sourceLanguage: locale,
|
|
4337
|
+
strings: {}
|
|
4338
|
+
};
|
|
4339
|
+
for (const [baseKey, keyData] of Object.entries(payload)) {
|
|
4340
|
+
if (!keyData || typeof keyData !== "object") {
|
|
4341
|
+
continue;
|
|
4342
|
+
}
|
|
4343
|
+
const hasDoNotTranslateFlag = originalInput && originalInput.strings && originalInput.strings[baseKey] && originalInput.strings[baseKey].shouldTranslate === false;
|
|
4344
|
+
const localizationData = {};
|
|
4345
|
+
if ("stringUnit" in keyData) {
|
|
4346
|
+
localizationData.stringUnit = {
|
|
4347
|
+
state: "translated",
|
|
4348
|
+
value: keyData.stringUnit
|
|
4349
|
+
};
|
|
4350
|
+
}
|
|
4351
|
+
if ("substitutions" in keyData && keyData.substitutions) {
|
|
4352
|
+
const subs = {};
|
|
4353
|
+
for (const [subName, subData] of Object.entries(
|
|
4354
|
+
keyData.substitutions
|
|
4355
|
+
)) {
|
|
4356
|
+
const pluralValue = _optionalChain([subData, 'optionalAccess', _196 => _196.variations, 'optionalAccess', _197 => _197.plural]);
|
|
4357
|
+
if (pluralValue && isIcuPluralString(pluralValue)) {
|
|
4358
|
+
try {
|
|
4359
|
+
const pluralForms = parseIcuPluralString(pluralValue);
|
|
4360
|
+
const pluralOut = {};
|
|
4361
|
+
for (const [form, text] of Object.entries(pluralForms)) {
|
|
4362
|
+
pluralOut[form] = {
|
|
4363
|
+
stringUnit: {
|
|
4364
|
+
state: "translated",
|
|
4365
|
+
value: text
|
|
4366
|
+
}
|
|
4367
|
+
};
|
|
4368
|
+
}
|
|
4369
|
+
const sourceLocale = _optionalChain([originalInput, 'optionalAccess', _198 => _198.sourceLanguage]) || "en";
|
|
4370
|
+
const origFormatSpec = _optionalChain([originalInput, 'optionalAccess', _199 => _199.strings, 'optionalAccess', _200 => _200[baseKey], 'optionalAccess', _201 => _201.localizations, 'optionalAccess', _202 => _202[sourceLocale], 'optionalAccess', _203 => _203.substitutions, 'optionalAccess', _204 => _204[subName], 'optionalAccess', _205 => _205.formatSpecifier]) || subName;
|
|
4371
|
+
subs[subName] = {
|
|
4372
|
+
formatSpecifier: origFormatSpec,
|
|
4373
|
+
variations: {
|
|
4374
|
+
plural: pluralOut
|
|
4375
|
+
}
|
|
4376
|
+
};
|
|
4377
|
+
} catch (error) {
|
|
4378
|
+
throw new Error(
|
|
4379
|
+
`Failed to write substitution plural translation for key "${baseKey}/substitutions/${subName}" (locale: ${locale}).
|
|
4535
4380
|
${error instanceof Error ? error.message : String(error)}`
|
|
4536
|
-
|
|
4381
|
+
);
|
|
4382
|
+
}
|
|
4383
|
+
}
|
|
4384
|
+
}
|
|
4385
|
+
if (Object.keys(subs).length > 0) {
|
|
4386
|
+
localizationData.substitutions = subs;
|
|
4387
|
+
}
|
|
4388
|
+
}
|
|
4389
|
+
if ("stringSet" in keyData && Array.isArray(keyData.stringSet)) {
|
|
4390
|
+
localizationData.stringSet = {
|
|
4391
|
+
state: "translated",
|
|
4392
|
+
values: keyData.stringSet
|
|
4393
|
+
};
|
|
4394
|
+
}
|
|
4395
|
+
if ("variations" in keyData && _optionalChain([keyData, 'access', _206 => _206.variations, 'optionalAccess', _207 => _207.plural])) {
|
|
4396
|
+
const pluralValue = keyData.variations.plural;
|
|
4397
|
+
if (isIcuPluralString(pluralValue)) {
|
|
4398
|
+
try {
|
|
4399
|
+
const pluralForms = parseIcuPluralString(pluralValue);
|
|
4400
|
+
const pluralOut = {};
|
|
4401
|
+
for (const [form, text] of Object.entries(pluralForms)) {
|
|
4402
|
+
pluralOut[form] = {
|
|
4403
|
+
stringUnit: {
|
|
4404
|
+
state: "translated",
|
|
4405
|
+
value: text
|
|
4406
|
+
}
|
|
4407
|
+
};
|
|
4408
|
+
}
|
|
4409
|
+
localizationData.variations = {
|
|
4410
|
+
plural: pluralOut
|
|
4411
|
+
};
|
|
4412
|
+
} catch (error) {
|
|
4413
|
+
throw new Error(
|
|
4414
|
+
`Failed to write plural translation for key "${baseKey}" (locale: ${locale}).
|
|
4415
|
+
${error instanceof Error ? error.message : String(error)}`
|
|
4416
|
+
);
|
|
4417
|
+
}
|
|
4418
|
+
}
|
|
4419
|
+
}
|
|
4420
|
+
if (Object.keys(localizationData).length > 0) {
|
|
4421
|
+
langDataToMerge.strings[baseKey] = {
|
|
4422
|
+
extractionState: _optionalChain([originalInput, 'optionalAccess', _208 => _208.strings, 'optionalAccess', _209 => _209[baseKey], 'optionalAccess', _210 => _210.extractionState]),
|
|
4423
|
+
localizations: {
|
|
4424
|
+
[locale]: localizationData
|
|
4425
|
+
}
|
|
4426
|
+
};
|
|
4427
|
+
if (hasDoNotTranslateFlag) {
|
|
4428
|
+
langDataToMerge.strings[baseKey].shouldTranslate = false;
|
|
4537
4429
|
}
|
|
4538
|
-
} else {
|
|
4539
|
-
result[key] = value;
|
|
4540
4430
|
}
|
|
4541
4431
|
}
|
|
4542
|
-
return
|
|
4432
|
+
return _lodash2.default.merge(input2, langDataToMerge);
|
|
4433
|
+
},
|
|
4434
|
+
async pullHints(input2) {
|
|
4435
|
+
const hints = {};
|
|
4436
|
+
for (const [translationKey, _translationEntity] of Object.entries(
|
|
4437
|
+
input2.strings || {}
|
|
4438
|
+
)) {
|
|
4439
|
+
const rootTranslationEntity = _translationEntity;
|
|
4440
|
+
if (rootTranslationEntity.comment && typeof rootTranslationEntity.comment === "string") {
|
|
4441
|
+
hints[translationKey] = { hint: rootTranslationEntity.comment };
|
|
4442
|
+
}
|
|
4443
|
+
}
|
|
4444
|
+
return hints;
|
|
4543
4445
|
}
|
|
4544
4446
|
});
|
|
4545
4447
|
}
|
|
@@ -4554,12 +4456,12 @@ function createUnlocalizableLoader(returnUnlocalizedKeys = false) {
|
|
|
4554
4456
|
const unlocalizableKeys = _getUnlocalizableKeys(input2);
|
|
4555
4457
|
const result = _lodash2.default.omitBy(
|
|
4556
4458
|
input2,
|
|
4557
|
-
(
|
|
4459
|
+
(_37, key) => unlocalizableKeys.includes(key)
|
|
4558
4460
|
);
|
|
4559
4461
|
if (returnUnlocalizedKeys) {
|
|
4560
4462
|
result.unlocalizable = _lodash2.default.omitBy(
|
|
4561
4463
|
input2,
|
|
4562
|
-
(
|
|
4464
|
+
(_37, key) => !unlocalizableKeys.includes(key)
|
|
4563
4465
|
);
|
|
4564
4466
|
}
|
|
4565
4467
|
return result;
|
|
@@ -4569,7 +4471,7 @@ function createUnlocalizableLoader(returnUnlocalizedKeys = false) {
|
|
|
4569
4471
|
const result = _lodash2.default.merge(
|
|
4570
4472
|
{},
|
|
4571
4473
|
data,
|
|
4572
|
-
_lodash2.default.omitBy(originalInput, (
|
|
4474
|
+
_lodash2.default.omitBy(originalInput, (_37, key) => !unlocalizableKeys.includes(key))
|
|
4573
4475
|
);
|
|
4574
4476
|
return result;
|
|
4575
4477
|
}
|
|
@@ -4600,7 +4502,7 @@ function _getUnlocalizableKeys(input2) {
|
|
|
4600
4502
|
}
|
|
4601
4503
|
}
|
|
4602
4504
|
return false;
|
|
4603
|
-
}).map(([key,
|
|
4505
|
+
}).map(([key, _37]) => key);
|
|
4604
4506
|
}
|
|
4605
4507
|
|
|
4606
4508
|
// src/cli/loaders/formatters/prettier.ts
|
|
@@ -4740,8 +4642,8 @@ async function formatDataWithBiome(data, filePath, options) {
|
|
|
4740
4642
|
});
|
|
4741
4643
|
return formatted.content;
|
|
4742
4644
|
} catch (error) {
|
|
4743
|
-
const errorMessage = error instanceof Error ? error.message || _optionalChain([error, 'access',
|
|
4744
|
-
if (_optionalChain([errorMessage, 'optionalAccess',
|
|
4645
|
+
const errorMessage = error instanceof Error ? error.message || _optionalChain([error, 'access', _211 => _211.stackTrace, 'optionalAccess', _212 => _212.toString, 'call', _213 => _213(), 'access', _214 => _214.split, 'call', _215 => _215("\n"), 'access', _216 => _216[0]]) : "";
|
|
4646
|
+
if (_optionalChain([errorMessage, 'optionalAccess', _217 => _217.includes, 'call', _218 => _218("does not exist in the workspace")])) {
|
|
4745
4647
|
} else {
|
|
4746
4648
|
console.log(`\u26A0\uFE0F Biome skipped ${path14.default.basename(filePath)}`);
|
|
4747
4649
|
if (errorMessage) {
|
|
@@ -4788,7 +4690,7 @@ function createPoDataLoader(params) {
|
|
|
4788
4690
|
Object.entries(entries).forEach(([msgid, entry]) => {
|
|
4789
4691
|
if (msgid && entry.msgid) {
|
|
4790
4692
|
const context = entry.msgctxt || "";
|
|
4791
|
-
const fullEntry = _optionalChain([parsedPo, 'access',
|
|
4693
|
+
const fullEntry = _optionalChain([parsedPo, 'access', _219 => _219.translations, 'access', _220 => _220[context], 'optionalAccess', _221 => _221[msgid]]);
|
|
4792
4694
|
if (fullEntry) {
|
|
4793
4695
|
result[msgid] = fullEntry;
|
|
4794
4696
|
}
|
|
@@ -4798,8 +4700,8 @@ function createPoDataLoader(params) {
|
|
|
4798
4700
|
return result;
|
|
4799
4701
|
},
|
|
4800
4702
|
async push(locale, data, originalInput, originalLocale, pullInput) {
|
|
4801
|
-
const currentSections = _optionalChain([pullInput, 'optionalAccess',
|
|
4802
|
-
const originalSections = _optionalChain([originalInput, 'optionalAccess',
|
|
4703
|
+
const currentSections = _optionalChain([pullInput, 'optionalAccess', _222 => _222.split, 'call', _223 => _223("\n\n"), 'access', _224 => _224.filter, 'call', _225 => _225(Boolean)]) || [];
|
|
4704
|
+
const originalSections = _optionalChain([originalInput, 'optionalAccess', _226 => _226.split, 'call', _227 => _227("\n\n"), 'access', _228 => _228.filter, 'call', _229 => _229(Boolean)]) || [];
|
|
4803
4705
|
const result = originalSections.map((section) => {
|
|
4804
4706
|
const sectionPo = _gettextparser2.default.po.parse(section);
|
|
4805
4707
|
if (Object.keys(sectionPo.translations).length === 0) {
|
|
@@ -4868,8 +4770,8 @@ function createPoContentLoader() {
|
|
|
4868
4770
|
{
|
|
4869
4771
|
...entry,
|
|
4870
4772
|
msgstr: [
|
|
4871
|
-
_optionalChain([data, 'access',
|
|
4872
|
-
_optionalChain([data, 'access',
|
|
4773
|
+
_optionalChain([data, 'access', _230 => _230[entry.msgid], 'optionalAccess', _231 => _231.singular]),
|
|
4774
|
+
_optionalChain([data, 'access', _232 => _232[entry.msgid], 'optionalAccess', _233 => _233.plural]) || null
|
|
4873
4775
|
].filter(Boolean)
|
|
4874
4776
|
}
|
|
4875
4777
|
]).fromPairs().value();
|
|
@@ -4991,7 +4893,7 @@ function pullV1(xliffElement, locale, originalLocale) {
|
|
|
4991
4893
|
let key = getTransUnitKey(unit);
|
|
4992
4894
|
if (!key) return;
|
|
4993
4895
|
if (seenKeys.has(key)) {
|
|
4994
|
-
const id = _optionalChain([unit, 'access',
|
|
4896
|
+
const id = _optionalChain([unit, 'access', _234 => _234.getAttribute, 'call', _235 => _235("id"), 'optionalAccess', _236 => _236.trim, 'call', _237 => _237()]);
|
|
4995
4897
|
if (id) {
|
|
4996
4898
|
key = `${key}#${id}`;
|
|
4997
4899
|
} else {
|
|
@@ -5039,7 +4941,7 @@ function pushV1(dom, xliffElement, locale, translations, originalLocale, origina
|
|
|
5039
4941
|
let key = getTransUnitKey(unit);
|
|
5040
4942
|
if (!key) return;
|
|
5041
4943
|
if (seenKeys.has(key)) {
|
|
5042
|
-
const id = _optionalChain([unit, 'access',
|
|
4944
|
+
const id = _optionalChain([unit, 'access', _238 => _238.getAttribute, 'call', _239 => _239("id"), 'optionalAccess', _240 => _240.trim, 'call', _241 => _241()]);
|
|
5043
4945
|
if (id) {
|
|
5044
4946
|
key = `${key}#${id}`;
|
|
5045
4947
|
} else {
|
|
@@ -5081,7 +4983,7 @@ function pushV1(dom, xliffElement, locale, translations, originalLocale, origina
|
|
|
5081
4983
|
const translationKeys = new Set(Object.keys(translations));
|
|
5082
4984
|
existingUnits.forEach((unit, key) => {
|
|
5083
4985
|
if (!translationKeys.has(key)) {
|
|
5084
|
-
_optionalChain([unit, 'access',
|
|
4986
|
+
_optionalChain([unit, 'access', _242 => _242.parentNode, 'optionalAccess', _243 => _243.removeChild, 'call', _244 => _244(unit)]);
|
|
5085
4987
|
}
|
|
5086
4988
|
});
|
|
5087
4989
|
return serializeWithDeclaration(
|
|
@@ -5124,18 +5026,18 @@ function traverseUnitsV2(container, fileId, currentPath, result) {
|
|
|
5124
5026
|
Array.from(container.children).forEach((child) => {
|
|
5125
5027
|
const tagName = child.tagName;
|
|
5126
5028
|
if (tagName === "unit") {
|
|
5127
|
-
const unitId = _optionalChain([child, 'access',
|
|
5029
|
+
const unitId = _optionalChain([child, 'access', _245 => _245.getAttribute, 'call', _246 => _246("id"), 'optionalAccess', _247 => _247.trim, 'call', _248 => _248()]);
|
|
5128
5030
|
if (!unitId) return;
|
|
5129
5031
|
const key = `resources/${fileId}/${currentPath}${unitId}/source`;
|
|
5130
5032
|
const segment = child.querySelector("segment");
|
|
5131
|
-
const source = _optionalChain([segment, 'optionalAccess',
|
|
5033
|
+
const source = _optionalChain([segment, 'optionalAccess', _249 => _249.querySelector, 'call', _250 => _250("source")]);
|
|
5132
5034
|
if (source) {
|
|
5133
5035
|
result[key] = extractTextContent(source);
|
|
5134
5036
|
} else {
|
|
5135
5037
|
result[key] = unitId;
|
|
5136
5038
|
}
|
|
5137
5039
|
} else if (tagName === "group") {
|
|
5138
|
-
const groupId = _optionalChain([child, 'access',
|
|
5040
|
+
const groupId = _optionalChain([child, 'access', _251 => _251.getAttribute, 'call', _252 => _252("id"), 'optionalAccess', _253 => _253.trim, 'call', _254 => _254()]);
|
|
5139
5041
|
const newPath = groupId ? `${currentPath}${groupId}/groupUnits/` : currentPath;
|
|
5140
5042
|
traverseUnitsV2(child, fileId, newPath, result);
|
|
5141
5043
|
}
|
|
@@ -5171,12 +5073,12 @@ function indexUnitsV2(container, fileId, currentPath, index) {
|
|
|
5171
5073
|
Array.from(container.children).forEach((child) => {
|
|
5172
5074
|
const tagName = child.tagName;
|
|
5173
5075
|
if (tagName === "unit") {
|
|
5174
|
-
const unitId = _optionalChain([child, 'access',
|
|
5076
|
+
const unitId = _optionalChain([child, 'access', _255 => _255.getAttribute, 'call', _256 => _256("id"), 'optionalAccess', _257 => _257.trim, 'call', _258 => _258()]);
|
|
5175
5077
|
if (!unitId) return;
|
|
5176
5078
|
const key = `resources/${fileId}/${currentPath}${unitId}/source`;
|
|
5177
5079
|
index.set(key, child);
|
|
5178
5080
|
} else if (tagName === "group") {
|
|
5179
|
-
const groupId = _optionalChain([child, 'access',
|
|
5081
|
+
const groupId = _optionalChain([child, 'access', _259 => _259.getAttribute, 'call', _260 => _260("id"), 'optionalAccess', _261 => _261.trim, 'call', _262 => _262()]);
|
|
5180
5082
|
const newPath = groupId ? `${currentPath}${groupId}/groupUnits/` : currentPath;
|
|
5181
5083
|
indexUnitsV2(child, fileId, newPath, index);
|
|
5182
5084
|
}
|
|
@@ -5197,9 +5099,9 @@ function updateUnitV2(unit, value) {
|
|
|
5197
5099
|
setTextContent(source, value);
|
|
5198
5100
|
}
|
|
5199
5101
|
function getTransUnitKey(transUnit) {
|
|
5200
|
-
const resname = _optionalChain([transUnit, 'access',
|
|
5102
|
+
const resname = _optionalChain([transUnit, 'access', _263 => _263.getAttribute, 'call', _264 => _264("resname"), 'optionalAccess', _265 => _265.trim, 'call', _266 => _266()]);
|
|
5201
5103
|
if (resname) return resname;
|
|
5202
|
-
const id = _optionalChain([transUnit, 'access',
|
|
5104
|
+
const id = _optionalChain([transUnit, 'access', _267 => _267.getAttribute, 'call', _268 => _268("id"), 'optionalAccess', _269 => _269.trim, 'call', _270 => _270()]);
|
|
5203
5105
|
if (id) return id;
|
|
5204
5106
|
const sourceElement = transUnit.querySelector("source");
|
|
5205
5107
|
if (sourceElement) {
|
|
@@ -5256,7 +5158,7 @@ function formatXml(xml) {
|
|
|
5256
5158
|
if (cdataNode) {
|
|
5257
5159
|
return `${indent2}${openTag}<![CDATA[${cdataNode.nodeValue}]]></${tagName}>`;
|
|
5258
5160
|
}
|
|
5259
|
-
const textContent = _optionalChain([element, 'access',
|
|
5161
|
+
const textContent = _optionalChain([element, 'access', _271 => _271.textContent, 'optionalAccess', _272 => _272.trim, 'call', _273 => _273()]) || "";
|
|
5260
5162
|
const hasOnlyText = element.childNodes.length === 1 && element.childNodes[0].nodeType === 3;
|
|
5261
5163
|
if (hasOnlyText && textContent) {
|
|
5262
5164
|
return `${indent2}${openTag}${textContent}</${tagName}>`;
|
|
@@ -5549,7 +5451,7 @@ function createDatoClient(params) {
|
|
|
5549
5451
|
ids: !records.length ? void 0 : records.join(",")
|
|
5550
5452
|
}
|
|
5551
5453
|
}).catch(
|
|
5552
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
5454
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _274 => _274.response, 'optionalAccess', _275 => _275.body, 'optionalAccess', _276 => _276.data, 'optionalAccess', _277 => _277[0]]) || error)
|
|
5553
5455
|
);
|
|
5554
5456
|
},
|
|
5555
5457
|
findRecordsForModel: async (modelId, records) => {
|
|
@@ -5560,10 +5462,10 @@ function createDatoClient(params) {
|
|
|
5560
5462
|
filter: {
|
|
5561
5463
|
type: modelId,
|
|
5562
5464
|
only_valid: "true",
|
|
5563
|
-
ids: !_optionalChain([records, 'optionalAccess',
|
|
5465
|
+
ids: !_optionalChain([records, 'optionalAccess', _278 => _278.length]) ? void 0 : records.join(",")
|
|
5564
5466
|
}
|
|
5565
5467
|
}).catch(
|
|
5566
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
5468
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _279 => _279.response, 'optionalAccess', _280 => _280.body, 'optionalAccess', _281 => _281.data, 'optionalAccess', _282 => _282[0]]) || error)
|
|
5567
5469
|
);
|
|
5568
5470
|
return result;
|
|
5569
5471
|
} catch (_error) {
|
|
@@ -5579,10 +5481,10 @@ function createDatoClient(params) {
|
|
|
5579
5481
|
updateRecord: async (id, payload) => {
|
|
5580
5482
|
try {
|
|
5581
5483
|
await dato.items.update(id, payload).catch(
|
|
5582
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
5484
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _283 => _283.response, 'optionalAccess', _284 => _284.body, 'optionalAccess', _285 => _285.data, 'optionalAccess', _286 => _286[0]]) || error)
|
|
5583
5485
|
);
|
|
5584
5486
|
} catch (_error) {
|
|
5585
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
5487
|
+
if (_optionalChain([_error, 'optionalAccess', _287 => _287.attributes, 'optionalAccess', _288 => _288.details, 'optionalAccess', _289 => _289.message])) {
|
|
5586
5488
|
throw new Error(
|
|
5587
5489
|
[
|
|
5588
5490
|
`${_error.attributes.details.message}`,
|
|
@@ -5604,10 +5506,10 @@ function createDatoClient(params) {
|
|
|
5604
5506
|
enableFieldLocalization: async (args) => {
|
|
5605
5507
|
try {
|
|
5606
5508
|
await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch(
|
|
5607
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
5509
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _290 => _290.response, 'optionalAccess', _291 => _291.body, 'optionalAccess', _292 => _292.data, 'optionalAccess', _293 => _293[0]]) || error)
|
|
5608
5510
|
);
|
|
5609
5511
|
} catch (_error) {
|
|
5610
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
5512
|
+
if (_optionalChain([_error, 'optionalAccess', _294 => _294.attributes, 'optionalAccess', _295 => _295.code]) === "NOT_FOUND") {
|
|
5611
5513
|
throw new Error(
|
|
5612
5514
|
[
|
|
5613
5515
|
`Field "${args.fieldId}" not found in model "${args.modelId}".`,
|
|
@@ -5615,7 +5517,7 @@ function createDatoClient(params) {
|
|
|
5615
5517
|
].join("\n\n")
|
|
5616
5518
|
);
|
|
5617
5519
|
}
|
|
5618
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
5520
|
+
if (_optionalChain([_error, 'optionalAccess', _296 => _296.attributes, 'optionalAccess', _297 => _297.details, 'optionalAccess', _298 => _298.message])) {
|
|
5619
5521
|
throw new Error(
|
|
5620
5522
|
[
|
|
5621
5523
|
`${_error.attributes.details.message}`,
|
|
@@ -5693,7 +5595,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
5693
5595
|
const records = await dato.findRecordsForModel(modelId);
|
|
5694
5596
|
const recordChoices = createRecordChoices(
|
|
5695
5597
|
records,
|
|
5696
|
-
_optionalChain([config, 'access',
|
|
5598
|
+
_optionalChain([config, 'access', _299 => _299.models, 'access', _300 => _300[modelId], 'optionalAccess', _301 => _301.records]) || [],
|
|
5697
5599
|
project
|
|
5698
5600
|
);
|
|
5699
5601
|
const selectedRecords = await promptRecordSelection(
|
|
@@ -5712,14 +5614,14 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
5712
5614
|
},
|
|
5713
5615
|
async pull(locale, input2, initCtx) {
|
|
5714
5616
|
const result = {};
|
|
5715
|
-
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess',
|
|
5716
|
-
let records = _optionalChain([initCtx, 'optionalAccess',
|
|
5617
|
+
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess', _302 => _302.models]) || {})) {
|
|
5618
|
+
let records = _optionalChain([initCtx, 'optionalAccess', _303 => _303.models, 'access', _304 => _304[modelId], 'access', _305 => _305.records]) || [];
|
|
5717
5619
|
const recordIds = records.map((record) => record.id);
|
|
5718
5620
|
records = await dato.findRecords(recordIds);
|
|
5719
5621
|
console.log(`Fetched ${records.length} records for model ${modelId}`);
|
|
5720
5622
|
if (records.length > 0) {
|
|
5721
5623
|
result[modelId] = {
|
|
5722
|
-
fields: _optionalChain([initCtx, 'optionalAccess',
|
|
5624
|
+
fields: _optionalChain([initCtx, 'optionalAccess', _306 => _306.models, 'optionalAccess', _307 => _307[modelId], 'optionalAccess', _308 => _308.fields]) || [],
|
|
5723
5625
|
records
|
|
5724
5626
|
};
|
|
5725
5627
|
}
|
|
@@ -5782,7 +5684,7 @@ function createRecordChoices(records, selectedIds = [], project) {
|
|
|
5782
5684
|
return records.map((record) => ({
|
|
5783
5685
|
name: `${record.id} - https://${project.internal_domain}/editor/item_types/${record.item_type.id}/items/${record.id}`,
|
|
5784
5686
|
value: record.id,
|
|
5785
|
-
checked: _optionalChain([selectedIds, 'optionalAccess',
|
|
5687
|
+
checked: _optionalChain([selectedIds, 'optionalAccess', _309 => _309.includes, 'call', _310 => _310(record.id)])
|
|
5786
5688
|
}));
|
|
5787
5689
|
}
|
|
5788
5690
|
async function promptRecordSelection(modelName, choices) {
|
|
@@ -6101,7 +6003,7 @@ function createVttLoader() {
|
|
|
6101
6003
|
if (!input2) {
|
|
6102
6004
|
return "";
|
|
6103
6005
|
}
|
|
6104
|
-
const vtt = _optionalChain([_nodewebvtt2.default, 'access',
|
|
6006
|
+
const vtt = _optionalChain([_nodewebvtt2.default, 'access', _311 => _311.parse, 'call', _312 => _312(input2), 'optionalAccess', _313 => _313.cues]);
|
|
6105
6007
|
if (Object.keys(vtt).length === 0) {
|
|
6106
6008
|
return {};
|
|
6107
6009
|
} else {
|
|
@@ -6147,15 +6049,6 @@ function variableExtractLoader(params) {
|
|
|
6147
6049
|
const inputValues = _lodash2.default.omitBy(input2, _lodash2.default.isEmpty);
|
|
6148
6050
|
for (const [key, value] of Object.entries(inputValues)) {
|
|
6149
6051
|
const originalValue = originalInput[key];
|
|
6150
|
-
if (isICUPluralObject(originalValue)) {
|
|
6151
|
-
const icuValue = isICUPluralObject(value) ? { icu: value.icu } : value;
|
|
6152
|
-
result[key] = {
|
|
6153
|
-
value: icuValue,
|
|
6154
|
-
variables: []
|
|
6155
|
-
// Metadata stored separately, not in variables
|
|
6156
|
-
};
|
|
6157
|
-
continue;
|
|
6158
|
-
}
|
|
6159
6052
|
const matches = originalValue.match(specifierPattern) || [];
|
|
6160
6053
|
result[key] = result[key] || {
|
|
6161
6054
|
value,
|
|
@@ -6164,7 +6057,7 @@ function variableExtractLoader(params) {
|
|
|
6164
6057
|
for (let i = 0; i < matches.length; i++) {
|
|
6165
6058
|
const match2 = matches[i];
|
|
6166
6059
|
const currentValue = result[key].value;
|
|
6167
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
6060
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _314 => _314.replace, 'call', _315 => _315(match2, `{variable:${i}}`)]);
|
|
6168
6061
|
result[key].value = newValue;
|
|
6169
6062
|
result[key].variables[i] = match2;
|
|
6170
6063
|
}
|
|
@@ -6175,19 +6068,14 @@ function variableExtractLoader(params) {
|
|
|
6175
6068
|
const result = {};
|
|
6176
6069
|
for (const [key, valueObj] of Object.entries(data)) {
|
|
6177
6070
|
result[key] = valueObj.value;
|
|
6178
|
-
const resultValue = result[key];
|
|
6179
|
-
if (isICUPluralObject(resultValue)) {
|
|
6180
|
-
const originalValue = _optionalChain([originalInput, 'optionalAccess', _299 => _299[key]]);
|
|
6181
|
-
if (isICUPluralObject(originalValue) && originalValue._meta) {
|
|
6182
|
-
resultValue._meta = originalValue._meta;
|
|
6183
|
-
resultValue[Symbol.for("@lingo.dev/icu-plural-object")] = true;
|
|
6184
|
-
}
|
|
6185
|
-
}
|
|
6186
6071
|
for (let i = 0; i < valueObj.variables.length; i++) {
|
|
6187
6072
|
const variable = valueObj.variables[i];
|
|
6188
6073
|
const currentValue = result[key];
|
|
6189
6074
|
if (typeof currentValue === "string") {
|
|
6190
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
6075
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _316 => _316.replaceAll, 'call', _317 => _317(
|
|
6076
|
+
`{variable:${i}}`,
|
|
6077
|
+
variable
|
|
6078
|
+
)]);
|
|
6191
6079
|
result[key] = newValue;
|
|
6192
6080
|
}
|
|
6193
6081
|
}
|
|
@@ -6388,7 +6276,7 @@ function createVueJsonLoader() {
|
|
|
6388
6276
|
return createLoader({
|
|
6389
6277
|
pull: async (locale, input2, ctx) => {
|
|
6390
6278
|
const parsed = parseVueFile(input2);
|
|
6391
|
-
return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess',
|
|
6279
|
+
return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _318 => _318.i18n, 'optionalAccess', _319 => _319[locale]]), () => ( {}));
|
|
6392
6280
|
},
|
|
6393
6281
|
push: async (locale, data, originalInput) => {
|
|
6394
6282
|
const parsed = parseVueFile(_nullishCoalesce(originalInput, () => ( "")));
|
|
@@ -6573,7 +6461,7 @@ function updateStringsInObjectExpression(objectExpression, data) {
|
|
|
6573
6461
|
objectExpression.properties.forEach((prop) => {
|
|
6574
6462
|
if (!t.isObjectProperty(prop)) return;
|
|
6575
6463
|
const key = getPropertyKey(prop);
|
|
6576
|
-
const incomingVal = _optionalChain([data, 'optionalAccess',
|
|
6464
|
+
const incomingVal = _optionalChain([data, 'optionalAccess', _320 => _320[key]]);
|
|
6577
6465
|
if (incomingVal === void 0) {
|
|
6578
6466
|
return;
|
|
6579
6467
|
}
|
|
@@ -6609,7 +6497,7 @@ function updateStringsInArrayExpression(arrayExpression, incoming) {
|
|
|
6609
6497
|
let modified = false;
|
|
6610
6498
|
arrayExpression.elements.forEach((element, index) => {
|
|
6611
6499
|
if (!element) return;
|
|
6612
|
-
const incomingVal = _optionalChain([incoming, 'optionalAccess',
|
|
6500
|
+
const incomingVal = _optionalChain([incoming, 'optionalAccess', _321 => _321[index]]);
|
|
6613
6501
|
if (incomingVal === void 0) return;
|
|
6614
6502
|
if (t.isStringLiteral(element) && typeof incomingVal === "string") {
|
|
6615
6503
|
if (element.value !== incomingVal) {
|
|
@@ -7100,7 +6988,7 @@ var AST = class _AST {
|
|
|
7100
6988
|
const ret = this.type === null ? this.#parts.slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...this.#parts.map((p) => p.toJSON())];
|
|
7101
6989
|
if (this.isStart() && !this.type)
|
|
7102
6990
|
ret.unshift([]);
|
|
7103
|
-
if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && _optionalChain([this, 'access',
|
|
6991
|
+
if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && _optionalChain([this, 'access', _322 => _322.#parent, 'optionalAccess', _323 => _323.type]) === "!")) {
|
|
7104
6992
|
ret.push({});
|
|
7105
6993
|
}
|
|
7106
6994
|
return ret;
|
|
@@ -7108,7 +6996,7 @@ var AST = class _AST {
|
|
|
7108
6996
|
isStart() {
|
|
7109
6997
|
if (this.#root === this)
|
|
7110
6998
|
return true;
|
|
7111
|
-
if (!_optionalChain([this, 'access',
|
|
6999
|
+
if (!_optionalChain([this, 'access', _324 => _324.#parent, 'optionalAccess', _325 => _325.isStart, 'call', _326 => _326()]))
|
|
7112
7000
|
return false;
|
|
7113
7001
|
if (this.#parentIndex === 0)
|
|
7114
7002
|
return true;
|
|
@@ -7124,12 +7012,12 @@ var AST = class _AST {
|
|
|
7124
7012
|
isEnd() {
|
|
7125
7013
|
if (this.#root === this)
|
|
7126
7014
|
return true;
|
|
7127
|
-
if (_optionalChain([this, 'access',
|
|
7015
|
+
if (_optionalChain([this, 'access', _327 => _327.#parent, 'optionalAccess', _328 => _328.type]) === "!")
|
|
7128
7016
|
return true;
|
|
7129
|
-
if (!_optionalChain([this, 'access',
|
|
7017
|
+
if (!_optionalChain([this, 'access', _329 => _329.#parent, 'optionalAccess', _330 => _330.isEnd, 'call', _331 => _331()]))
|
|
7130
7018
|
return false;
|
|
7131
7019
|
if (!this.type)
|
|
7132
|
-
return _optionalChain([this, 'access',
|
|
7020
|
+
return _optionalChain([this, 'access', _332 => _332.#parent, 'optionalAccess', _333 => _333.isEnd, 'call', _334 => _334()]);
|
|
7133
7021
|
const pl = this.#parent ? this.#parent.#parts.length : 0;
|
|
7134
7022
|
return this.#parentIndex === pl - 1;
|
|
7135
7023
|
}
|
|
@@ -7351,7 +7239,7 @@ var AST = class _AST {
|
|
|
7351
7239
|
if (!this.type) {
|
|
7352
7240
|
const noEmpty = this.isStart() && this.isEnd();
|
|
7353
7241
|
const src = this.#parts.map((p) => {
|
|
7354
|
-
const [re,
|
|
7242
|
+
const [re, _37, hasMagic, uflag] = typeof p === "string" ? _AST.#parseGlob(p, this.#hasMagic, noEmpty) : p.toRegExpSource(allowDot);
|
|
7355
7243
|
this.#hasMagic = this.#hasMagic || hasMagic;
|
|
7356
7244
|
this.#uflag = this.#uflag || uflag;
|
|
7357
7245
|
return re;
|
|
@@ -7374,7 +7262,7 @@ var AST = class _AST {
|
|
|
7374
7262
|
}
|
|
7375
7263
|
}
|
|
7376
7264
|
let end = "";
|
|
7377
|
-
if (this.isEnd() && this.#root.#filledNegs && _optionalChain([this, 'access',
|
|
7265
|
+
if (this.isEnd() && this.#root.#filledNegs && _optionalChain([this, 'access', _335 => _335.#parent, 'optionalAccess', _336 => _336.type]) === "!") {
|
|
7378
7266
|
end = "(?:$|\\/)";
|
|
7379
7267
|
}
|
|
7380
7268
|
const final2 = start2 + src + end;
|
|
@@ -7424,7 +7312,7 @@ var AST = class _AST {
|
|
|
7424
7312
|
if (typeof p === "string") {
|
|
7425
7313
|
throw new Error("string type in extglob ast??");
|
|
7426
7314
|
}
|
|
7427
|
-
const [re,
|
|
7315
|
+
const [re, _37, _hasMagic, uflag] = p.toRegExpSource(dot);
|
|
7428
7316
|
this.#uflag = this.#uflag || uflag;
|
|
7429
7317
|
return re;
|
|
7430
7318
|
}).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
|
|
@@ -7669,7 +7557,7 @@ var Minimatch = class {
|
|
|
7669
7557
|
}
|
|
7670
7558
|
return false;
|
|
7671
7559
|
}
|
|
7672
|
-
debug(...
|
|
7560
|
+
debug(..._37) {
|
|
7673
7561
|
}
|
|
7674
7562
|
make() {
|
|
7675
7563
|
const pattern = this.pattern;
|
|
@@ -7691,7 +7579,7 @@ var Minimatch = class {
|
|
|
7691
7579
|
const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
|
|
7692
7580
|
this.globParts = this.preprocess(rawGlobParts);
|
|
7693
7581
|
this.debug(this.pattern, this.globParts);
|
|
7694
|
-
let set = this.globParts.map((s,
|
|
7582
|
+
let set = this.globParts.map((s, _37, __) => {
|
|
7695
7583
|
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
7696
7584
|
const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
|
|
7697
7585
|
const isDrive = /^[a-z]:/i.test(s[0]);
|
|
@@ -8464,7 +8352,7 @@ function createMdxSectionsSplit2Loader() {
|
|
|
8464
8352
|
const content = _lodash2.default.chain(data.sections).values().join("\n\n").value();
|
|
8465
8353
|
const result = {
|
|
8466
8354
|
frontmatter: data.frontmatter,
|
|
8467
|
-
codePlaceholders: _optionalChain([pullInput, 'optionalAccess',
|
|
8355
|
+
codePlaceholders: _optionalChain([pullInput, 'optionalAccess', _337 => _337.codePlaceholders]) || {},
|
|
8468
8356
|
content
|
|
8469
8357
|
};
|
|
8470
8358
|
return result;
|
|
@@ -8729,7 +8617,7 @@ function createTxtLoader() {
|
|
|
8729
8617
|
const sortedEntries = Object.entries(payload).sort(
|
|
8730
8618
|
([a], [b]) => parseInt(a) - parseInt(b)
|
|
8731
8619
|
);
|
|
8732
|
-
return sortedEntries.map(([
|
|
8620
|
+
return sortedEntries.map(([_37, value]) => value).join("\n");
|
|
8733
8621
|
}
|
|
8734
8622
|
});
|
|
8735
8623
|
}
|
|
@@ -9020,9 +8908,8 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys,
|
|
|
9020
8908
|
createPlutilJsonTextLoader(),
|
|
9021
8909
|
createLockedPatternsLoader(lockedPatterns),
|
|
9022
8910
|
createJsonLoader(),
|
|
9023
|
-
createXcodeXcstringsLoader(options.defaultLocale),
|
|
9024
8911
|
createXcodeXcstringsV2Loader(options.defaultLocale),
|
|
9025
|
-
createFlatLoader(
|
|
8912
|
+
createFlatLoader(),
|
|
9026
8913
|
createEnsureKeyOrderLoader(),
|
|
9027
8914
|
createLockedKeysLoader(lockedKeys || []),
|
|
9028
8915
|
createIgnoredKeysLoader(ignoredKeys || []),
|
|
@@ -9565,7 +9452,7 @@ function createBasicTranslator(model, systemPrompt, settings = {}) {
|
|
|
9565
9452
|
]
|
|
9566
9453
|
});
|
|
9567
9454
|
const result = JSON.parse(response.text);
|
|
9568
|
-
return _optionalChain([result, 'optionalAccess',
|
|
9455
|
+
return _optionalChain([result, 'optionalAccess', _338 => _338.data]) || {};
|
|
9569
9456
|
}
|
|
9570
9457
|
}
|
|
9571
9458
|
function extractPayloadChunks(payload) {
|
|
@@ -9648,7 +9535,7 @@ function getPureModelProvider(provider) {
|
|
|
9648
9535
|
|
|
9649
9536
|
${_chalk2.default.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
|
|
9650
9537
|
`;
|
|
9651
|
-
switch (_optionalChain([provider, 'optionalAccess',
|
|
9538
|
+
switch (_optionalChain([provider, 'optionalAccess', _339 => _339.id])) {
|
|
9652
9539
|
case "openai": {
|
|
9653
9540
|
if (!process.env.OPENAI_API_KEY) {
|
|
9654
9541
|
throw new Error(
|
|
@@ -9706,7 +9593,7 @@ function getPureModelProvider(provider) {
|
|
|
9706
9593
|
})(provider.model);
|
|
9707
9594
|
}
|
|
9708
9595
|
default: {
|
|
9709
|
-
throw new Error(createUnsupportedProviderErrorMessage(_optionalChain([provider, 'optionalAccess',
|
|
9596
|
+
throw new Error(createUnsupportedProviderErrorMessage(_optionalChain([provider, 'optionalAccess', _340 => _340.id])));
|
|
9710
9597
|
}
|
|
9711
9598
|
}
|
|
9712
9599
|
}
|
|
@@ -9914,6 +9801,35 @@ function createDeltaProcessor(fileKey) {
|
|
|
9914
9801
|
};
|
|
9915
9802
|
}
|
|
9916
9803
|
|
|
9804
|
+
// src/cli/loaders/xcode-xcstrings-icu.ts
|
|
9805
|
+
var ICU_TYPE_MARKER = Symbol.for("@lingo.dev/icu-plural-object");
|
|
9806
|
+
function isICUPluralObject(value) {
|
|
9807
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
9808
|
+
return false;
|
|
9809
|
+
}
|
|
9810
|
+
if (ICU_TYPE_MARKER in value) {
|
|
9811
|
+
return true;
|
|
9812
|
+
}
|
|
9813
|
+
if (!("icu" in value) || typeof value.icu !== "string") {
|
|
9814
|
+
return false;
|
|
9815
|
+
}
|
|
9816
|
+
const icuPluralPattern = /^\{[\w]+,\s*plural,\s*.+\}$/;
|
|
9817
|
+
if (!icuPluralPattern.test(value.icu)) {
|
|
9818
|
+
return false;
|
|
9819
|
+
}
|
|
9820
|
+
if (value._meta !== void 0) {
|
|
9821
|
+
if (typeof value._meta !== "object" || !value._meta.variables || typeof value._meta.variables !== "object") {
|
|
9822
|
+
return false;
|
|
9823
|
+
}
|
|
9824
|
+
for (const [varName, varMeta] of Object.entries(value._meta.variables)) {
|
|
9825
|
+
if (!varMeta || typeof varMeta !== "object" || typeof varMeta.format !== "string" || varMeta.role !== "plural" && varMeta.role !== "other") {
|
|
9826
|
+
return false;
|
|
9827
|
+
}
|
|
9828
|
+
}
|
|
9829
|
+
}
|
|
9830
|
+
return true;
|
|
9831
|
+
}
|
|
9832
|
+
|
|
9917
9833
|
// src/cli/cmd/i18n.ts
|
|
9918
9834
|
var i18n_default = new (0, _interactivecommander.Command)().command("i18n").description(
|
|
9919
9835
|
"DEPRECATED: Run localization pipeline (prefer `run` command instead)"
|
|
@@ -9992,7 +9908,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
9992
9908
|
validateParams(i18nConfig, flags);
|
|
9993
9909
|
ora.succeed("Localization configuration is valid");
|
|
9994
9910
|
ora.start("Connecting to Lingo.dev Localization Engine...");
|
|
9995
|
-
const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess',
|
|
9911
|
+
const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess', _341 => _341.provider]);
|
|
9996
9912
|
if (isByokMode) {
|
|
9997
9913
|
authId = null;
|
|
9998
9914
|
ora.succeed("Using external provider (BYOK mode)");
|
|
@@ -10006,16 +9922,16 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
10006
9922
|
flags
|
|
10007
9923
|
});
|
|
10008
9924
|
let buckets = getBuckets(i18nConfig);
|
|
10009
|
-
if (_optionalChain([flags, 'access',
|
|
9925
|
+
if (_optionalChain([flags, 'access', _342 => _342.bucket, 'optionalAccess', _343 => _343.length])) {
|
|
10010
9926
|
buckets = buckets.filter(
|
|
10011
9927
|
(bucket) => flags.bucket.includes(bucket.type)
|
|
10012
9928
|
);
|
|
10013
9929
|
}
|
|
10014
9930
|
ora.succeed("Buckets retrieved");
|
|
10015
|
-
if (_optionalChain([flags, 'access',
|
|
9931
|
+
if (_optionalChain([flags, 'access', _344 => _344.file, 'optionalAccess', _345 => _345.length])) {
|
|
10016
9932
|
buckets = buckets.map((bucket) => {
|
|
10017
9933
|
const paths = bucket.paths.filter(
|
|
10018
|
-
(path19) => flags.file.find((file) => _optionalChain([path19, 'access',
|
|
9934
|
+
(path19) => flags.file.find((file) => _optionalChain([path19, 'access', _346 => _346.pathPattern, 'optionalAccess', _347 => _347.includes, 'call', _348 => _348(file)]))
|
|
10019
9935
|
);
|
|
10020
9936
|
return { ...bucket, paths };
|
|
10021
9937
|
}).filter((bucket) => bucket.paths.length > 0);
|
|
@@ -10036,7 +9952,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
10036
9952
|
});
|
|
10037
9953
|
}
|
|
10038
9954
|
}
|
|
10039
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
9955
|
+
const targetLocales = _optionalChain([flags, 'access', _349 => _349.locale, 'optionalAccess', _350 => _350.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
10040
9956
|
ora.start("Setting up localization cache...");
|
|
10041
9957
|
const checkLockfileProcessor = createDeltaProcessor("");
|
|
10042
9958
|
const lockfileExists = await checkLockfileProcessor.checkIfLockExists();
|
|
@@ -10213,7 +10129,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
10213
10129
|
if (flags.key) {
|
|
10214
10130
|
processableData = _lodash2.default.pickBy(
|
|
10215
10131
|
processableData,
|
|
10216
|
-
(
|
|
10132
|
+
(_37, key) => key === flags.key
|
|
10217
10133
|
);
|
|
10218
10134
|
}
|
|
10219
10135
|
if (flags.verbose) {
|
|
@@ -10324,7 +10240,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
10324
10240
|
}
|
|
10325
10241
|
const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
|
|
10326
10242
|
const checksums = await deltaProcessor.createChecksums(sourceData);
|
|
10327
|
-
if (!_optionalChain([flags, 'access',
|
|
10243
|
+
if (!_optionalChain([flags, 'access', _351 => _351.locale, 'optionalAccess', _352 => _352.length])) {
|
|
10328
10244
|
await deltaProcessor.saveChecksums(checksums);
|
|
10329
10245
|
}
|
|
10330
10246
|
}
|
|
@@ -10448,12 +10364,12 @@ function validateParams(i18nConfig, flags) {
|
|
|
10448
10364
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
10449
10365
|
docUrl: "bucketNotFound"
|
|
10450
10366
|
});
|
|
10451
|
-
} else if (_optionalChain([flags, 'access',
|
|
10367
|
+
} else if (_optionalChain([flags, 'access', _353 => _353.locale, 'optionalAccess', _354 => _354.some, 'call', _355 => _355((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
10452
10368
|
throw new ValidationError({
|
|
10453
10369
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
10454
10370
|
docUrl: "localeTargetNotFound"
|
|
10455
10371
|
});
|
|
10456
|
-
} else if (_optionalChain([flags, 'access',
|
|
10372
|
+
} else if (_optionalChain([flags, 'access', _356 => _356.bucket, 'optionalAccess', _357 => _357.some, 'call', _358 => _358(
|
|
10457
10373
|
(bucket) => !i18nConfig.buckets[bucket]
|
|
10458
10374
|
)])) {
|
|
10459
10375
|
throw new ValidationError({
|
|
@@ -10857,7 +10773,7 @@ var _mcpjs = require('@modelcontextprotocol/sdk/server/mcp.js');
|
|
|
10857
10773
|
|
|
10858
10774
|
var mcp_default = new (0, _interactivecommander.Command)().command("mcp").description(
|
|
10859
10775
|
"Start a Model Context Protocol (MCP) server for AI assistant integration"
|
|
10860
|
-
).helpOption("-h, --help", "Show help").action(async (
|
|
10776
|
+
).helpOption("-h, --help", "Show help").action(async (_37, program) => {
|
|
10861
10777
|
const apiKey = program.args[0];
|
|
10862
10778
|
const settings = getSettings(apiKey);
|
|
10863
10779
|
if (!settings.auth.apiKey) {
|
|
@@ -10987,7 +10903,7 @@ function createLingoDotDevLocalizer(explicitApiKey) {
|
|
|
10987
10903
|
const response = await engine.whoami();
|
|
10988
10904
|
return {
|
|
10989
10905
|
authenticated: !!response,
|
|
10990
|
-
username: _optionalChain([response, 'optionalAccess',
|
|
10906
|
+
username: _optionalChain([response, 'optionalAccess', _359 => _359.email])
|
|
10991
10907
|
};
|
|
10992
10908
|
} catch (error) {
|
|
10993
10909
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -11103,7 +11019,7 @@ function createExplicitLocalizer(provider) {
|
|
|
11103
11019
|
}
|
|
11104
11020
|
function createAiSdkLocalizer(params) {
|
|
11105
11021
|
const skipAuth = params.skipAuth === true;
|
|
11106
|
-
const apiKey = process.env[_nullishCoalesce(_optionalChain([params, 'optionalAccess',
|
|
11022
|
+
const apiKey = process.env[_nullishCoalesce(_optionalChain([params, 'optionalAccess', _360 => _360.apiKeyName]), () => ( ""))];
|
|
11107
11023
|
if (!skipAuth && !apiKey || !params.apiKeyName) {
|
|
11108
11024
|
throw new Error(
|
|
11109
11025
|
_dedent2.default`
|
|
@@ -11237,8 +11153,8 @@ async function setup(input2) {
|
|
|
11237
11153
|
throw new Error(
|
|
11238
11154
|
"No buckets found in i18n.json. Please add at least one bucket containing i18n content."
|
|
11239
11155
|
);
|
|
11240
|
-
} else if (_optionalChain([ctx, 'access',
|
|
11241
|
-
(bucket) => !_optionalChain([ctx, 'access',
|
|
11156
|
+
} else if (_optionalChain([ctx, 'access', _361 => _361.flags, 'access', _362 => _362.bucket, 'optionalAccess', _363 => _363.some, 'call', _364 => _364(
|
|
11157
|
+
(bucket) => !_optionalChain([ctx, 'access', _365 => _365.config, 'optionalAccess', _366 => _366.buckets, 'access', _367 => _367[bucket]])
|
|
11242
11158
|
)])) {
|
|
11243
11159
|
throw new Error(
|
|
11244
11160
|
`One or more specified buckets do not exist in i18n.json. Please add them to the list first and try again.`
|
|
@@ -11251,7 +11167,7 @@ async function setup(input2) {
|
|
|
11251
11167
|
title: "Selecting localization provider",
|
|
11252
11168
|
task: async (ctx, task) => {
|
|
11253
11169
|
ctx.localizer = createLocalizer(
|
|
11254
|
-
_optionalChain([ctx, 'access',
|
|
11170
|
+
_optionalChain([ctx, 'access', _368 => _368.config, 'optionalAccess', _369 => _369.provider]),
|
|
11255
11171
|
ctx.flags.apiKey
|
|
11256
11172
|
);
|
|
11257
11173
|
if (!ctx.localizer) {
|
|
@@ -11264,7 +11180,7 @@ async function setup(input2) {
|
|
|
11264
11180
|
},
|
|
11265
11181
|
{
|
|
11266
11182
|
title: "Checking authentication",
|
|
11267
|
-
enabled: (ctx) => _optionalChain([ctx, 'access',
|
|
11183
|
+
enabled: (ctx) => _optionalChain([ctx, 'access', _370 => _370.localizer, 'optionalAccess', _371 => _371.id]) === "Lingo.dev",
|
|
11268
11184
|
task: async (ctx, task) => {
|
|
11269
11185
|
const authStatus = await ctx.localizer.checkAuth();
|
|
11270
11186
|
if (!authStatus.authenticated) {
|
|
@@ -11277,7 +11193,7 @@ async function setup(input2) {
|
|
|
11277
11193
|
},
|
|
11278
11194
|
{
|
|
11279
11195
|
title: "Validating configuration",
|
|
11280
|
-
enabled: (ctx) => _optionalChain([ctx, 'access',
|
|
11196
|
+
enabled: (ctx) => _optionalChain([ctx, 'access', _372 => _372.localizer, 'optionalAccess', _373 => _373.id]) !== "Lingo.dev",
|
|
11281
11197
|
task: async (ctx, task) => {
|
|
11282
11198
|
const validationStatus = await ctx.localizer.validateSettings();
|
|
11283
11199
|
if (!validationStatus.valid) {
|
|
@@ -11495,7 +11411,7 @@ async function execute(input2) {
|
|
|
11495
11411
|
const workerTasks = [];
|
|
11496
11412
|
for (let i = 0; i < workersCount; i++) {
|
|
11497
11413
|
const assignedTasks = ctx.tasks.filter(
|
|
11498
|
-
(
|
|
11414
|
+
(_37, idx) => idx % workersCount === i
|
|
11499
11415
|
);
|
|
11500
11416
|
workerTasks.push(
|
|
11501
11417
|
createWorkerTask({
|
|
@@ -11608,7 +11524,7 @@ function createWorkerTask(args) {
|
|
|
11608
11524
|
const processableData = _lodash2.default.chain(sourceData).entries().filter(
|
|
11609
11525
|
([key, value]) => delta.added.includes(key) || delta.updated.includes(key) || !!args.ctx.flags.force
|
|
11610
11526
|
).filter(
|
|
11611
|
-
([key]) => !assignedTask.onlyKeys.length || _optionalChain([assignedTask, 'access',
|
|
11527
|
+
([key]) => !assignedTask.onlyKeys.length || _optionalChain([assignedTask, 'access', _374 => _374.onlyKeys, 'optionalAccess', _375 => _375.some, 'call', _376 => _376(
|
|
11612
11528
|
(pattern) => minimatch(key, pattern)
|
|
11613
11529
|
)])
|
|
11614
11530
|
).fromPairs().value();
|
|
@@ -11676,7 +11592,7 @@ function createWorkerTask(args) {
|
|
|
11676
11592
|
finalRenamedTargetData
|
|
11677
11593
|
);
|
|
11678
11594
|
const checksums = await deltaProcessor.createChecksums(sourceData);
|
|
11679
|
-
if (!_optionalChain([args, 'access',
|
|
11595
|
+
if (!_optionalChain([args, 'access', _377 => _377.ctx, 'access', _378 => _378.flags, 'access', _379 => _379.targetLocale, 'optionalAccess', _380 => _380.length])) {
|
|
11680
11596
|
await deltaProcessor.saveChecksums(checksums);
|
|
11681
11597
|
}
|
|
11682
11598
|
});
|
|
@@ -11881,10 +11797,10 @@ var flagsSchema2 = _zod.z.object({
|
|
|
11881
11797
|
async function frozen(input2) {
|
|
11882
11798
|
console.log(_chalk2.default.hex(colors.orange)("[Frozen]"));
|
|
11883
11799
|
let buckets = getBuckets(input2.config);
|
|
11884
|
-
if (_optionalChain([input2, 'access',
|
|
11800
|
+
if (_optionalChain([input2, 'access', _381 => _381.flags, 'access', _382 => _382.bucket, 'optionalAccess', _383 => _383.length])) {
|
|
11885
11801
|
buckets = buckets.filter((b) => input2.flags.bucket.includes(b.type));
|
|
11886
11802
|
}
|
|
11887
|
-
if (_optionalChain([input2, 'access',
|
|
11803
|
+
if (_optionalChain([input2, 'access', _384 => _384.flags, 'access', _385 => _385.file, 'optionalAccess', _386 => _386.length])) {
|
|
11888
11804
|
buckets = buckets.map((bucket) => {
|
|
11889
11805
|
const paths = bucket.paths.filter(
|
|
11890
11806
|
(p) => input2.flags.file.some(
|
|
@@ -12021,13 +11937,13 @@ async function frozen(input2) {
|
|
|
12021
11937
|
|
|
12022
11938
|
// src/cli/cmd/run/_utils.ts
|
|
12023
11939
|
async function determineAuthId(ctx) {
|
|
12024
|
-
const isByokMode = !!_optionalChain([ctx, 'access',
|
|
11940
|
+
const isByokMode = !!_optionalChain([ctx, 'access', _387 => _387.config, 'optionalAccess', _388 => _388.provider]);
|
|
12025
11941
|
if (isByokMode) {
|
|
12026
11942
|
return null;
|
|
12027
11943
|
} else {
|
|
12028
11944
|
try {
|
|
12029
|
-
const authStatus = await _optionalChain([ctx, 'access',
|
|
12030
|
-
return _optionalChain([authStatus, 'optionalAccess',
|
|
11945
|
+
const authStatus = await _optionalChain([ctx, 'access', _389 => _389.localizer, 'optionalAccess', _390 => _390.checkAuth, 'call', _391 => _391()]);
|
|
11946
|
+
return _optionalChain([authStatus, 'optionalAccess', _392 => _392.username]) || null;
|
|
12031
11947
|
} catch (e3) {
|
|
12032
11948
|
return null;
|
|
12033
11949
|
}
|
|
@@ -12225,7 +12141,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
12225
12141
|
_child_process.execSync.call(void 0, `git config --global safe.directory ${process.cwd()}`);
|
|
12226
12142
|
_child_process.execSync.call(void 0, `git config user.name "${gitConfig.userName}"`);
|
|
12227
12143
|
_child_process.execSync.call(void 0, `git config user.email "${gitConfig.userEmail}"`);
|
|
12228
|
-
_optionalChain([this, 'access',
|
|
12144
|
+
_optionalChain([this, 'access', _393 => _393.platformKit, 'optionalAccess', _394 => _394.gitConfig, 'call', _395 => _395()]);
|
|
12229
12145
|
_child_process.execSync.call(void 0, `git fetch origin ${baseBranchName}`, { stdio: "inherit" });
|
|
12230
12146
|
_child_process.execSync.call(void 0, `git checkout ${baseBranchName} --`, { stdio: "inherit" });
|
|
12231
12147
|
if (!processOwnCommits) {
|
|
@@ -12257,7 +12173,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
12257
12173
|
// src/cli/cmd/ci/flows/pull-request.ts
|
|
12258
12174
|
var PullRequestFlow = class extends InBranchFlow {
|
|
12259
12175
|
async preRun() {
|
|
12260
|
-
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall',
|
|
12176
|
+
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _396 => _396()]);
|
|
12261
12177
|
if (!canContinue) {
|
|
12262
12178
|
return false;
|
|
12263
12179
|
}
|
|
@@ -12524,10 +12440,10 @@ var BitbucketPlatformKit = class extends PlatformKit {
|
|
|
12524
12440
|
repo_slug: this.platformConfig.repositoryName,
|
|
12525
12441
|
state: "OPEN"
|
|
12526
12442
|
}).then(({ data: { values } }) => {
|
|
12527
|
-
return _optionalChain([values, 'optionalAccess',
|
|
12528
|
-
({ source, destination }) => _optionalChain([source, 'optionalAccess',
|
|
12443
|
+
return _optionalChain([values, 'optionalAccess', _397 => _397.find, 'call', _398 => _398(
|
|
12444
|
+
({ source, destination }) => _optionalChain([source, 'optionalAccess', _399 => _399.branch, 'optionalAccess', _400 => _400.name]) === branch && _optionalChain([destination, 'optionalAccess', _401 => _401.branch, 'optionalAccess', _402 => _402.name]) === this.platformConfig.baseBranchName
|
|
12529
12445
|
)]);
|
|
12530
|
-
}).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
12446
|
+
}).then((pr) => _optionalChain([pr, 'optionalAccess', _403 => _403.id]));
|
|
12531
12447
|
}
|
|
12532
12448
|
async closePullRequest({ pullRequestNumber }) {
|
|
12533
12449
|
await this.bb.repositories.declinePullRequest({
|
|
@@ -12623,7 +12539,7 @@ var GitHubPlatformKit = class extends PlatformKit {
|
|
|
12623
12539
|
repo: this.platformConfig.repositoryName,
|
|
12624
12540
|
base: this.platformConfig.baseBranchName,
|
|
12625
12541
|
state: "open"
|
|
12626
|
-
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
12542
|
+
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess', _404 => _404.number]));
|
|
12627
12543
|
}
|
|
12628
12544
|
async closePullRequest({ pullRequestNumber }) {
|
|
12629
12545
|
await this.octokit.rest.pulls.update({
|
|
@@ -12750,7 +12666,7 @@ var GitlabPlatformKit = class extends PlatformKit {
|
|
|
12750
12666
|
sourceBranch: branch,
|
|
12751
12667
|
state: "opened"
|
|
12752
12668
|
});
|
|
12753
|
-
return _optionalChain([mergeRequests, 'access',
|
|
12669
|
+
return _optionalChain([mergeRequests, 'access', _405 => _405[0], 'optionalAccess', _406 => _406.iid]);
|
|
12754
12670
|
}
|
|
12755
12671
|
async closePullRequest({
|
|
12756
12672
|
pullRequestNumber
|
|
@@ -12862,7 +12778,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
12862
12778
|
}
|
|
12863
12779
|
const env = {
|
|
12864
12780
|
LINGODOTDEV_API_KEY: settings.auth.apiKey,
|
|
12865
|
-
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access',
|
|
12781
|
+
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _407 => _407.pullRequest, 'optionalAccess', _408 => _408.toString, 'call', _409 => _409()]) || "false",
|
|
12866
12782
|
...options.commitMessage && {
|
|
12867
12783
|
LINGODOTDEV_COMMIT_MESSAGE: options.commitMessage
|
|
12868
12784
|
},
|
|
@@ -12888,7 +12804,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
12888
12804
|
const { isPullRequestMode } = platformKit.config;
|
|
12889
12805
|
ora.info(`Pull request mode: ${isPullRequestMode ? "on" : "off"}`);
|
|
12890
12806
|
const flow = isPullRequestMode ? new PullRequestFlow(ora, platformKit) : new InBranchFlow(ora, platformKit);
|
|
12891
|
-
const canRun = await _optionalChain([flow, 'access',
|
|
12807
|
+
const canRun = await _optionalChain([flow, 'access', _410 => _410.preRun, 'optionalCall', _411 => _411()]);
|
|
12892
12808
|
if (canRun === false) {
|
|
12893
12809
|
return;
|
|
12894
12810
|
}
|
|
@@ -12898,7 +12814,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
12898
12814
|
if (!hasChanges) {
|
|
12899
12815
|
return;
|
|
12900
12816
|
}
|
|
12901
|
-
await _optionalChain([flow, 'access',
|
|
12817
|
+
await _optionalChain([flow, 'access', _412 => _412.postRun, 'optionalCall', _413 => _413()]);
|
|
12902
12818
|
});
|
|
12903
12819
|
function parseBooleanArg(val) {
|
|
12904
12820
|
if (val === true) return true;
|
|
@@ -12935,8 +12851,8 @@ function exitGracefully(elapsedMs = 0) {
|
|
|
12935
12851
|
}
|
|
12936
12852
|
}
|
|
12937
12853
|
function checkForPendingOperations() {
|
|
12938
|
-
const activeHandles = _optionalChain([process, 'access',
|
|
12939
|
-
const activeRequests = _optionalChain([process, 'access',
|
|
12854
|
+
const activeHandles = _optionalChain([process, 'access', _414 => _414._getActiveHandles, 'optionalCall', _415 => _415()]) || [];
|
|
12855
|
+
const activeRequests = _optionalChain([process, 'access', _416 => _416._getActiveRequests, 'optionalCall', _417 => _417()]) || [];
|
|
12940
12856
|
const nonStandardHandles = activeHandles.filter((handle) => {
|
|
12941
12857
|
if (handle === process.stdin || handle === process.stdout || handle === process.stderr) {
|
|
12942
12858
|
return false;
|
|
@@ -13005,17 +12921,17 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
13005
12921
|
flags
|
|
13006
12922
|
});
|
|
13007
12923
|
let buckets = getBuckets(i18nConfig);
|
|
13008
|
-
if (_optionalChain([flags, 'access',
|
|
12924
|
+
if (_optionalChain([flags, 'access', _418 => _418.bucket, 'optionalAccess', _419 => _419.length])) {
|
|
13009
12925
|
buckets = buckets.filter(
|
|
13010
12926
|
(bucket) => flags.bucket.includes(bucket.type)
|
|
13011
12927
|
);
|
|
13012
12928
|
}
|
|
13013
12929
|
ora.succeed("Buckets retrieved");
|
|
13014
|
-
if (_optionalChain([flags, 'access',
|
|
12930
|
+
if (_optionalChain([flags, 'access', _420 => _420.file, 'optionalAccess', _421 => _421.length])) {
|
|
13015
12931
|
buckets = buckets.map((bucket) => {
|
|
13016
12932
|
const paths = bucket.paths.filter(
|
|
13017
12933
|
(path19) => flags.file.find(
|
|
13018
|
-
(file) => _optionalChain([path19, 'access',
|
|
12934
|
+
(file) => _optionalChain([path19, 'access', _422 => _422.pathPattern, 'optionalAccess', _423 => _423.includes, 'call', _424 => _424(file)]) || _optionalChain([path19, 'access', _425 => _425.pathPattern, 'optionalAccess', _426 => _426.match, 'call', _427 => _427(file)]) || minimatch(path19.pathPattern, file)
|
|
13019
12935
|
)
|
|
13020
12936
|
);
|
|
13021
12937
|
return { ...bucket, paths };
|
|
@@ -13035,7 +12951,7 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
13035
12951
|
});
|
|
13036
12952
|
}
|
|
13037
12953
|
}
|
|
13038
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
12954
|
+
const targetLocales = _optionalChain([flags, 'access', _428 => _428.locale, 'optionalAccess', _429 => _429.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
13039
12955
|
let totalSourceKeyCount = 0;
|
|
13040
12956
|
let uniqueKeysToTranslate = 0;
|
|
13041
12957
|
let totalExistingTranslations = 0;
|
|
@@ -13443,12 +13359,12 @@ function validateParams2(i18nConfig, flags) {
|
|
|
13443
13359
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
13444
13360
|
docUrl: "bucketNotFound"
|
|
13445
13361
|
});
|
|
13446
|
-
} else if (_optionalChain([flags, 'access',
|
|
13362
|
+
} else if (_optionalChain([flags, 'access', _430 => _430.locale, 'optionalAccess', _431 => _431.some, 'call', _432 => _432((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
13447
13363
|
throw new CLIError({
|
|
13448
13364
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
13449
13365
|
docUrl: "localeTargetNotFound"
|
|
13450
13366
|
});
|
|
13451
|
-
} else if (_optionalChain([flags, 'access',
|
|
13367
|
+
} else if (_optionalChain([flags, 'access', _433 => _433.bucket, 'optionalAccess', _434 => _434.some, 'call', _435 => _435(
|
|
13452
13368
|
(bucket) => !i18nConfig.buckets[bucket]
|
|
13453
13369
|
)])) {
|
|
13454
13370
|
throw new CLIError({
|
|
@@ -13540,7 +13456,7 @@ async function renderHero2() {
|
|
|
13540
13456
|
// package.json
|
|
13541
13457
|
var package_default = {
|
|
13542
13458
|
name: "lingo.dev",
|
|
13543
|
-
version: "0.116.
|
|
13459
|
+
version: "0.116.3",
|
|
13544
13460
|
description: "Lingo.dev CLI",
|
|
13545
13461
|
private: false,
|
|
13546
13462
|
publishConfig: {
|
|
@@ -13832,7 +13748,7 @@ var purge_default = new (0, _interactivecommander.Command)().command("purge").de
|
|
|
13832
13748
|
if (options.file && options.file.length) {
|
|
13833
13749
|
buckets = buckets.map((bucket) => {
|
|
13834
13750
|
const paths = bucket.paths.filter(
|
|
13835
|
-
(bucketPath) => _optionalChain([options, 'access',
|
|
13751
|
+
(bucketPath) => _optionalChain([options, 'access', _436 => _436.file, 'optionalAccess', _437 => _437.some, 'call', _438 => _438((f) => bucketPath.pathPattern.includes(f))])
|
|
13836
13752
|
);
|
|
13837
13753
|
return { ...bucket, paths };
|
|
13838
13754
|
}).filter((bucket) => bucket.paths.length > 0);
|