lingo.dev 0.87.15 → 0.88.0
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 +63 -7
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +62 -6
- package/build/cli.mjs.map +1 -1
- package/package.json +3 -3
package/build/cli.mjs
CHANGED
|
@@ -865,6 +865,9 @@ function getBuckets(i18nConfig) {
|
|
|
865
865
|
if (bucketEntry.lockedKeys) {
|
|
866
866
|
config.lockedKeys = bucketEntry.lockedKeys;
|
|
867
867
|
}
|
|
868
|
+
if (bucketEntry.lockedPatterns) {
|
|
869
|
+
config.lockedPatterns = bucketEntry.lockedPatterns;
|
|
870
|
+
}
|
|
868
871
|
return config;
|
|
869
872
|
});
|
|
870
873
|
return result;
|
|
@@ -3139,7 +3142,7 @@ function md5(input2) {
|
|
|
3139
3142
|
import _20 from "lodash";
|
|
3140
3143
|
var fenceRegex = /([ \t]*)(^>\s*)?```([\s\S]*?)```/gm;
|
|
3141
3144
|
var inlineCodeRegex = /(?<!`)`([^`\r\n]+?)`(?!`)/g;
|
|
3142
|
-
var imageRegex = /([ \t]*)(^>\s*)?!\[[^\]]*?\]\([
|
|
3145
|
+
var imageRegex = /([ \t]*)(^>\s*)?!\[[^\]]*?\]\(([^()]*(\([^()]*\)[^()]*)*)\)/gm;
|
|
3143
3146
|
function ensureSurroundingImageNewlines(_content) {
|
|
3144
3147
|
let found = false;
|
|
3145
3148
|
let content = _content;
|
|
@@ -3278,8 +3281,57 @@ function createMdxSectionsSplit2Loader() {
|
|
|
3278
3281
|
});
|
|
3279
3282
|
}
|
|
3280
3283
|
|
|
3284
|
+
// src/cli/loaders/mdx2/locked-patterns.ts
|
|
3285
|
+
function extractLockedPatterns(content, patterns = []) {
|
|
3286
|
+
let finalContent = content;
|
|
3287
|
+
const lockedPlaceholders = {};
|
|
3288
|
+
if (!patterns || patterns.length === 0) {
|
|
3289
|
+
return { content: finalContent, lockedPlaceholders };
|
|
3290
|
+
}
|
|
3291
|
+
for (const patternStr of patterns) {
|
|
3292
|
+
try {
|
|
3293
|
+
const pattern = new RegExp(patternStr, "gm");
|
|
3294
|
+
const matches = Array.from(finalContent.matchAll(pattern));
|
|
3295
|
+
for (const match of matches) {
|
|
3296
|
+
const matchedText = match[0];
|
|
3297
|
+
const matchHash = md5(matchedText);
|
|
3298
|
+
const placeholder = `---LOCKED-PATTERN-${matchHash}---`;
|
|
3299
|
+
lockedPlaceholders[placeholder] = matchedText;
|
|
3300
|
+
finalContent = finalContent.replace(matchedText, placeholder);
|
|
3301
|
+
}
|
|
3302
|
+
} catch (error) {
|
|
3303
|
+
console.warn(`Invalid regex pattern: ${patternStr}`);
|
|
3304
|
+
}
|
|
3305
|
+
}
|
|
3306
|
+
return {
|
|
3307
|
+
content: finalContent,
|
|
3308
|
+
lockedPlaceholders
|
|
3309
|
+
};
|
|
3310
|
+
}
|
|
3311
|
+
function createMdxLockedPatternsLoader(defaultPatterns) {
|
|
3312
|
+
return createLoader({
|
|
3313
|
+
async pull(locale, input2, initCtx, originalLocale) {
|
|
3314
|
+
const patterns = defaultPatterns || [];
|
|
3315
|
+
const { content } = extractLockedPatterns(input2 || "", patterns);
|
|
3316
|
+
return content;
|
|
3317
|
+
},
|
|
3318
|
+
async push(locale, data, originalInput, originalLocale, pullInput, pullOutput) {
|
|
3319
|
+
const patterns = defaultPatterns || [];
|
|
3320
|
+
if (!pullInput) {
|
|
3321
|
+
return data;
|
|
3322
|
+
}
|
|
3323
|
+
const { lockedPlaceholders } = extractLockedPatterns(pullInput, patterns);
|
|
3324
|
+
let result = data;
|
|
3325
|
+
for (const [placeholder, original] of Object.entries(lockedPlaceholders)) {
|
|
3326
|
+
result = result.replaceAll(placeholder, original);
|
|
3327
|
+
}
|
|
3328
|
+
return result;
|
|
3329
|
+
}
|
|
3330
|
+
});
|
|
3331
|
+
}
|
|
3332
|
+
|
|
3281
3333
|
// src/cli/loaders/index.ts
|
|
3282
|
-
function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys) {
|
|
3334
|
+
function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys, lockedPatterns) {
|
|
3283
3335
|
switch (bucketType) {
|
|
3284
3336
|
default:
|
|
3285
3337
|
throw new Error(`Unsupported bucket type: ${bucketType}`);
|
|
@@ -3349,6 +3401,7 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
|
|
|
3349
3401
|
bucketPathPattern
|
|
3350
3402
|
}),
|
|
3351
3403
|
createMdxCodePlaceholderLoader(),
|
|
3404
|
+
createMdxLockedPatternsLoader(lockedPatterns),
|
|
3352
3405
|
createMdxFrontmatterSplitLoader(),
|
|
3353
3406
|
createMdxSectionsSplit2Loader(),
|
|
3354
3407
|
createLocalizableMdxDocumentLoader(),
|
|
@@ -3673,7 +3726,8 @@ function withExponentialBackoff(fn, maxAttempts = 3, baseDelay = 1e3) {
|
|
|
3673
3726
|
}
|
|
3674
3727
|
|
|
3675
3728
|
// src/cli/utils/observability.ts
|
|
3676
|
-
import
|
|
3729
|
+
import pkg from "posthog-node";
|
|
3730
|
+
var { PostHog } = pkg;
|
|
3677
3731
|
async function trackEvent(distinctId, event, properties) {
|
|
3678
3732
|
if (process.env.DO_NOT_TRACK) {
|
|
3679
3733
|
return;
|
|
@@ -3927,7 +3981,8 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
3927
3981
|
defaultLocale: sourceLocale,
|
|
3928
3982
|
injectLocale: bucket.injectLocale
|
|
3929
3983
|
},
|
|
3930
|
-
bucket.lockedKeys
|
|
3984
|
+
bucket.lockedKeys,
|
|
3985
|
+
bucket.lockedPatterns
|
|
3931
3986
|
);
|
|
3932
3987
|
bucketLoader.setDefaultLocale(sourceLocale);
|
|
3933
3988
|
await bucketLoader.init();
|
|
@@ -4113,7 +4168,8 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
4113
4168
|
defaultLocale: sourceLocale,
|
|
4114
4169
|
injectLocale: bucket.injectLocale
|
|
4115
4170
|
},
|
|
4116
|
-
bucket.lockedKeys
|
|
4171
|
+
bucket.lockedKeys,
|
|
4172
|
+
bucket.lockedPatterns
|
|
4117
4173
|
);
|
|
4118
4174
|
bucketLoader.setDefaultLocale(sourceLocale);
|
|
4119
4175
|
await bucketLoader.init();
|
|
@@ -5724,7 +5780,7 @@ function validateParams2(i18nConfig, flags) {
|
|
|
5724
5780
|
// package.json
|
|
5725
5781
|
var package_default = {
|
|
5726
5782
|
name: "lingo.dev",
|
|
5727
|
-
version: "0.
|
|
5783
|
+
version: "0.88.0",
|
|
5728
5784
|
description: "Lingo.dev CLI",
|
|
5729
5785
|
private: false,
|
|
5730
5786
|
publishConfig: {
|