lingo.dev 0.78.1 → 0.78.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 CHANGED
@@ -297,7 +297,7 @@ function findLocaleFiles(bucket) {
297
297
  case "xcode-stringsdict":
298
298
  return findLocaleFilesForFilename("Localizable.stringsdict");
299
299
  default:
300
- throw new Error(`Unsupported bucket type: ${bucket}`);
300
+ return null;
301
301
  }
302
302
  }
303
303
  function findLocaleFilesWithExtension(ext) {
@@ -681,38 +681,50 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
681
681
  };
682
682
  } else {
683
683
  let selectedPatterns = [];
684
- const { patterns, defaultPatterns } = findLocaleFiles(options.bucket);
685
- if (patterns.length > 0) {
686
- spinner.succeed("Found existing locale files:");
687
- selectedPatterns = await _prompts.checkbox.call(void 0, {
688
- message: "Select the paths to use",
689
- choices: patterns.map((value) => ({
690
- value
691
- }))
692
- });
684
+ const localeFiles = findLocaleFiles(options.bucket);
685
+ if (!localeFiles) {
686
+ spinner.warn(
687
+ `Bucket type "${options.bucket}" does not supported automatic initialization. Add paths to "i18n.json" manually.`
688
+ );
689
+ newConfig.buckets = {
690
+ [options.bucket]: {
691
+ include: options.paths || []
692
+ }
693
+ };
693
694
  } else {
694
- spinner.succeed("No existing locale files found.");
695
- }
696
- if (selectedPatterns.length === 0) {
697
- const useDefault = await _prompts.confirm.call(void 0, {
698
- message: `Use (and create) default path ${defaultPatterns.join(", ")}?`
699
- });
700
- if (useDefault) {
701
- ensurePatterns(defaultPatterns, options.source);
702
- selectedPatterns = defaultPatterns;
695
+ const { patterns, defaultPatterns } = localeFiles;
696
+ if (patterns.length > 0) {
697
+ spinner.succeed("Found existing locale files:");
698
+ selectedPatterns = await _prompts.checkbox.call(void 0, {
699
+ message: "Select the paths to use",
700
+ choices: patterns.map((value) => ({
701
+ value
702
+ }))
703
+ });
704
+ } else {
705
+ spinner.succeed("No existing locale files found.");
703
706
  }
704
- }
705
- if (selectedPatterns.length === 0) {
706
- const customPaths = await _prompts.input.call(void 0, {
707
- message: "Enter paths to use"
708
- });
709
- selectedPatterns = customPaths.includes(",") ? customPaths.split(",") : customPaths.split(" ");
710
- }
711
- newConfig.buckets = {
712
- [options.bucket]: {
713
- include: selectedPatterns || []
707
+ if (selectedPatterns.length === 0) {
708
+ const useDefault = await _prompts.confirm.call(void 0, {
709
+ message: `Use (and create) default path ${defaultPatterns.join(", ")}?`
710
+ });
711
+ if (useDefault) {
712
+ ensurePatterns(defaultPatterns, options.source);
713
+ selectedPatterns = defaultPatterns;
714
+ }
714
715
  }
715
- };
716
+ if (selectedPatterns.length === 0) {
717
+ const customPaths = await _prompts.input.call(void 0, {
718
+ message: "Enter paths to use"
719
+ });
720
+ selectedPatterns = customPaths.includes(",") ? customPaths.split(",") : customPaths.split(" ");
721
+ }
722
+ newConfig.buckets = {
723
+ [options.bucket]: {
724
+ include: selectedPatterns || []
725
+ }
726
+ };
727
+ }
716
728
  }
717
729
  await saveConfig(newConfig);
718
730
  spinner.succeed("Lingo.dev project initialized");
@@ -2857,6 +2869,41 @@ function escapePhpString(str) {
2857
2869
  return str.replaceAll("\\", "\\\\").replaceAll("'", "\\'").replaceAll("\r", "\\r").replaceAll("\n", "\\n").replaceAll(" ", "\\t");
2858
2870
  }
2859
2871
 
2872
+ // src/cli/loaders/vue-json.ts
2873
+
2874
+ function createVueJsonLoader() {
2875
+ return createLoader({
2876
+ pull: async (locale, input2, ctx) => {
2877
+ const parsed = parseVueFile(input2);
2878
+ return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _128 => _128.i18n, 'optionalAccess', _129 => _129[locale]]), () => ( {}));
2879
+ },
2880
+ push: async (locale, data, originalInput) => {
2881
+ const parsed = parseVueFile(_nullishCoalesce(originalInput, () => ( "")));
2882
+ if (!parsed) {
2883
+ return _nullishCoalesce(originalInput, () => ( ""));
2884
+ }
2885
+ parsed.i18n[locale] = data;
2886
+ return `${parsed.before}<i18n>
2887
+ ${JSON.stringify(parsed.i18n, null, 2)}
2888
+ </i18n>${parsed.after}`;
2889
+ }
2890
+ });
2891
+ }
2892
+ function parseVueFile(input2) {
2893
+ const match = input2.match(/^([\s\S]*)<i18n>([\s\S]*)<\/i18n>([\s\S]*)$/);
2894
+ if (!match) {
2895
+ return null;
2896
+ }
2897
+ const [, before, jsonString = "{}", after] = match;
2898
+ let i18n;
2899
+ try {
2900
+ i18n = JSON.parse(jsonString);
2901
+ } catch (error) {
2902
+ i18n = JSON.parse(_jsonrepair.jsonrepair.call(void 0, jsonString));
2903
+ }
2904
+ return { before, after, i18n };
2905
+ }
2906
+
2860
2907
  // src/cli/loaders/index.ts
2861
2908
  function createBucketLoader(bucketType, bucketPathPattern, options) {
2862
2909
  switch (bucketType) {
@@ -3019,6 +3066,14 @@ function createBucketLoader(bucketType, bucketPathPattern, options) {
3019
3066
  createFlatLoader(),
3020
3067
  createUnlocalizableLoader(options.isCacheRestore)
3021
3068
  );
3069
+ case "vue-json":
3070
+ return composeLoaders(
3071
+ createTextFileLoader(bucketPathPattern),
3072
+ createVueJsonLoader(),
3073
+ createSyncLoader(),
3074
+ createFlatLoader(),
3075
+ createUnlocalizableLoader()
3076
+ );
3022
3077
  }
3023
3078
  }
3024
3079
 
@@ -3191,11 +3246,11 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
3191
3246
  const auth = await validateAuth(settings);
3192
3247
  ora.succeed(`Authenticated as ${auth.email}`);
3193
3248
  let buckets = getBuckets(i18nConfig);
3194
- if (_optionalChain([flags, 'access', _128 => _128.bucket, 'optionalAccess', _129 => _129.length])) {
3249
+ if (_optionalChain([flags, 'access', _130 => _130.bucket, 'optionalAccess', _131 => _131.length])) {
3195
3250
  buckets = buckets.filter((bucket) => flags.bucket.includes(bucket.type));
3196
3251
  }
3197
3252
  ora.succeed("Buckets retrieved");
3198
- const targetLocales = _optionalChain([flags, 'access', _130 => _130.locale, 'optionalAccess', _131 => _131.length]) ? flags.locale : i18nConfig.locale.targets;
3253
+ const targetLocales = _optionalChain([flags, 'access', _132 => _132.locale, 'optionalAccess', _133 => _133.length]) ? flags.locale : i18nConfig.locale.targets;
3199
3254
  const lockfileHelper = createLockfileHelper();
3200
3255
  ora.start("Ensuring i18n.lock exists...");
3201
3256
  if (!lockfileHelper.isLockfileExists()) {
@@ -3497,12 +3552,12 @@ function validateParams(i18nConfig, flags) {
3497
3552
  message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
3498
3553
  docUrl: "bucketNotFound"
3499
3554
  });
3500
- } else if (_optionalChain([flags, 'access', _132 => _132.locale, 'optionalAccess', _133 => _133.some, 'call', _134 => _134((locale) => !i18nConfig.locale.targets.includes(locale))])) {
3555
+ } else if (_optionalChain([flags, 'access', _134 => _134.locale, 'optionalAccess', _135 => _135.some, 'call', _136 => _136((locale) => !i18nConfig.locale.targets.includes(locale))])) {
3501
3556
  throw new CLIError({
3502
3557
  message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
3503
3558
  docUrl: "localeTargetNotFound"
3504
3559
  });
3505
- } else if (_optionalChain([flags, 'access', _135 => _135.bucket, 'optionalAccess', _136 => _136.some, 'call', _137 => _137((bucket) => !i18nConfig.buckets[bucket])])) {
3560
+ } else if (_optionalChain([flags, 'access', _137 => _137.bucket, 'optionalAccess', _138 => _138.some, 'call', _139 => _139((bucket) => !i18nConfig.buckets[bucket])])) {
3506
3561
  throw new CLIError({
3507
3562
  message: `One or more specified buckets do not exist in i18n.json. Please add them to the list and try again.`,
3508
3563
  docUrl: "bucketNotFound"
@@ -3782,7 +3837,7 @@ var mcp_default = new (0, _interactivecommander.Command)().command("mcp").descri
3782
3837
  // package.json
3783
3838
  var package_default = {
3784
3839
  name: "lingo.dev",
3785
- version: "0.78.1",
3840
+ version: "0.78.3",
3786
3841
  description: "Lingo.dev CLI",
3787
3842
  private: false,
3788
3843
  publishConfig: {