lingo.dev 0.78.1 → 0.78.2
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 +79 -31
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +79 -31
- package/build/cli.mjs.map +1 -1
- package/package.json +3 -3
package/build/cli.mjs
CHANGED
|
@@ -297,7 +297,7 @@ function findLocaleFiles(bucket) {
|
|
|
297
297
|
case "xcode-stringsdict":
|
|
298
298
|
return findLocaleFilesForFilename("Localizable.stringsdict");
|
|
299
299
|
default:
|
|
300
|
-
|
|
300
|
+
return null;
|
|
301
301
|
}
|
|
302
302
|
}
|
|
303
303
|
function findLocaleFilesWithExtension(ext) {
|
|
@@ -681,38 +681,50 @@ var init_default = new InteractiveCommand().command("init").description("Initial
|
|
|
681
681
|
};
|
|
682
682
|
} else {
|
|
683
683
|
let selectedPatterns = [];
|
|
684
|
-
const
|
|
685
|
-
if (
|
|
686
|
-
spinner.
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
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
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
695
|
+
const { patterns, defaultPatterns } = localeFiles;
|
|
696
|
+
if (patterns.length > 0) {
|
|
697
|
+
spinner.succeed("Found existing locale files:");
|
|
698
|
+
selectedPatterns = await checkbox2({
|
|
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
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
[options.bucket]: {
|
|
713
|
-
include: selectedPatterns || []
|
|
707
|
+
if (selectedPatterns.length === 0) {
|
|
708
|
+
const useDefault = await confirm2({
|
|
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 input({
|
|
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,34 @@ 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
|
+
import { jsonrepair as jsonrepair2 } from "jsonrepair";
|
|
2874
|
+
function createVueJsonLoader() {
|
|
2875
|
+
return createLoader({
|
|
2876
|
+
pull: async (locale, input2, ctx) => {
|
|
2877
|
+
const { i18n } = parseVueFile(input2);
|
|
2878
|
+
return i18n[locale] ?? {};
|
|
2879
|
+
},
|
|
2880
|
+
push: async (locale, data, originalInput) => {
|
|
2881
|
+
const { before, i18n, after } = parseVueFile(originalInput ?? "");
|
|
2882
|
+
i18n[locale] = data;
|
|
2883
|
+
return `${before}<i18n>
|
|
2884
|
+
${JSON.stringify(i18n, null, 2)}
|
|
2885
|
+
</i18n>${after}`;
|
|
2886
|
+
}
|
|
2887
|
+
});
|
|
2888
|
+
}
|
|
2889
|
+
function parseVueFile(input2) {
|
|
2890
|
+
const [, before, jsonString = "{}", after] = input2.match(/^([\s\S]*)<i18n>([\s\S]*)<\/i18n>([\s\S]*)$/) || [];
|
|
2891
|
+
let i18n;
|
|
2892
|
+
try {
|
|
2893
|
+
i18n = JSON.parse(jsonString);
|
|
2894
|
+
} catch (error) {
|
|
2895
|
+
i18n = JSON.parse(jsonrepair2(jsonString));
|
|
2896
|
+
}
|
|
2897
|
+
return { before, after, i18n };
|
|
2898
|
+
}
|
|
2899
|
+
|
|
2860
2900
|
// src/cli/loaders/index.ts
|
|
2861
2901
|
function createBucketLoader(bucketType, bucketPathPattern, options) {
|
|
2862
2902
|
switch (bucketType) {
|
|
@@ -3019,6 +3059,14 @@ function createBucketLoader(bucketType, bucketPathPattern, options) {
|
|
|
3019
3059
|
createFlatLoader(),
|
|
3020
3060
|
createUnlocalizableLoader(options.isCacheRestore)
|
|
3021
3061
|
);
|
|
3062
|
+
case "vue-json":
|
|
3063
|
+
return composeLoaders(
|
|
3064
|
+
createTextFileLoader(bucketPathPattern),
|
|
3065
|
+
createVueJsonLoader(),
|
|
3066
|
+
createSyncLoader(),
|
|
3067
|
+
createFlatLoader(),
|
|
3068
|
+
createUnlocalizableLoader()
|
|
3069
|
+
);
|
|
3022
3070
|
}
|
|
3023
3071
|
}
|
|
3024
3072
|
|
|
@@ -3782,7 +3830,7 @@ var mcp_default = new Command9().command("mcp").description("Use Lingo.dev model
|
|
|
3782
3830
|
// package.json
|
|
3783
3831
|
var package_default = {
|
|
3784
3832
|
name: "lingo.dev",
|
|
3785
|
-
version: "0.78.
|
|
3833
|
+
version: "0.78.2",
|
|
3786
3834
|
description: "Lingo.dev CLI",
|
|
3787
3835
|
private: false,
|
|
3788
3836
|
publishConfig: {
|