lingo.dev 0.74.15 → 0.74.17
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 +372 -164
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +483 -275
- package/build/cli.mjs.map +1 -1
- package/package.json +1 -1
package/build/cli.cjs
CHANGED
|
@@ -25,9 +25,9 @@ function getSettings(explicitApiKey) {
|
|
|
25
25
|
_legacyEnvVarWarning();
|
|
26
26
|
return {
|
|
27
27
|
auth: {
|
|
28
|
-
apiKey: explicitApiKey || env.LINGODOTDEV_API_KEY || _optionalChain([systemFile, 'access',
|
|
29
|
-
apiUrl: env.LINGODOTDEV_API_URL || _optionalChain([systemFile, 'access',
|
|
30
|
-
webUrl: env.LINGODOTDEV_WEB_URL || _optionalChain([systemFile, 'access',
|
|
28
|
+
apiKey: explicitApiKey || env.LINGODOTDEV_API_KEY || _optionalChain([systemFile, 'access', _22 => _22.auth, 'optionalAccess', _23 => _23.apiKey]) || defaults.auth.apiKey,
|
|
29
|
+
apiUrl: env.LINGODOTDEV_API_URL || _optionalChain([systemFile, 'access', _24 => _24.auth, 'optionalAccess', _25 => _25.apiUrl]) || defaults.auth.apiUrl,
|
|
30
|
+
webUrl: env.LINGODOTDEV_WEB_URL || _optionalChain([systemFile, 'access', _26 => _26.auth, 'optionalAccess', _27 => _27.webUrl]) || defaults.auth.webUrl
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
}
|
|
@@ -137,7 +137,7 @@ function createAuthenticator(params) {
|
|
|
137
137
|
});
|
|
138
138
|
if (res.ok) {
|
|
139
139
|
const payload = await res.json();
|
|
140
|
-
if (!_optionalChain([payload, 'optionalAccess',
|
|
140
|
+
if (!_optionalChain([payload, 'optionalAccess', _28 => _28.email])) {
|
|
141
141
|
return null;
|
|
142
142
|
}
|
|
143
143
|
return {
|
|
@@ -269,9 +269,167 @@ function _getConfigFilePath() {
|
|
|
269
269
|
var _child_process = require('child_process');
|
|
270
270
|
|
|
271
271
|
var _prompts = require('@inquirer/prompts');
|
|
272
|
-
|
|
272
|
+
|
|
273
|
+
// src/cli/utils/find-locale-paths.ts
|
|
274
|
+
|
|
275
|
+
var _glob = require('glob'); var glob2 = _interopRequireWildcard(_glob);
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
function findLocaleFiles(bucket) {
|
|
279
|
+
switch (bucket) {
|
|
280
|
+
case "json":
|
|
281
|
+
return findLocaleFilesWithExtension(".json");
|
|
282
|
+
case "yaml":
|
|
283
|
+
return findLocaleFilesWithExtension(".yml");
|
|
284
|
+
case "flutter":
|
|
285
|
+
return findLocaleFilesWithExtension(".arb");
|
|
286
|
+
case "android":
|
|
287
|
+
return findLocaleFilesWithExtension(".xml");
|
|
288
|
+
case "markdown":
|
|
289
|
+
return findLocaleFilesWithExtension(".md");
|
|
290
|
+
case "xcode-xcstrings":
|
|
291
|
+
return findLocaleFilesForFilename("Localizable.xcstrings");
|
|
292
|
+
case "xcode-strings":
|
|
293
|
+
return findLocaleFilesForFilename("Localizable.strings");
|
|
294
|
+
case "xcode-stringsdict":
|
|
295
|
+
return findLocaleFilesForFilename("Localizable.stringsdict");
|
|
296
|
+
default:
|
|
297
|
+
throw new Error(`Unsupported bucket type: ${bucket}`);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
function findLocaleFilesWithExtension(ext) {
|
|
301
|
+
const files = _glob.glob.sync(`**/*${ext}`, {
|
|
302
|
+
ignore: ["node_modules/**", "package*.json", "i18n.json", "lingo.json"]
|
|
303
|
+
});
|
|
304
|
+
const localeFilePattern = new RegExp(`[/\\\\]([a-z]{2}(-[A-Z]{2})?)${ext}$`);
|
|
305
|
+
const localeDirectoryPattern = new RegExp(`[/\\\\]([a-z]{2}(-[A-Z]{2})?)[/\\\\][^/\\\\]+${ext}$`);
|
|
306
|
+
const potentialLocaleFiles = files.filter(
|
|
307
|
+
(file) => localeFilePattern.test(file) || localeDirectoryPattern.test(file)
|
|
308
|
+
);
|
|
309
|
+
const localeFilesAndPatterns = potentialLocaleFiles.map((file) => {
|
|
310
|
+
const match = file.match(new RegExp(`[/|\\\\]([a-z]{2}(-[A-Z]{2})?)(/|\\\\|${ext})`));
|
|
311
|
+
const locale = _optionalChain([match, 'optionalAccess', _29 => _29[1]]);
|
|
312
|
+
const localeInDir = _optionalChain([match, 'optionalAccess', _30 => _30[3]]) !== ext;
|
|
313
|
+
const filePattern = localeInDir ? file.replace(`/${locale}/`, `/[locale]/`) : _path2.default.join(_path2.default.dirname(file), `[locale]${ext}`);
|
|
314
|
+
return { file, locale, pattern: filePattern };
|
|
315
|
+
}).filter(({ locale }) => {
|
|
316
|
+
try {
|
|
317
|
+
__spec.resolveLocaleCode.call(void 0, locale);
|
|
318
|
+
return true;
|
|
319
|
+
} catch (e) {
|
|
320
|
+
}
|
|
321
|
+
return false;
|
|
322
|
+
});
|
|
323
|
+
const grouppedFilesAndPatterns = _lodash2.default.groupBy(localeFilesAndPatterns, "pattern");
|
|
324
|
+
const patterns = Object.keys(grouppedFilesAndPatterns);
|
|
325
|
+
if (patterns.length > 0) {
|
|
326
|
+
return { found: true, patterns };
|
|
327
|
+
}
|
|
328
|
+
return { found: false, patterns: [`i18n/[locale]${ext}`] };
|
|
329
|
+
}
|
|
330
|
+
function findLocaleFilesForFilename(fileName) {
|
|
331
|
+
const pattern = fileName;
|
|
332
|
+
const localeFiles = _glob.glob.sync(`**/${fileName}`, {
|
|
333
|
+
ignore: ["node_modules/**", "package*.json", "i18n.json", "lingo.json"]
|
|
334
|
+
});
|
|
335
|
+
const localeFilesAndPatterns = localeFiles.map((file) => ({
|
|
336
|
+
file,
|
|
337
|
+
pattern: _path2.default.join(_path2.default.dirname(file), pattern)
|
|
338
|
+
}));
|
|
339
|
+
const grouppedFilesAndPatterns = _lodash2.default.groupBy(localeFilesAndPatterns, "pattern");
|
|
340
|
+
const patterns = Object.keys(grouppedFilesAndPatterns);
|
|
341
|
+
if (patterns.length > 0) {
|
|
342
|
+
return { found: true, patterns };
|
|
343
|
+
}
|
|
344
|
+
return { found: false, patterns: [fileName] };
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// src/cli/utils/ensure-patterns.ts
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
function ensurePatterns(patterns, source) {
|
|
351
|
+
if (patterns.length === 0) {
|
|
352
|
+
throw new Error("No patterns found");
|
|
353
|
+
}
|
|
354
|
+
patterns.forEach((pattern) => {
|
|
355
|
+
const filePath = pattern.replace("[locale]", source);
|
|
356
|
+
if (!_fs2.default.existsSync(filePath)) {
|
|
357
|
+
const defaultContent = getDefaultContent(_path2.default.extname(filePath), source);
|
|
358
|
+
_fs2.default.mkdirSync(_path2.default.dirname(filePath), { recursive: true });
|
|
359
|
+
_fs2.default.writeFileSync(filePath, defaultContent);
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
function getDefaultContent(ext, source) {
|
|
364
|
+
const defaultGreeting = "Hello from Lingo.dev";
|
|
365
|
+
switch (ext) {
|
|
366
|
+
case ".json":
|
|
367
|
+
case ".arb":
|
|
368
|
+
return `{
|
|
369
|
+
"greeting": "${defaultGreeting}"
|
|
370
|
+
}`;
|
|
371
|
+
case ".yml":
|
|
372
|
+
return `${source}:
|
|
373
|
+
greeting: "${defaultGreeting}"`;
|
|
374
|
+
case ".xml":
|
|
375
|
+
return `<resources>
|
|
376
|
+
<string name="greeting">${defaultGreeting}</string>
|
|
377
|
+
</resources>`;
|
|
378
|
+
case ".md":
|
|
379
|
+
return `# ${defaultGreeting}`;
|
|
380
|
+
case ".xcstrings":
|
|
381
|
+
return `{
|
|
382
|
+
"sourceLanguage" : "${source}",
|
|
383
|
+
"strings" : {
|
|
384
|
+
"${defaultGreeting}" : {
|
|
385
|
+
"extractionState" : "manual",
|
|
386
|
+
"localizations" : {
|
|
387
|
+
"${source}" : {
|
|
388
|
+
"stringUnit" : {
|
|
389
|
+
"state" : "translated",
|
|
390
|
+
"value" : "${defaultGreeting}"
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}`;
|
|
397
|
+
case ".strings":
|
|
398
|
+
return `"greeting" = "${defaultGreeting}";`;
|
|
399
|
+
case ".stringsdict":
|
|
400
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
401
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
402
|
+
<plist version="1.0">
|
|
403
|
+
<dict>
|
|
404
|
+
<key>key</key>
|
|
405
|
+
<dict>
|
|
406
|
+
<key>NSStringLocalizedFormatKey</key>
|
|
407
|
+
<string>%#@count@</string>
|
|
408
|
+
<key>count</key>
|
|
409
|
+
<dict>
|
|
410
|
+
<key>NSStringFormatSpecTypeKey</key>
|
|
411
|
+
<string>NSStringPluralRuleType</string>
|
|
412
|
+
<key>NSStringFormatValueTypeKey</key>
|
|
413
|
+
<string>d</string>
|
|
414
|
+
<key>zero</key>
|
|
415
|
+
<string>No items</string>
|
|
416
|
+
<key>one</key>
|
|
417
|
+
<string>One item</string>
|
|
418
|
+
<key>other</key>
|
|
419
|
+
<string>%d items</string>
|
|
420
|
+
</dict>
|
|
421
|
+
</dict>
|
|
422
|
+
</dict>
|
|
423
|
+
</plist>`;
|
|
424
|
+
default:
|
|
425
|
+
throw new Error(`Unsupported file extension: ${ext}`);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// src/cli/cmd/init.ts
|
|
430
|
+
var openUrl = (path11) => {
|
|
273
431
|
const settings = getSettings(void 0);
|
|
274
|
-
_child_process.spawn.call(void 0, "open", [`${settings.auth.webUrl}${
|
|
432
|
+
_child_process.spawn.call(void 0, "open", [`${settings.auth.webUrl}${path11}`]);
|
|
275
433
|
};
|
|
276
434
|
var throwHelpError = (option, value) => {
|
|
277
435
|
if (value === "help") {
|
|
@@ -327,9 +485,10 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
327
485
|
}
|
|
328
486
|
}
|
|
329
487
|
return values;
|
|
330
|
-
}).default([])
|
|
488
|
+
}).prompt(void 0).default([])
|
|
331
489
|
).action(async (options) => {
|
|
332
490
|
const settings = getSettings(void 0);
|
|
491
|
+
const isInteractive = options.interactive;
|
|
333
492
|
const spinner = _ora2.default.call(void 0, ).start("Initializing Lingo.dev project");
|
|
334
493
|
let existingConfig = await getConfig(false);
|
|
335
494
|
if (existingConfig && !options.force) {
|
|
@@ -339,14 +498,47 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
339
498
|
const newConfig = _lodash2.default.cloneDeep(__spec.defaultConfig);
|
|
340
499
|
newConfig.locale.source = options.source;
|
|
341
500
|
newConfig.locale.targets = options.targets;
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
501
|
+
if (!isInteractive) {
|
|
502
|
+
newConfig.buckets = {
|
|
503
|
+
[options.bucket]: {
|
|
504
|
+
include: options.paths || []
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
} else {
|
|
508
|
+
let selectedPatterns = [];
|
|
509
|
+
const { found, patterns } = findLocaleFiles(options.bucket);
|
|
510
|
+
if (found) {
|
|
511
|
+
spinner.succeed("Found existing locale files:");
|
|
512
|
+
selectedPatterns = await _prompts.checkbox.call(void 0, {
|
|
513
|
+
message: "Select the paths to use",
|
|
514
|
+
choices: patterns.map((value) => ({
|
|
515
|
+
value
|
|
516
|
+
}))
|
|
517
|
+
});
|
|
518
|
+
} else {
|
|
519
|
+
spinner.succeed("No existing locale files found.");
|
|
520
|
+
const useDefault = await _prompts.confirm.call(void 0, {
|
|
521
|
+
message: `Use (and create) default path ${patterns.join(", ")}?`
|
|
522
|
+
});
|
|
523
|
+
ensurePatterns(patterns, options.source);
|
|
524
|
+
if (useDefault) {
|
|
525
|
+
selectedPatterns = patterns;
|
|
526
|
+
}
|
|
345
527
|
}
|
|
346
|
-
|
|
528
|
+
if (selectedPatterns.length === 0) {
|
|
529
|
+
const customPaths = await _prompts.input.call(void 0, {
|
|
530
|
+
message: "Enter paths to use"
|
|
531
|
+
});
|
|
532
|
+
selectedPatterns = customPaths.includes(",") ? customPaths.split(",") : customPaths.split(" ");
|
|
533
|
+
}
|
|
534
|
+
newConfig.buckets = {
|
|
535
|
+
[options.bucket]: {
|
|
536
|
+
include: selectedPatterns || []
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
}
|
|
347
540
|
await saveConfig(newConfig);
|
|
348
541
|
spinner.succeed("Lingo.dev project initialized");
|
|
349
|
-
const isInteractive = !process.argv.includes("-y") && !process.argv.includes("--no-interactive");
|
|
350
542
|
if (isInteractive) {
|
|
351
543
|
const openDocs = await _prompts.confirm.call(void 0, { message: "Would you like to see our docs?" });
|
|
352
544
|
if (openDocs) {
|
|
@@ -373,7 +565,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
373
565
|
});
|
|
374
566
|
const auth2 = await newAuthenticator.whoami();
|
|
375
567
|
if (auth2) {
|
|
376
|
-
_ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess',
|
|
568
|
+
_ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess', _31 => _31.email])}`);
|
|
377
569
|
} else {
|
|
378
570
|
_ora2.default.call(void 0, ).fail("Authentication failed.");
|
|
379
571
|
}
|
|
@@ -447,12 +639,12 @@ var locale_default = new (0, _interactivecommander.Command)().command("locale").
|
|
|
447
639
|
// src/cli/utils/buckets.ts
|
|
448
640
|
|
|
449
641
|
|
|
450
|
-
|
|
642
|
+
|
|
451
643
|
|
|
452
644
|
function getBuckets(i18nConfig) {
|
|
453
645
|
const result = Object.entries(i18nConfig.buckets).map(([bucketType, bucketEntry]) => {
|
|
454
646
|
const includeItems = bucketEntry.include.map((item) => resolveBucketItem(item));
|
|
455
|
-
const excludeItems = _optionalChain([bucketEntry, 'access',
|
|
647
|
+
const excludeItems = _optionalChain([bucketEntry, 'access', _32 => _32.exclude, 'optionalAccess', _33 => _33.map, 'call', _34 => _34((item) => resolveBucketItem(item))]);
|
|
456
648
|
return {
|
|
457
649
|
type: bucketType,
|
|
458
650
|
config: extractPathPatterns(i18nConfig.locale.source, includeItems, excludeItems)
|
|
@@ -469,7 +661,7 @@ function extractPathPatterns(sourceLocale, include, exclude) {
|
|
|
469
661
|
})
|
|
470
662
|
)
|
|
471
663
|
);
|
|
472
|
-
const excludedPatterns = _optionalChain([exclude, 'optionalAccess',
|
|
664
|
+
const excludedPatterns = _optionalChain([exclude, 'optionalAccess', _35 => _35.flatMap, 'call', _36 => _36(
|
|
473
665
|
(pattern) => expandPlaceholderedGlob(pattern.path, __spec.resolveOverridenLocale.call(void 0, sourceLocale, pattern.delimiter)).map(
|
|
474
666
|
(pathPattern) => ({
|
|
475
667
|
pathPattern,
|
|
@@ -503,9 +695,9 @@ function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
|
|
|
503
695
|
}
|
|
504
696
|
const pathPatternChunks = pathPattern.split(_path2.default.sep);
|
|
505
697
|
const localeSegmentIndex = pathPatternChunks.findIndex((segment) => segment.includes("[locale]"));
|
|
506
|
-
const localePlaceholderIndex = _nullishCoalesce(_optionalChain([pathPatternChunks, 'access',
|
|
698
|
+
const localePlaceholderIndex = _nullishCoalesce(_optionalChain([pathPatternChunks, 'access', _37 => _37[localeSegmentIndex], 'optionalAccess', _38 => _38.indexOf, 'call', _39 => _39("[locale]")]), () => ( -1));
|
|
507
699
|
const sourcePathPattern = pathPattern.replace(/\[locale\]/g, sourceLocale);
|
|
508
|
-
const sourcePaths =
|
|
700
|
+
const sourcePaths = glob2.sync(sourcePathPattern, { follow: true, withFileTypes: true }).filter((file) => file.isFile() || file.isSymbolicLink()).map((file) => file.fullpath()).map((fullpath) => _path2.default.relative(process.cwd(), fullpath));
|
|
509
701
|
const placeholderedPaths = sourcePaths.map((sourcePath) => {
|
|
510
702
|
const sourcePathChunks = sourcePath.split(_path2.default.sep);
|
|
511
703
|
if (localeSegmentIndex >= 0 && localePlaceholderIndex >= 0) {
|
|
@@ -555,8 +747,8 @@ var files_default = new (0, _interactivecommander.Command)().command("files").de
|
|
|
555
747
|
} else if (type.target) {
|
|
556
748
|
result.push(...targetPaths);
|
|
557
749
|
}
|
|
558
|
-
result.forEach((
|
|
559
|
-
console.log(
|
|
750
|
+
result.forEach((path11) => {
|
|
751
|
+
console.log(path11);
|
|
560
752
|
});
|
|
561
753
|
}
|
|
562
754
|
}
|
|
@@ -588,17 +780,17 @@ function composeLoaders(...loaders) {
|
|
|
588
780
|
return {
|
|
589
781
|
init: async () => {
|
|
590
782
|
for (const loader of loaders) {
|
|
591
|
-
await _optionalChain([loader, 'access',
|
|
783
|
+
await _optionalChain([loader, 'access', _40 => _40.init, 'optionalCall', _41 => _41()]);
|
|
592
784
|
}
|
|
593
785
|
},
|
|
594
786
|
setDefaultLocale(locale) {
|
|
595
787
|
for (const loader of loaders) {
|
|
596
|
-
_optionalChain([loader, 'access',
|
|
788
|
+
_optionalChain([loader, 'access', _42 => _42.setDefaultLocale, 'optionalCall', _43 => _43(locale)]);
|
|
597
789
|
}
|
|
598
790
|
return this;
|
|
599
791
|
},
|
|
600
|
-
pull: async (locale,
|
|
601
|
-
let result =
|
|
792
|
+
pull: async (locale, input2) => {
|
|
793
|
+
let result = input2;
|
|
602
794
|
for (let i = 0; i < loaders.length; i++) {
|
|
603
795
|
result = await loaders[i].pull(locale, result);
|
|
604
796
|
}
|
|
@@ -624,7 +816,7 @@ function createLoader(lDefinition) {
|
|
|
624
816
|
if (state.initCtx) {
|
|
625
817
|
return state.initCtx;
|
|
626
818
|
}
|
|
627
|
-
state.initCtx = await _optionalChain([lDefinition, 'access',
|
|
819
|
+
state.initCtx = await _optionalChain([lDefinition, 'access', _44 => _44.init, 'optionalCall', _45 => _45()]);
|
|
628
820
|
return state.initCtx;
|
|
629
821
|
},
|
|
630
822
|
setDefaultLocale(locale) {
|
|
@@ -634,7 +826,7 @@ function createLoader(lDefinition) {
|
|
|
634
826
|
state.defaultLocale = locale;
|
|
635
827
|
return this;
|
|
636
828
|
},
|
|
637
|
-
async pull(locale,
|
|
829
|
+
async pull(locale, input2) {
|
|
638
830
|
if (!state.defaultLocale) {
|
|
639
831
|
throw new Error("Default locale not set");
|
|
640
832
|
}
|
|
@@ -642,9 +834,9 @@ function createLoader(lDefinition) {
|
|
|
642
834
|
throw new Error("The first pull must be for the default locale");
|
|
643
835
|
}
|
|
644
836
|
if (locale === state.defaultLocale) {
|
|
645
|
-
state.originalInput =
|
|
837
|
+
state.originalInput = input2 || null;
|
|
646
838
|
}
|
|
647
|
-
return lDefinition.pull(locale,
|
|
839
|
+
return lDefinition.pull(locale, input2, state.initCtx);
|
|
648
840
|
},
|
|
649
841
|
async push(locale, data) {
|
|
650
842
|
if (!state.defaultLocale) {
|
|
@@ -663,8 +855,8 @@ function createLoader(lDefinition) {
|
|
|
663
855
|
var _jsonrepair = require('jsonrepair');
|
|
664
856
|
function createJsonLoader() {
|
|
665
857
|
return createLoader({
|
|
666
|
-
pull: async (locale,
|
|
667
|
-
const jsonString =
|
|
858
|
+
pull: async (locale, input2) => {
|
|
859
|
+
const jsonString = input2 || "{}";
|
|
668
860
|
let result;
|
|
669
861
|
try {
|
|
670
862
|
result = JSON.parse(jsonString);
|
|
@@ -685,30 +877,43 @@ var _flat = require('flat');
|
|
|
685
877
|
|
|
686
878
|
var OBJECT_NUMERIC_KEY_PREFIX = "__lingodotdev__obj__";
|
|
687
879
|
function createFlatLoader() {
|
|
688
|
-
|
|
880
|
+
return composeLoaders(createDenormalizeLoader(), createNormalizeLoader());
|
|
881
|
+
}
|
|
882
|
+
function createDenormalizeLoader() {
|
|
689
883
|
return createLoader({
|
|
690
|
-
pull: async (locale,
|
|
691
|
-
const
|
|
692
|
-
const
|
|
884
|
+
pull: async (locale, input2) => {
|
|
885
|
+
const inputDenormalized = denormalizeObjectKeys(input2 || {});
|
|
886
|
+
const denormalized = _flat.flatten.call(void 0, inputDenormalized, {
|
|
693
887
|
delimiter: "/",
|
|
694
888
|
transformKey(key) {
|
|
695
889
|
return encodeURIComponent(String(key));
|
|
696
890
|
}
|
|
697
891
|
});
|
|
698
|
-
|
|
699
|
-
|
|
892
|
+
const keysMap = buildDenormalizedKeysMap(denormalized);
|
|
893
|
+
return { denormalized, keysMap };
|
|
894
|
+
},
|
|
895
|
+
push: async (locale, { denormalized }) => {
|
|
896
|
+
const normalized = normalizeObjectKeys(denormalized);
|
|
897
|
+
return normalized;
|
|
898
|
+
}
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
function createNormalizeLoader() {
|
|
902
|
+
return createLoader({
|
|
903
|
+
pull: async (locale, input2) => {
|
|
904
|
+
const normalized = normalizeObjectKeys(input2.denormalized);
|
|
700
905
|
return normalized;
|
|
701
906
|
},
|
|
702
|
-
push: async (locale, data) => {
|
|
703
|
-
const
|
|
704
|
-
const
|
|
907
|
+
push: async (locale, data, originalInput) => {
|
|
908
|
+
const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess', _46 => _46.keysMap]), () => ( {}));
|
|
909
|
+
const input2 = mapDenormalizedKeys(data, keysMap);
|
|
910
|
+
const denormalized = _flat.unflatten.call(void 0, input2, {
|
|
705
911
|
delimiter: "/",
|
|
706
912
|
transformKey(key) {
|
|
707
913
|
return decodeURIComponent(String(key));
|
|
708
914
|
}
|
|
709
915
|
});
|
|
710
|
-
|
|
711
|
-
return normalized;
|
|
916
|
+
return { denormalized, keysMap: keysMap || {} };
|
|
712
917
|
}
|
|
713
918
|
});
|
|
714
919
|
}
|
|
@@ -728,7 +933,7 @@ function buildDenormalizedKeysMap(obj) {
|
|
|
728
933
|
function mapDenormalizedKeys(obj, denormalizedKeysMap) {
|
|
729
934
|
return Object.keys(obj).reduce(
|
|
730
935
|
(acc, key) => {
|
|
731
|
-
const denormalizedKey = denormalizedKeysMap[key];
|
|
936
|
+
const denormalizedKey = _nullishCoalesce(denormalizedKeysMap[key], () => ( key));
|
|
732
937
|
acc[denormalizedKey] = obj[key];
|
|
733
938
|
return acc;
|
|
734
939
|
},
|
|
@@ -774,7 +979,7 @@ function createTextFileLoader(pathPattern) {
|
|
|
774
979
|
const trimmedResult = result.trim();
|
|
775
980
|
return trimmedResult;
|
|
776
981
|
},
|
|
777
|
-
async push(locale, data,
|
|
982
|
+
async push(locale, data, _21, originalLocale) {
|
|
778
983
|
const draftPath = pathPattern.replace("[locale]", locale);
|
|
779
984
|
const finalPath = _path2.default.resolve(draftPath);
|
|
780
985
|
const dirPath = _path2.default.dirname(finalPath);
|
|
@@ -803,8 +1008,8 @@ async function getTrailingNewLine(pathPattern, locale, originalLocale) {
|
|
|
803
1008
|
if (!templateData) {
|
|
804
1009
|
templateData = await readFileForLocale(pathPattern, originalLocale);
|
|
805
1010
|
}
|
|
806
|
-
if (_optionalChain([templateData, 'optionalAccess',
|
|
807
|
-
const ending = _optionalChain([templateData, 'optionalAccess',
|
|
1011
|
+
if (_optionalChain([templateData, 'optionalAccess', _47 => _47.match, 'call', _48 => _48(/[\r\n]$/)])) {
|
|
1012
|
+
const ending = _optionalChain([templateData, 'optionalAccess', _49 => _49.includes, 'call', _50 => _50("\r\n")]) ? "\r\n" : _optionalChain([templateData, 'optionalAccess', _51 => _51.includes, 'call', _52 => _52("\r")]) ? "\r" : "\n";
|
|
808
1013
|
return ending;
|
|
809
1014
|
}
|
|
810
1015
|
return "";
|
|
@@ -814,8 +1019,8 @@ async function getTrailingNewLine(pathPattern, locale, originalLocale) {
|
|
|
814
1019
|
var _yaml = require('yaml'); var _yaml2 = _interopRequireDefault(_yaml);
|
|
815
1020
|
function createYamlLoader() {
|
|
816
1021
|
return createLoader({
|
|
817
|
-
async pull(locale,
|
|
818
|
-
return _yaml2.default.parse(
|
|
1022
|
+
async pull(locale, input2) {
|
|
1023
|
+
return _yaml2.default.parse(input2) || {};
|
|
819
1024
|
},
|
|
820
1025
|
async push(locale, payload) {
|
|
821
1026
|
return _yaml2.default.stringify(payload, {
|
|
@@ -828,8 +1033,8 @@ function createYamlLoader() {
|
|
|
828
1033
|
// src/cli/loaders/root-key.ts
|
|
829
1034
|
function createRootKeyLoader(replaceAll = false) {
|
|
830
1035
|
return createLoader({
|
|
831
|
-
async pull(locale,
|
|
832
|
-
const result =
|
|
1036
|
+
async pull(locale, input2) {
|
|
1037
|
+
const result = input2[locale];
|
|
833
1038
|
return result;
|
|
834
1039
|
},
|
|
835
1040
|
async push(locale, data, originalInput) {
|
|
@@ -846,8 +1051,8 @@ function createRootKeyLoader(replaceAll = false) {
|
|
|
846
1051
|
|
|
847
1052
|
function createFlutterLoader() {
|
|
848
1053
|
return createLoader({
|
|
849
|
-
async pull(locale,
|
|
850
|
-
const result = _lodash2.default.pickBy(
|
|
1054
|
+
async pull(locale, input2) {
|
|
1055
|
+
const result = _lodash2.default.pickBy(input2, (value, key) => !key.startsWith("@"));
|
|
851
1056
|
return result;
|
|
852
1057
|
},
|
|
853
1058
|
async push(locale, data, originalInput) {
|
|
@@ -861,10 +1066,10 @@ function createFlutterLoader() {
|
|
|
861
1066
|
var _xml2js = require('xml2js');
|
|
862
1067
|
function createAndroidLoader() {
|
|
863
1068
|
return createLoader({
|
|
864
|
-
async pull(locale,
|
|
1069
|
+
async pull(locale, input2) {
|
|
865
1070
|
try {
|
|
866
1071
|
const result = {};
|
|
867
|
-
const parsed = !
|
|
1072
|
+
const parsed = !input2 ? { resources: {} } : await _xml2js.parseStringPromise.call(void 0, input2, { explicitArray: true });
|
|
868
1073
|
if (!parsed || !parsed.resources) {
|
|
869
1074
|
console.warn("No resources found in the Android resource file");
|
|
870
1075
|
return result;
|
|
@@ -957,12 +1162,12 @@ var _sync3 = require('csv-stringify/sync');
|
|
|
957
1162
|
function createCsvLoader() {
|
|
958
1163
|
return createLoader({
|
|
959
1164
|
async pull(locale, _input) {
|
|
960
|
-
const
|
|
1165
|
+
const input2 = _sync.parse.call(void 0, _input, {
|
|
961
1166
|
columns: true,
|
|
962
1167
|
skip_empty_lines: true
|
|
963
1168
|
});
|
|
964
1169
|
const result = {};
|
|
965
|
-
_lodash2.default.forEach(
|
|
1170
|
+
_lodash2.default.forEach(input2, (row) => {
|
|
966
1171
|
const key = row.id;
|
|
967
1172
|
if (key && row[locale] && row[locale].trim() !== "") {
|
|
968
1173
|
result[key] = row[locale];
|
|
@@ -971,16 +1176,16 @@ function createCsvLoader() {
|
|
|
971
1176
|
return result;
|
|
972
1177
|
},
|
|
973
1178
|
async push(locale, data, originalInput) {
|
|
974
|
-
const
|
|
1179
|
+
const input2 = _sync.parse.call(void 0, originalInput || "", {
|
|
975
1180
|
columns: true,
|
|
976
1181
|
skip_empty_lines: true
|
|
977
1182
|
});
|
|
978
|
-
const columns =
|
|
979
|
-
const updatedRows =
|
|
1183
|
+
const columns = input2.length > 0 ? Object.keys(input2[0]) : ["id", locale];
|
|
1184
|
+
const updatedRows = input2.map((row) => ({
|
|
980
1185
|
...row,
|
|
981
1186
|
[locale]: data[row.id] || row[locale] || ""
|
|
982
1187
|
}));
|
|
983
|
-
const existingKeys = new Set(
|
|
1188
|
+
const existingKeys = new Set(input2.map((row) => row.id));
|
|
984
1189
|
Object.entries(data).forEach(([key, value]) => {
|
|
985
1190
|
if (!existingKeys.has(key)) {
|
|
986
1191
|
const newRow = {
|
|
@@ -1015,9 +1220,9 @@ function createHtmlLoader() {
|
|
|
1015
1220
|
};
|
|
1016
1221
|
const UNLOCALIZABLE_TAGS = ["script", "style"];
|
|
1017
1222
|
return createLoader({
|
|
1018
|
-
async pull(locale,
|
|
1223
|
+
async pull(locale, input2) {
|
|
1019
1224
|
const result = {};
|
|
1020
|
-
const dom = new (0, _jsdom.JSDOM)(
|
|
1225
|
+
const dom = new (0, _jsdom.JSDOM)(input2);
|
|
1021
1226
|
const document = dom.window.document;
|
|
1022
1227
|
const getPath = (node, attribute) => {
|
|
1023
1228
|
const indices = [];
|
|
@@ -1031,7 +1236,7 @@ function createHtmlLoader() {
|
|
|
1031
1236
|
break;
|
|
1032
1237
|
}
|
|
1033
1238
|
const siblings = Array.from(parent.childNodes).filter(
|
|
1034
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1239
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _53 => _53.textContent, 'optionalAccess', _54 => _54.trim, 'call', _55 => _55()])
|
|
1035
1240
|
);
|
|
1036
1241
|
const index = siblings.indexOf(current);
|
|
1037
1242
|
if (index !== -1) {
|
|
@@ -1066,11 +1271,11 @@ function createHtmlLoader() {
|
|
|
1066
1271
|
result[getPath(element, attr)] = value;
|
|
1067
1272
|
}
|
|
1068
1273
|
});
|
|
1069
|
-
Array.from(element.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1274
|
+
Array.from(element.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _56 => _56.textContent, 'optionalAccess', _57 => _57.trim, 'call', _58 => _58()])).forEach(processNode);
|
|
1070
1275
|
}
|
|
1071
1276
|
};
|
|
1072
|
-
Array.from(document.head.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1073
|
-
Array.from(document.body.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1277
|
+
Array.from(document.head.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _59 => _59.textContent, 'optionalAccess', _60 => _60.trim, 'call', _61 => _61()])).forEach(processNode);
|
|
1278
|
+
Array.from(document.body.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _62 => _62.textContent, 'optionalAccess', _63 => _63.trim, 'call', _64 => _64()])).forEach(processNode);
|
|
1074
1279
|
return result;
|
|
1075
1280
|
},
|
|
1076
1281
|
async push(locale, data, originalInput) {
|
|
@@ -1083,16 +1288,16 @@ function createHtmlLoader() {
|
|
|
1083
1288
|
const bDepth = b.split("/").length;
|
|
1084
1289
|
return aDepth - bDepth;
|
|
1085
1290
|
});
|
|
1086
|
-
paths.forEach((
|
|
1087
|
-
const value = data[
|
|
1088
|
-
const [nodePath, attribute] =
|
|
1291
|
+
paths.forEach((path11) => {
|
|
1292
|
+
const value = data[path11];
|
|
1293
|
+
const [nodePath, attribute] = path11.split("#");
|
|
1089
1294
|
const [rootTag, ...indices] = nodePath.split("/");
|
|
1090
1295
|
let parent = rootTag === "head" ? document.head : document.body;
|
|
1091
1296
|
let current = parent;
|
|
1092
1297
|
for (let i = 0; i < indices.length; i++) {
|
|
1093
1298
|
const index = parseInt(indices[i]);
|
|
1094
1299
|
const siblings = Array.from(parent.childNodes).filter(
|
|
1095
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1300
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _65 => _65.textContent, 'optionalAccess', _66 => _66.trim, 'call', _67 => _67()])
|
|
1096
1301
|
);
|
|
1097
1302
|
if (index >= siblings.length) {
|
|
1098
1303
|
if (i === indices.length - 1) {
|
|
@@ -1137,8 +1342,8 @@ var yamlEngine = {
|
|
|
1137
1342
|
};
|
|
1138
1343
|
function createMarkdownLoader() {
|
|
1139
1344
|
return createLoader({
|
|
1140
|
-
async pull(locale,
|
|
1141
|
-
const { data: frontmatter, content } = _graymatter2.default.call(void 0,
|
|
1345
|
+
async pull(locale, input2) {
|
|
1346
|
+
const { data: frontmatter, content } = _graymatter2.default.call(void 0, input2, {
|
|
1142
1347
|
engines: {
|
|
1143
1348
|
yaml: yamlEngine
|
|
1144
1349
|
}
|
|
@@ -1188,7 +1393,7 @@ function createPropertiesLoader() {
|
|
|
1188
1393
|
return result;
|
|
1189
1394
|
},
|
|
1190
1395
|
async push(locale, payload) {
|
|
1191
|
-
const result = Object.entries(payload).filter(([
|
|
1396
|
+
const result = Object.entries(payload).filter(([_21, value]) => value != null).map(([key, value]) => `${key}=${value}`).join("\n");
|
|
1192
1397
|
return result;
|
|
1193
1398
|
}
|
|
1194
1399
|
});
|
|
@@ -1199,7 +1404,7 @@ function isSkippableLine(line) {
|
|
|
1199
1404
|
function parsePropertyLine(line) {
|
|
1200
1405
|
const [key, ...valueParts] = line.split("=");
|
|
1201
1406
|
return {
|
|
1202
|
-
key: _optionalChain([key, 'optionalAccess',
|
|
1407
|
+
key: _optionalChain([key, 'optionalAccess', _68 => _68.trim, 'call', _69 => _69()]) || "",
|
|
1203
1408
|
value: valueParts.join("=").trim()
|
|
1204
1409
|
};
|
|
1205
1410
|
}
|
|
@@ -1207,8 +1412,8 @@ function parsePropertyLine(line) {
|
|
|
1207
1412
|
// src/cli/loaders/xcode-strings.ts
|
|
1208
1413
|
function createXcodeStringsLoader() {
|
|
1209
1414
|
return createLoader({
|
|
1210
|
-
async pull(locale,
|
|
1211
|
-
const lines =
|
|
1415
|
+
async pull(locale, input2) {
|
|
1416
|
+
const lines = input2.split("\n");
|
|
1212
1417
|
const result = {};
|
|
1213
1418
|
for (const line of lines) {
|
|
1214
1419
|
const trimmedLine = line.trim();
|
|
@@ -1249,9 +1454,9 @@ var emptyData = [
|
|
|
1249
1454
|
].join("\n");
|
|
1250
1455
|
function createXcodeStringsdictLoader() {
|
|
1251
1456
|
return createLoader({
|
|
1252
|
-
async pull(locale,
|
|
1457
|
+
async pull(locale, input2) {
|
|
1253
1458
|
try {
|
|
1254
|
-
const parsed = _plist2.default.parse(
|
|
1459
|
+
const parsed = _plist2.default.parse(input2 || emptyData);
|
|
1255
1460
|
if (typeof parsed !== "object" || parsed === null) {
|
|
1256
1461
|
throw new CLIError({
|
|
1257
1462
|
message: "Invalid .stringsdict format",
|
|
@@ -1277,11 +1482,11 @@ function createXcodeStringsdictLoader() {
|
|
|
1277
1482
|
|
|
1278
1483
|
function createXcodeXcstringsLoader() {
|
|
1279
1484
|
return createLoader({
|
|
1280
|
-
async pull(locale,
|
|
1485
|
+
async pull(locale, input2) {
|
|
1281
1486
|
const resultData = {};
|
|
1282
|
-
for (const [translationKey, _translationEntity] of Object.entries(
|
|
1487
|
+
for (const [translationKey, _translationEntity] of Object.entries(input2.strings)) {
|
|
1283
1488
|
const rootTranslationEntity = _translationEntity;
|
|
1284
|
-
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess',
|
|
1489
|
+
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _70 => _70.localizations, 'optionalAccess', _71 => _71[locale]]);
|
|
1285
1490
|
if (langTranslationEntity) {
|
|
1286
1491
|
if ("stringUnit" in langTranslationEntity) {
|
|
1287
1492
|
resultData[translationKey] = langTranslationEntity.stringUnit.value;
|
|
@@ -1290,7 +1495,7 @@ function createXcodeXcstringsLoader() {
|
|
|
1290
1495
|
resultData[translationKey] = {};
|
|
1291
1496
|
const pluralForms = langTranslationEntity.variations.plural;
|
|
1292
1497
|
for (const form in pluralForms) {
|
|
1293
|
-
if (_optionalChain([pluralForms, 'access',
|
|
1498
|
+
if (_optionalChain([pluralForms, 'access', _72 => _72[form], 'optionalAccess', _73 => _73.stringUnit, 'optionalAccess', _74 => _74.value])) {
|
|
1294
1499
|
resultData[translationKey][form] = pluralForms[form].stringUnit.value;
|
|
1295
1500
|
}
|
|
1296
1501
|
}
|
|
@@ -1383,7 +1588,7 @@ async function loadPrettierConfig() {
|
|
|
1383
1588
|
|
|
1384
1589
|
var _isurl = require('is-url'); var _isurl2 = _interopRequireDefault(_isurl);
|
|
1385
1590
|
var _datefns = require('date-fns');
|
|
1386
|
-
function createUnlocalizableLoader() {
|
|
1591
|
+
function createUnlocalizableLoader(isCacheRestore = false) {
|
|
1387
1592
|
const rules = {
|
|
1388
1593
|
isEmpty: (v) => _lodash2.default.isEmpty(v),
|
|
1389
1594
|
isNumber: (v) => !_lodash2.default.isNaN(_lodash2.default.toNumber(v)),
|
|
@@ -1393,19 +1598,22 @@ function createUnlocalizableLoader() {
|
|
|
1393
1598
|
isUrl: (v) => _lodash2.default.isString(v) && _isurl2.default.call(void 0, v)
|
|
1394
1599
|
};
|
|
1395
1600
|
return createLoader({
|
|
1396
|
-
async pull(locale,
|
|
1397
|
-
const passthroughKeys = Object.entries(
|
|
1601
|
+
async pull(locale, input2) {
|
|
1602
|
+
const passthroughKeys = Object.entries(input2).filter(([key, value]) => {
|
|
1398
1603
|
for (const [ruleName, rule] of Object.entries(rules)) {
|
|
1399
1604
|
if (rule(value)) {
|
|
1400
1605
|
return true;
|
|
1401
1606
|
}
|
|
1402
1607
|
}
|
|
1403
1608
|
return false;
|
|
1404
|
-
}).map(([key,
|
|
1405
|
-
const result = _lodash2.default.omitBy(
|
|
1609
|
+
}).map(([key, _21]) => key);
|
|
1610
|
+
const result = _lodash2.default.omitBy(input2, (_21, key) => passthroughKeys.includes(key));
|
|
1406
1611
|
return result;
|
|
1407
1612
|
},
|
|
1408
1613
|
async push(locale, data, originalInput) {
|
|
1614
|
+
if (isCacheRestore) {
|
|
1615
|
+
return _lodash2.default.merge({}, data);
|
|
1616
|
+
}
|
|
1409
1617
|
const result = _lodash2.default.merge({}, originalInput, data);
|
|
1410
1618
|
return result;
|
|
1411
1619
|
}
|
|
@@ -1426,10 +1634,10 @@ function createPoLoader(params = { multiline: false }) {
|
|
|
1426
1634
|
}
|
|
1427
1635
|
function createPoDataLoader(params) {
|
|
1428
1636
|
return createLoader({
|
|
1429
|
-
async pull(locale,
|
|
1430
|
-
const parsedPo = _gettextparser2.default.po.parse(
|
|
1637
|
+
async pull(locale, input2) {
|
|
1638
|
+
const parsedPo = _gettextparser2.default.po.parse(input2);
|
|
1431
1639
|
const result = {};
|
|
1432
|
-
const sections =
|
|
1640
|
+
const sections = input2.split("\n\n").filter(Boolean);
|
|
1433
1641
|
for (const section of sections) {
|
|
1434
1642
|
const sectionPo = _gettextparser2.default.po.parse(section);
|
|
1435
1643
|
const contextKey = _lodash2.default.keys(sectionPo.translations)[0];
|
|
@@ -1437,7 +1645,7 @@ function createPoDataLoader(params) {
|
|
|
1437
1645
|
Object.entries(entries).forEach(([msgid, entry]) => {
|
|
1438
1646
|
if (msgid && entry.msgid) {
|
|
1439
1647
|
const context = entry.msgctxt || "";
|
|
1440
|
-
const fullEntry = _optionalChain([parsedPo, 'access',
|
|
1648
|
+
const fullEntry = _optionalChain([parsedPo, 'access', _75 => _75.translations, 'access', _76 => _76[context], 'optionalAccess', _77 => _77[msgid]]);
|
|
1441
1649
|
if (fullEntry) {
|
|
1442
1650
|
result[msgid] = fullEntry;
|
|
1443
1651
|
}
|
|
@@ -1447,7 +1655,7 @@ function createPoDataLoader(params) {
|
|
|
1447
1655
|
return result;
|
|
1448
1656
|
},
|
|
1449
1657
|
async push(locale, data, originalInput) {
|
|
1450
|
-
const sections = _optionalChain([originalInput, 'optionalAccess',
|
|
1658
|
+
const sections = _optionalChain([originalInput, 'optionalAccess', _78 => _78.split, 'call', _79 => _79("\n\n"), 'access', _80 => _80.filter, 'call', _81 => _81(Boolean)]) || [];
|
|
1451
1659
|
const result = sections.map((section) => {
|
|
1452
1660
|
const sectionPo = _gettextparser2.default.po.parse(section);
|
|
1453
1661
|
const contextKey = _lodash2.default.keys(sectionPo.translations)[0];
|
|
@@ -1474,8 +1682,8 @@ function createPoDataLoader(params) {
|
|
|
1474
1682
|
}
|
|
1475
1683
|
function createPoContentLoader() {
|
|
1476
1684
|
return createLoader({
|
|
1477
|
-
async pull(locale,
|
|
1478
|
-
const result = _lodash2.default.chain(
|
|
1685
|
+
async pull(locale, input2) {
|
|
1686
|
+
const result = _lodash2.default.chain(input2).entries().filter(([, entry]) => !!entry.msgid).map(([, entry]) => [
|
|
1479
1687
|
entry.msgid,
|
|
1480
1688
|
{
|
|
1481
1689
|
singular: entry.msgstr[0] || entry.msgid,
|
|
@@ -1489,7 +1697,7 @@ function createPoContentLoader() {
|
|
|
1489
1697
|
entry.msgid,
|
|
1490
1698
|
{
|
|
1491
1699
|
...entry,
|
|
1492
|
-
msgstr: [_optionalChain([data, 'access',
|
|
1700
|
+
msgstr: [_optionalChain([data, 'access', _82 => _82[entry.msgid], 'optionalAccess', _83 => _83.singular]), _optionalChain([data, 'access', _84 => _84[entry.msgid], 'optionalAccess', _85 => _85.plural]) || null].filter(Boolean)
|
|
1493
1701
|
}
|
|
1494
1702
|
]).fromPairs().value();
|
|
1495
1703
|
return result;
|
|
@@ -1501,8 +1709,8 @@ function createPoContentLoader() {
|
|
|
1501
1709
|
var _xliff = require('xliff'); var _xliff2 = _interopRequireDefault(_xliff);
|
|
1502
1710
|
function createXliffLoader() {
|
|
1503
1711
|
return createLoader({
|
|
1504
|
-
async pull(locale,
|
|
1505
|
-
const js = await _xliff2.default.xliff2js(
|
|
1712
|
+
async pull(locale, input2) {
|
|
1713
|
+
const js = await _xliff2.default.xliff2js(input2);
|
|
1506
1714
|
return js || {};
|
|
1507
1715
|
},
|
|
1508
1716
|
async push(locale, payload) {
|
|
@@ -1519,10 +1727,10 @@ function normalizeXMLString(xmlString) {
|
|
|
1519
1727
|
}
|
|
1520
1728
|
function createXmlLoader() {
|
|
1521
1729
|
return createLoader({
|
|
1522
|
-
async pull(locale,
|
|
1730
|
+
async pull(locale, input2) {
|
|
1523
1731
|
let result = {};
|
|
1524
1732
|
try {
|
|
1525
|
-
const parsed = await _xml2js.parseStringPromise.call(void 0,
|
|
1733
|
+
const parsed = await _xml2js.parseStringPromise.call(void 0, input2, {
|
|
1526
1734
|
explicitArray: false,
|
|
1527
1735
|
mergeAttrs: false,
|
|
1528
1736
|
normalize: true,
|
|
@@ -1557,8 +1765,8 @@ var _srtparser2 = require('srt-parser-2'); var _srtparser22 = _interopRequireDef
|
|
|
1557
1765
|
function createSrtLoader() {
|
|
1558
1766
|
const parser = new (0, _srtparser22.default)();
|
|
1559
1767
|
return createLoader({
|
|
1560
|
-
async pull(locale,
|
|
1561
|
-
const parsed = parser.fromSrt(
|
|
1768
|
+
async pull(locale, input2) {
|
|
1769
|
+
const parsed = parser.fromSrt(input2) || [];
|
|
1562
1770
|
const result = {};
|
|
1563
1771
|
parsed.forEach((entry) => {
|
|
1564
1772
|
const key = `${entry.id}#${entry.startTime}-${entry.endTime}`;
|
|
@@ -1611,9 +1819,9 @@ var datoSettingsSchema = _zod2.default.object({
|
|
|
1611
1819
|
|
|
1612
1820
|
function createDatoFilterLoader() {
|
|
1613
1821
|
return createLoader({
|
|
1614
|
-
async pull(locale,
|
|
1822
|
+
async pull(locale, input2) {
|
|
1615
1823
|
const result = {};
|
|
1616
|
-
for (const [modelId, modelInfo] of _lodash2.default.entries(
|
|
1824
|
+
for (const [modelId, modelInfo] of _lodash2.default.entries(input2)) {
|
|
1617
1825
|
result[modelId] = {};
|
|
1618
1826
|
for (const record of modelInfo.records) {
|
|
1619
1827
|
result[modelId][record.id] = _lodash2.default.chain(modelInfo.fields).mapKeys((field) => field.api_key).mapValues((field) => _lodash2.default.get(record, [field.api_key, locale])).value();
|
|
@@ -1735,7 +1943,7 @@ function createDatoClient(params) {
|
|
|
1735
1943
|
only_valid: "true",
|
|
1736
1944
|
ids: !records.length ? void 0 : records.join(",")
|
|
1737
1945
|
}
|
|
1738
|
-
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
1946
|
+
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _86 => _86.response, 'optionalAccess', _87 => _87.body, 'optionalAccess', _88 => _88.data, 'optionalAccess', _89 => _89[0]]) || error));
|
|
1739
1947
|
},
|
|
1740
1948
|
findRecordsForModel: async (modelId, records) => {
|
|
1741
1949
|
try {
|
|
@@ -1745,9 +1953,9 @@ function createDatoClient(params) {
|
|
|
1745
1953
|
filter: {
|
|
1746
1954
|
type: modelId,
|
|
1747
1955
|
only_valid: "true",
|
|
1748
|
-
ids: !_optionalChain([records, 'optionalAccess',
|
|
1956
|
+
ids: !_optionalChain([records, 'optionalAccess', _90 => _90.length]) ? void 0 : records.join(",")
|
|
1749
1957
|
}
|
|
1750
|
-
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
1958
|
+
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _91 => _91.response, 'optionalAccess', _92 => _92.body, 'optionalAccess', _93 => _93.data, 'optionalAccess', _94 => _94[0]]) || error));
|
|
1751
1959
|
return result;
|
|
1752
1960
|
} catch (_error) {
|
|
1753
1961
|
throw new Error(
|
|
@@ -1761,9 +1969,9 @@ function createDatoClient(params) {
|
|
|
1761
1969
|
},
|
|
1762
1970
|
updateRecord: async (id, payload) => {
|
|
1763
1971
|
try {
|
|
1764
|
-
await dato.items.update(id, payload).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
1972
|
+
await dato.items.update(id, payload).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _95 => _95.response, 'optionalAccess', _96 => _96.body, 'optionalAccess', _97 => _97.data, 'optionalAccess', _98 => _98[0]]) || error));
|
|
1765
1973
|
} catch (_error) {
|
|
1766
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
1974
|
+
if (_optionalChain([_error, 'optionalAccess', _99 => _99.attributes, 'optionalAccess', _100 => _100.details, 'optionalAccess', _101 => _101.message])) {
|
|
1767
1975
|
throw new Error(
|
|
1768
1976
|
[
|
|
1769
1977
|
`${_error.attributes.details.message}`,
|
|
@@ -1784,9 +1992,9 @@ function createDatoClient(params) {
|
|
|
1784
1992
|
},
|
|
1785
1993
|
enableFieldLocalization: async (args) => {
|
|
1786
1994
|
try {
|
|
1787
|
-
await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
1995
|
+
await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _102 => _102.response, 'optionalAccess', _103 => _103.body, 'optionalAccess', _104 => _104.data, 'optionalAccess', _105 => _105[0]]) || error));
|
|
1788
1996
|
} catch (_error) {
|
|
1789
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
1997
|
+
if (_optionalChain([_error, 'optionalAccess', _106 => _106.attributes, 'optionalAccess', _107 => _107.code]) === "NOT_FOUND") {
|
|
1790
1998
|
throw new Error(
|
|
1791
1999
|
[
|
|
1792
2000
|
`Field "${args.fieldId}" not found in model "${args.modelId}".`,
|
|
@@ -1794,7 +2002,7 @@ function createDatoClient(params) {
|
|
|
1794
2002
|
].join("\n\n")
|
|
1795
2003
|
);
|
|
1796
2004
|
}
|
|
1797
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
2005
|
+
if (_optionalChain([_error, 'optionalAccess', _108 => _108.attributes, 'optionalAccess', _109 => _109.details, 'optionalAccess', _110 => _110.message])) {
|
|
1798
2006
|
throw new Error(
|
|
1799
2007
|
[`${_error.attributes.details.message}`, `Error: ${JSON.stringify(_error, null, 2)}`].join("\n\n")
|
|
1800
2008
|
);
|
|
@@ -1860,7 +2068,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
1860
2068
|
}
|
|
1861
2069
|
}
|
|
1862
2070
|
const records = await dato.findRecordsForModel(modelId);
|
|
1863
|
-
const recordChoices = createRecordChoices(records, _optionalChain([config, 'access',
|
|
2071
|
+
const recordChoices = createRecordChoices(records, _optionalChain([config, 'access', _111 => _111.models, 'access', _112 => _112[modelId], 'optionalAccess', _113 => _113.records]) || [], project);
|
|
1864
2072
|
const selectedRecords = await promptRecordSelection(modelName, recordChoices);
|
|
1865
2073
|
result.models[modelId].records = records.filter((record) => selectedRecords.includes(record.id));
|
|
1866
2074
|
updatedConfig.models[modelId].records = selectedRecords;
|
|
@@ -1870,16 +2078,16 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
1870
2078
|
onConfigUpdate(updatedConfig);
|
|
1871
2079
|
return result;
|
|
1872
2080
|
},
|
|
1873
|
-
async pull(locale,
|
|
2081
|
+
async pull(locale, input2, initCtx) {
|
|
1874
2082
|
const result = {};
|
|
1875
|
-
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess',
|
|
1876
|
-
let records = _optionalChain([initCtx, 'optionalAccess',
|
|
2083
|
+
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess', _114 => _114.models]) || {})) {
|
|
2084
|
+
let records = _optionalChain([initCtx, 'optionalAccess', _115 => _115.models, 'access', _116 => _116[modelId], 'access', _117 => _117.records]) || [];
|
|
1877
2085
|
const recordIds = records.map((record) => record.id);
|
|
1878
2086
|
records = await dato.findRecords(recordIds);
|
|
1879
2087
|
console.log(`Fetched ${records.length} records for model ${modelId}`);
|
|
1880
2088
|
if (records.length > 0) {
|
|
1881
2089
|
result[modelId] = {
|
|
1882
|
-
fields: _optionalChain([initCtx, 'optionalAccess',
|
|
2090
|
+
fields: _optionalChain([initCtx, 'optionalAccess', _118 => _118.models, 'optionalAccess', _119 => _119[modelId], 'optionalAccess', _120 => _120.fields]) || [],
|
|
1883
2091
|
records
|
|
1884
2092
|
};
|
|
1885
2093
|
}
|
|
@@ -1938,7 +2146,7 @@ function createRecordChoices(records, selectedIds = [], project) {
|
|
|
1938
2146
|
return records.map((record) => ({
|
|
1939
2147
|
name: `${record.id} - https://${project.internal_domain}/editor/item_types/${record.item_type.id}/items/${record.id}`,
|
|
1940
2148
|
value: record.id,
|
|
1941
|
-
checked: _optionalChain([selectedIds, 'optionalAccess',
|
|
2149
|
+
checked: _optionalChain([selectedIds, 'optionalAccess', _121 => _121.includes, 'call', _122 => _122(record.id)])
|
|
1942
2150
|
}));
|
|
1943
2151
|
}
|
|
1944
2152
|
async function promptRecordSelection(modelName, choices) {
|
|
@@ -1982,9 +2190,9 @@ async function promptModelSelection(choices) {
|
|
|
1982
2190
|
|
|
1983
2191
|
function createDatoExtractLoader() {
|
|
1984
2192
|
return createLoader({
|
|
1985
|
-
async pull(locale,
|
|
2193
|
+
async pull(locale, input2) {
|
|
1986
2194
|
const result = {};
|
|
1987
|
-
for (const [modelId, modelInfo] of _lodash2.default.entries(
|
|
2195
|
+
for (const [modelId, modelInfo] of _lodash2.default.entries(input2)) {
|
|
1988
2196
|
for (const [recordId, record] of _lodash2.default.entries(modelInfo)) {
|
|
1989
2197
|
for (const [fieldName, fieldValue] of _lodash2.default.entries(record)) {
|
|
1990
2198
|
const parsedValue = createParsedDatoValue(fieldValue);
|
|
@@ -2089,18 +2297,18 @@ function createRawDatoValue(parsedDatoValue, originalRawDatoValue, isClean = fal
|
|
|
2089
2297
|
}
|
|
2090
2298
|
function serializeStructuredText(rawStructuredText) {
|
|
2091
2299
|
return serializeStructuredTextNode(rawStructuredText);
|
|
2092
|
-
function serializeStructuredTextNode(node,
|
|
2300
|
+
function serializeStructuredTextNode(node, path11 = [], acc = {}) {
|
|
2093
2301
|
if ("document" in node) {
|
|
2094
|
-
return serializeStructuredTextNode(node.document, [...
|
|
2302
|
+
return serializeStructuredTextNode(node.document, [...path11, "document"], acc);
|
|
2095
2303
|
}
|
|
2096
2304
|
if (!_lodash2.default.isNil(node.value)) {
|
|
2097
|
-
acc[[...
|
|
2305
|
+
acc[[...path11, "value"].join(".")] = node.value;
|
|
2098
2306
|
} else if (_lodash2.default.get(node, "type") === "block") {
|
|
2099
|
-
acc[[...
|
|
2307
|
+
acc[[...path11, "item"].join(".")] = serializeBlock(node.item);
|
|
2100
2308
|
}
|
|
2101
2309
|
if (node.children) {
|
|
2102
2310
|
for (let i = 0; i < node.children.length; i++) {
|
|
2103
|
-
serializeStructuredTextNode(node.children[i], [...
|
|
2311
|
+
serializeStructuredTextNode(node.children[i], [...path11, i.toString()], acc);
|
|
2104
2312
|
}
|
|
2105
2313
|
}
|
|
2106
2314
|
return acc;
|
|
@@ -2159,8 +2367,8 @@ function deserializeBlockList(parsedBlockList, originalRawBlockList, isClean = f
|
|
|
2159
2367
|
}
|
|
2160
2368
|
function deserializeStructuredText(parsedStructuredText, originalRawStructuredText) {
|
|
2161
2369
|
const result = _lodash2.default.cloneDeep(originalRawStructuredText);
|
|
2162
|
-
for (const [
|
|
2163
|
-
const realPath = _lodash2.default.chain(
|
|
2370
|
+
for (const [path11, value] of _lodash2.default.entries(parsedStructuredText)) {
|
|
2371
|
+
const realPath = _lodash2.default.chain(path11.split(".")).flatMap((s) => !_lodash2.default.isNaN(_lodash2.default.toNumber(s)) ? ["children", s] : s).value();
|
|
2164
2372
|
const deserializedValue = createRawDatoValue(value, _lodash2.default.get(originalRawStructuredText, realPath), true);
|
|
2165
2373
|
_lodash2.default.set(result, realPath, deserializedValue);
|
|
2166
2374
|
}
|
|
@@ -2204,8 +2412,8 @@ function createDatoLoader(configFilePath) {
|
|
|
2204
2412
|
var _nodewebvtt = require('node-webvtt'); var _nodewebvtt2 = _interopRequireDefault(_nodewebvtt);
|
|
2205
2413
|
function createVttLoader() {
|
|
2206
2414
|
return createLoader({
|
|
2207
|
-
async pull(locale,
|
|
2208
|
-
const vtt = _optionalChain([_nodewebvtt2.default, 'access',
|
|
2415
|
+
async pull(locale, input2) {
|
|
2416
|
+
const vtt = _optionalChain([_nodewebvtt2.default, 'access', _123 => _123.parse, 'call', _124 => _124(input2), 'optionalAccess', _125 => _125.cues]);
|
|
2209
2417
|
if (Object.keys(vtt).length === 0) {
|
|
2210
2418
|
return {};
|
|
2211
2419
|
} else {
|
|
@@ -2228,12 +2436,12 @@ function createVttLoader() {
|
|
|
2228
2436
|
text
|
|
2229
2437
|
};
|
|
2230
2438
|
});
|
|
2231
|
-
const
|
|
2439
|
+
const input2 = {
|
|
2232
2440
|
valid: true,
|
|
2233
2441
|
strict: true,
|
|
2234
2442
|
cues: output
|
|
2235
2443
|
};
|
|
2236
|
-
return _nodewebvtt2.default.compile(
|
|
2444
|
+
return _nodewebvtt2.default.compile(input2);
|
|
2237
2445
|
}
|
|
2238
2446
|
});
|
|
2239
2447
|
}
|
|
@@ -2246,9 +2454,9 @@ function createVariableLoader(params) {
|
|
|
2246
2454
|
function variableExtractLoader(params) {
|
|
2247
2455
|
const specifierPattern = getFormatSpecifierPattern(params.type);
|
|
2248
2456
|
return createLoader({
|
|
2249
|
-
pull: async (locale,
|
|
2457
|
+
pull: async (locale, input2) => {
|
|
2250
2458
|
const result = {};
|
|
2251
|
-
for (const [key, value] of Object.entries(
|
|
2459
|
+
for (const [key, value] of Object.entries(input2)) {
|
|
2252
2460
|
const matches = value.match(specifierPattern) || [];
|
|
2253
2461
|
result[key] = result[key] || {
|
|
2254
2462
|
value,
|
|
@@ -2257,7 +2465,7 @@ function variableExtractLoader(params) {
|
|
|
2257
2465
|
for (let i = 0; i < matches.length; i++) {
|
|
2258
2466
|
const match = matches[i];
|
|
2259
2467
|
const currentValue = result[key].value;
|
|
2260
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
2468
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _126 => _126.replace, 'call', _127 => _127(match, `{variable:${i}}`)]);
|
|
2261
2469
|
result[key].value = newValue;
|
|
2262
2470
|
result[key].variables[i] = match;
|
|
2263
2471
|
}
|
|
@@ -2271,7 +2479,7 @@ function variableExtractLoader(params) {
|
|
|
2271
2479
|
for (let i = 0; i < valueObj.variables.length; i++) {
|
|
2272
2480
|
const variable = valueObj.variables[i];
|
|
2273
2481
|
const currentValue = result[key];
|
|
2274
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
2482
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _128 => _128.replace, 'call', _129 => _129(`{variable:${i}}`, variable)]);
|
|
2275
2483
|
result[key] = newValue;
|
|
2276
2484
|
}
|
|
2277
2485
|
}
|
|
@@ -2281,8 +2489,8 @@ function variableExtractLoader(params) {
|
|
|
2281
2489
|
}
|
|
2282
2490
|
function variableContentLoader() {
|
|
2283
2491
|
return createLoader({
|
|
2284
|
-
pull: async (locale,
|
|
2285
|
-
const result = _lodash2.default.mapValues(
|
|
2492
|
+
pull: async (locale, input2) => {
|
|
2493
|
+
const result = _lodash2.default.mapValues(input2, (payload) => payload.value);
|
|
2286
2494
|
return result;
|
|
2287
2495
|
},
|
|
2288
2496
|
push: async (locale, data, originalInput) => {
|
|
@@ -2312,11 +2520,11 @@ function getFormatSpecifierPattern(type) {
|
|
|
2312
2520
|
|
|
2313
2521
|
function createSyncLoader() {
|
|
2314
2522
|
return createLoader({
|
|
2315
|
-
async pull(locale,
|
|
2523
|
+
async pull(locale, input2, originalInput) {
|
|
2316
2524
|
if (!originalInput) {
|
|
2317
|
-
return
|
|
2525
|
+
return input2;
|
|
2318
2526
|
}
|
|
2319
|
-
return _lodash2.default.chain(originalInput).mapValues((value, key) =>
|
|
2527
|
+
return _lodash2.default.chain(originalInput).mapValues((value, key) => input2[key]).value();
|
|
2320
2528
|
},
|
|
2321
2529
|
async push(locale, data, originalInput) {
|
|
2322
2530
|
if (!originalInput) {
|
|
@@ -2387,7 +2595,7 @@ function createPlutilJsonTextLoader() {
|
|
|
2387
2595
|
}
|
|
2388
2596
|
|
|
2389
2597
|
// src/cli/loaders/index.ts
|
|
2390
|
-
function createBucketLoader(bucketType, bucketPathPattern) {
|
|
2598
|
+
function createBucketLoader(bucketType, bucketPathPattern, { isCacheRestore = false } = {}) {
|
|
2391
2599
|
switch (bucketType) {
|
|
2392
2600
|
default:
|
|
2393
2601
|
throw new Error(`Unsupported bucket type: ${bucketType}`);
|
|
@@ -2397,7 +2605,7 @@ function createBucketLoader(bucketType, bucketPathPattern) {
|
|
|
2397
2605
|
createAndroidLoader(),
|
|
2398
2606
|
createFlatLoader(),
|
|
2399
2607
|
createSyncLoader(),
|
|
2400
|
-
createUnlocalizableLoader()
|
|
2608
|
+
createUnlocalizableLoader(isCacheRestore)
|
|
2401
2609
|
);
|
|
2402
2610
|
case "csv":
|
|
2403
2611
|
return composeLoaders(
|
|
@@ -2405,7 +2613,7 @@ function createBucketLoader(bucketType, bucketPathPattern) {
|
|
|
2405
2613
|
createCsvLoader(),
|
|
2406
2614
|
createFlatLoader(),
|
|
2407
2615
|
createSyncLoader(),
|
|
2408
|
-
createUnlocalizableLoader()
|
|
2616
|
+
createUnlocalizableLoader(isCacheRestore)
|
|
2409
2617
|
);
|
|
2410
2618
|
case "html":
|
|
2411
2619
|
return composeLoaders(
|
|
@@ -2413,7 +2621,7 @@ function createBucketLoader(bucketType, bucketPathPattern) {
|
|
|
2413
2621
|
createPrettierLoader({ parser: "html", alwaysFormat: true }),
|
|
2414
2622
|
createHtmlLoader(),
|
|
2415
2623
|
createSyncLoader(),
|
|
2416
|
-
createUnlocalizableLoader()
|
|
2624
|
+
createUnlocalizableLoader(isCacheRestore)
|
|
2417
2625
|
);
|
|
2418
2626
|
case "json":
|
|
2419
2627
|
return composeLoaders(
|
|
@@ -2422,7 +2630,7 @@ function createBucketLoader(bucketType, bucketPathPattern) {
|
|
|
2422
2630
|
createJsonLoader(),
|
|
2423
2631
|
createFlatLoader(),
|
|
2424
2632
|
createSyncLoader(),
|
|
2425
|
-
createUnlocalizableLoader()
|
|
2633
|
+
createUnlocalizableLoader(isCacheRestore)
|
|
2426
2634
|
);
|
|
2427
2635
|
case "markdown":
|
|
2428
2636
|
return composeLoaders(
|
|
@@ -2430,7 +2638,7 @@ function createBucketLoader(bucketType, bucketPathPattern) {
|
|
|
2430
2638
|
createPrettierLoader({ parser: "markdown" }),
|
|
2431
2639
|
createMarkdownLoader(),
|
|
2432
2640
|
createSyncLoader(),
|
|
2433
|
-
createUnlocalizableLoader()
|
|
2641
|
+
createUnlocalizableLoader(isCacheRestore)
|
|
2434
2642
|
);
|
|
2435
2643
|
case "po":
|
|
2436
2644
|
return composeLoaders(
|
|
@@ -2438,7 +2646,7 @@ function createBucketLoader(bucketType, bucketPathPattern) {
|
|
|
2438
2646
|
createPoLoader(),
|
|
2439
2647
|
createFlatLoader(),
|
|
2440
2648
|
createSyncLoader(),
|
|
2441
|
-
createUnlocalizableLoader(),
|
|
2649
|
+
createUnlocalizableLoader(isCacheRestore),
|
|
2442
2650
|
createVariableLoader({ type: "python" })
|
|
2443
2651
|
);
|
|
2444
2652
|
case "properties":
|
|
@@ -2446,14 +2654,14 @@ function createBucketLoader(bucketType, bucketPathPattern) {
|
|
|
2446
2654
|
createTextFileLoader(bucketPathPattern),
|
|
2447
2655
|
createPropertiesLoader(),
|
|
2448
2656
|
createSyncLoader(),
|
|
2449
|
-
createUnlocalizableLoader()
|
|
2657
|
+
createUnlocalizableLoader(isCacheRestore)
|
|
2450
2658
|
);
|
|
2451
2659
|
case "xcode-strings":
|
|
2452
2660
|
return composeLoaders(
|
|
2453
2661
|
createTextFileLoader(bucketPathPattern),
|
|
2454
2662
|
createXcodeStringsLoader(),
|
|
2455
2663
|
createSyncLoader(),
|
|
2456
|
-
createUnlocalizableLoader()
|
|
2664
|
+
createUnlocalizableLoader(isCacheRestore)
|
|
2457
2665
|
);
|
|
2458
2666
|
case "xcode-stringsdict":
|
|
2459
2667
|
return composeLoaders(
|
|
@@ -2461,7 +2669,7 @@ function createBucketLoader(bucketType, bucketPathPattern) {
|
|
|
2461
2669
|
createXcodeStringsdictLoader(),
|
|
2462
2670
|
createFlatLoader(),
|
|
2463
2671
|
createSyncLoader(),
|
|
2464
|
-
createUnlocalizableLoader()
|
|
2672
|
+
createUnlocalizableLoader(isCacheRestore)
|
|
2465
2673
|
);
|
|
2466
2674
|
case "xcode-xcstrings":
|
|
2467
2675
|
return composeLoaders(
|
|
@@ -2471,7 +2679,7 @@ function createBucketLoader(bucketType, bucketPathPattern) {
|
|
|
2471
2679
|
createXcodeXcstringsLoader(),
|
|
2472
2680
|
createFlatLoader(),
|
|
2473
2681
|
createSyncLoader(),
|
|
2474
|
-
createUnlocalizableLoader(),
|
|
2682
|
+
createUnlocalizableLoader(isCacheRestore),
|
|
2475
2683
|
createVariableLoader({ type: "ieee" })
|
|
2476
2684
|
);
|
|
2477
2685
|
case "yaml":
|
|
@@ -2481,7 +2689,7 @@ function createBucketLoader(bucketType, bucketPathPattern) {
|
|
|
2481
2689
|
createYamlLoader(),
|
|
2482
2690
|
createFlatLoader(),
|
|
2483
2691
|
createSyncLoader(),
|
|
2484
|
-
createUnlocalizableLoader()
|
|
2692
|
+
createUnlocalizableLoader(isCacheRestore)
|
|
2485
2693
|
);
|
|
2486
2694
|
case "yaml-root-key":
|
|
2487
2695
|
return composeLoaders(
|
|
@@ -2491,7 +2699,7 @@ function createBucketLoader(bucketType, bucketPathPattern) {
|
|
|
2491
2699
|
createRootKeyLoader(true),
|
|
2492
2700
|
createFlatLoader(),
|
|
2493
2701
|
createSyncLoader(),
|
|
2494
|
-
createUnlocalizableLoader()
|
|
2702
|
+
createUnlocalizableLoader(isCacheRestore)
|
|
2495
2703
|
);
|
|
2496
2704
|
case "flutter":
|
|
2497
2705
|
return composeLoaders(
|
|
@@ -2501,7 +2709,7 @@ function createBucketLoader(bucketType, bucketPathPattern) {
|
|
|
2501
2709
|
createFlutterLoader(),
|
|
2502
2710
|
createFlatLoader(),
|
|
2503
2711
|
createSyncLoader(),
|
|
2504
|
-
createUnlocalizableLoader()
|
|
2712
|
+
createUnlocalizableLoader(isCacheRestore)
|
|
2505
2713
|
);
|
|
2506
2714
|
case "xliff":
|
|
2507
2715
|
return composeLoaders(
|
|
@@ -2509,7 +2717,7 @@ function createBucketLoader(bucketType, bucketPathPattern) {
|
|
|
2509
2717
|
createXliffLoader(),
|
|
2510
2718
|
createFlatLoader(),
|
|
2511
2719
|
createSyncLoader(),
|
|
2512
|
-
createUnlocalizableLoader()
|
|
2720
|
+
createUnlocalizableLoader(isCacheRestore)
|
|
2513
2721
|
);
|
|
2514
2722
|
case "xml":
|
|
2515
2723
|
return composeLoaders(
|
|
@@ -2517,28 +2725,28 @@ function createBucketLoader(bucketType, bucketPathPattern) {
|
|
|
2517
2725
|
createXmlLoader(),
|
|
2518
2726
|
createFlatLoader(),
|
|
2519
2727
|
createSyncLoader(),
|
|
2520
|
-
createUnlocalizableLoader()
|
|
2728
|
+
createUnlocalizableLoader(isCacheRestore)
|
|
2521
2729
|
);
|
|
2522
2730
|
case "srt":
|
|
2523
2731
|
return composeLoaders(
|
|
2524
2732
|
createTextFileLoader(bucketPathPattern),
|
|
2525
2733
|
createSrtLoader(),
|
|
2526
2734
|
createSyncLoader(),
|
|
2527
|
-
createUnlocalizableLoader()
|
|
2735
|
+
createUnlocalizableLoader(isCacheRestore)
|
|
2528
2736
|
);
|
|
2529
2737
|
case "dato":
|
|
2530
2738
|
return composeLoaders(
|
|
2531
2739
|
createDatoLoader(bucketPathPattern),
|
|
2532
2740
|
createSyncLoader(),
|
|
2533
2741
|
createFlatLoader(),
|
|
2534
|
-
createUnlocalizableLoader()
|
|
2742
|
+
createUnlocalizableLoader(isCacheRestore)
|
|
2535
2743
|
);
|
|
2536
2744
|
case "vtt":
|
|
2537
2745
|
return composeLoaders(
|
|
2538
2746
|
createTextFileLoader(bucketPathPattern),
|
|
2539
2747
|
createVttLoader(),
|
|
2540
2748
|
createSyncLoader(),
|
|
2541
|
-
createUnlocalizableLoader()
|
|
2749
|
+
createUnlocalizableLoader(isCacheRestore)
|
|
2542
2750
|
);
|
|
2543
2751
|
}
|
|
2544
2752
|
}
|
|
@@ -2711,11 +2919,11 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
2711
2919
|
const auth = await validateAuth(settings);
|
|
2712
2920
|
ora.succeed(`Authenticated as ${auth.email}`);
|
|
2713
2921
|
let buckets = getBuckets(i18nConfig);
|
|
2714
|
-
if (_optionalChain([flags, 'access',
|
|
2922
|
+
if (_optionalChain([flags, 'access', _130 => _130.bucket, 'optionalAccess', _131 => _131.length])) {
|
|
2715
2923
|
buckets = buckets.filter((bucket) => flags.bucket.includes(bucket.type));
|
|
2716
2924
|
}
|
|
2717
2925
|
ora.succeed("Buckets retrieved");
|
|
2718
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
2926
|
+
const targetLocales = _optionalChain([flags, 'access', _132 => _132.locale, 'optionalAccess', _133 => _133.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
2719
2927
|
const lockfileHelper = createLockfileHelper();
|
|
2720
2928
|
ora.start("Ensuring i18n.lock exists...");
|
|
2721
2929
|
if (!lockfileHelper.isLockfileExists()) {
|
|
@@ -2745,7 +2953,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
2745
2953
|
const bucketOra = _ora2.default.call(void 0, { indent: 4 });
|
|
2746
2954
|
bucketOra.info(`Processing path: ${bucketConfig.pathPattern}`);
|
|
2747
2955
|
const sourceLocale = __spec.resolveOverridenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
|
|
2748
|
-
const bucketLoader = createBucketLoader(bucket.type, bucketConfig.pathPattern);
|
|
2956
|
+
const bucketLoader = createBucketLoader(bucket.type, bucketConfig.pathPattern, { isCacheRestore: true });
|
|
2749
2957
|
bucketLoader.setDefaultLocale(sourceLocale);
|
|
2750
2958
|
await bucketLoader.init();
|
|
2751
2959
|
const sourceData = await bucketLoader.pull(sourceLocale);
|
|
@@ -2823,7 +3031,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
2823
3031
|
targetData
|
|
2824
3032
|
});
|
|
2825
3033
|
if (flags.key) {
|
|
2826
|
-
processableData = _lodash2.default.pickBy(processableData, (
|
|
3034
|
+
processableData = _lodash2.default.pickBy(processableData, (_21, key) => key === flags.key);
|
|
2827
3035
|
}
|
|
2828
3036
|
if (flags.verbose) {
|
|
2829
3037
|
bucketOra.info(JSON.stringify(processableData, null, 2));
|
|
@@ -3001,12 +3209,12 @@ function validateParams(i18nConfig, flags) {
|
|
|
3001
3209
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
3002
3210
|
docUrl: "bucketNotFound"
|
|
3003
3211
|
});
|
|
3004
|
-
} else if (_optionalChain([flags, 'access',
|
|
3212
|
+
} else if (_optionalChain([flags, 'access', _134 => _134.locale, 'optionalAccess', _135 => _135.some, 'call', _136 => _136((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
3005
3213
|
throw new CLIError({
|
|
3006
3214
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
3007
3215
|
docUrl: "localeTargetNotFound"
|
|
3008
3216
|
});
|
|
3009
|
-
} else if (_optionalChain([flags, 'access',
|
|
3217
|
+
} else if (_optionalChain([flags, 'access', _137 => _137.bucket, 'optionalAccess', _138 => _138.some, 'call', _139 => _139((bucket) => !i18nConfig.buckets[bucket])])) {
|
|
3010
3218
|
throw new CLIError({
|
|
3011
3219
|
message: `One or more specified buckets do not exist in i18n.json. Please add them to the list and try again.`,
|
|
3012
3220
|
docUrl: "bucketNotFound"
|
|
@@ -3233,7 +3441,7 @@ function displaySummary(results) {
|
|
|
3233
3441
|
// package.json
|
|
3234
3442
|
var package_default = {
|
|
3235
3443
|
name: "lingo.dev",
|
|
3236
|
-
version: "0.74.
|
|
3444
|
+
version: "0.74.17",
|
|
3237
3445
|
description: "Lingo.dev CLI",
|
|
3238
3446
|
private: false,
|
|
3239
3447
|
publishConfig: {
|