lingo.dev 0.107.6 → 0.109.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 +443 -118
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +353 -28
- package/build/cli.mjs.map +1 -1
- package/package.json +11 -9
package/build/cli.mjs
CHANGED
|
@@ -368,7 +368,8 @@ var colors = {
|
|
|
368
368
|
blue: "#0090ff",
|
|
369
369
|
yellow: "#ffcc00",
|
|
370
370
|
grey: "#808080",
|
|
371
|
-
red: "#ff0000"
|
|
371
|
+
red: "#ff0000",
|
|
372
|
+
white: "#ffffff"
|
|
372
373
|
};
|
|
373
374
|
|
|
374
375
|
// src/cli/utils/ui.ts
|
|
@@ -396,24 +397,24 @@ async function renderHero() {
|
|
|
396
397
|
)} - open-source, AI-powered i18n CLI for web & mobile localization.`
|
|
397
398
|
);
|
|
398
399
|
console.log("");
|
|
399
|
-
const label1 = "\
|
|
400
|
-
const label2 = "\
|
|
401
|
-
const label3 = "\u{
|
|
400
|
+
const label1 = "\u{1F4DA} Docs:";
|
|
401
|
+
const label2 = "\u2B50 Star the repo:";
|
|
402
|
+
const label3 = "\u{1F3AE} Join Discord:";
|
|
402
403
|
const maxLabelWidth = 17;
|
|
403
404
|
console.log(
|
|
404
|
-
`${chalk.hex(colors.blue)(label1.padEnd(maxLabelWidth))} ${chalk.hex(
|
|
405
|
+
`${chalk.hex(colors.blue)(label1.padEnd(maxLabelWidth + 1))} ${chalk.hex(
|
|
405
406
|
colors.blue
|
|
406
|
-
)("https://lingo.dev/go/
|
|
407
|
+
)("https://lingo.dev/go/docs")}`
|
|
407
408
|
);
|
|
408
409
|
console.log(
|
|
409
|
-
`${chalk.hex(colors.blue)(label2.padEnd(maxLabelWidth
|
|
410
|
+
`${chalk.hex(colors.blue)(label2.padEnd(maxLabelWidth))} ${chalk.hex(
|
|
410
411
|
colors.blue
|
|
411
|
-
)("https://lingo.dev/go/
|
|
412
|
+
)("https://lingo.dev/go/gh")}`
|
|
412
413
|
);
|
|
413
414
|
console.log(
|
|
414
415
|
`${chalk.hex(colors.blue)(label3.padEnd(maxLabelWidth + 1))} ${chalk.hex(
|
|
415
416
|
colors.blue
|
|
416
|
-
)("
|
|
417
|
+
)("https://lingo.dev/go/discord")}`
|
|
417
418
|
);
|
|
418
419
|
}
|
|
419
420
|
async function waitForUserPrompt(message) {
|
|
@@ -448,6 +449,17 @@ async function renderSummary(results) {
|
|
|
448
449
|
(r) => r.status === "error"
|
|
449
450
|
).length;
|
|
450
451
|
console.log(`\u2022 ${chalk.hex(colors.yellow)(failedTasksCount)} failed`);
|
|
452
|
+
if (failedTasksCount > 0) {
|
|
453
|
+
console.log(chalk.hex(colors.orange)("\n[Failed]"));
|
|
454
|
+
for (const result of Array.from(results.values()).filter(
|
|
455
|
+
(r) => r.status === "error"
|
|
456
|
+
)) {
|
|
457
|
+
console.log(
|
|
458
|
+
`\u274C ${chalk.hex(colors.white)(String(result.error.message))}
|
|
459
|
+
`
|
|
460
|
+
);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
451
463
|
}
|
|
452
464
|
|
|
453
465
|
// src/cli/cmd/login.ts
|
|
@@ -1513,6 +1525,16 @@ function composeLoaders(...loaders) {
|
|
|
1513
1525
|
result = await loaders[i].push(locale, result);
|
|
1514
1526
|
}
|
|
1515
1527
|
return result;
|
|
1528
|
+
},
|
|
1529
|
+
pullHints: async (originalInput) => {
|
|
1530
|
+
let result = originalInput;
|
|
1531
|
+
for (let i = 0; i < loaders.length; i++) {
|
|
1532
|
+
const subResult = await loaders[i].pullHints?.(result);
|
|
1533
|
+
if (subResult) {
|
|
1534
|
+
result = subResult;
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
return result;
|
|
1516
1538
|
}
|
|
1517
1539
|
};
|
|
1518
1540
|
}
|
|
@@ -1539,6 +1561,9 @@ function createLoader(lDefinition) {
|
|
|
1539
1561
|
state.defaultLocale = locale;
|
|
1540
1562
|
return this;
|
|
1541
1563
|
},
|
|
1564
|
+
async pullHints() {
|
|
1565
|
+
return lDefinition.pullHints?.(state.originalInput);
|
|
1566
|
+
},
|
|
1542
1567
|
async pull(locale, input2) {
|
|
1543
1568
|
if (!state.defaultLocale) {
|
|
1544
1569
|
throw new Error("Default locale not set");
|
|
@@ -1601,12 +1626,220 @@ function createJsonLoader() {
|
|
|
1601
1626
|
});
|
|
1602
1627
|
}
|
|
1603
1628
|
|
|
1629
|
+
// src/cli/loaders/json5.ts
|
|
1630
|
+
import JSON5 from "json5";
|
|
1631
|
+
function createJson5Loader() {
|
|
1632
|
+
return createLoader({
|
|
1633
|
+
pull: async (locale, input2) => {
|
|
1634
|
+
const json5String = input2 || "{}";
|
|
1635
|
+
return JSON5.parse(json5String);
|
|
1636
|
+
},
|
|
1637
|
+
push: async (locale, data) => {
|
|
1638
|
+
const serializedData = JSON5.stringify(data, null, 2);
|
|
1639
|
+
return serializedData;
|
|
1640
|
+
}
|
|
1641
|
+
});
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
// src/cli/loaders/jsonc.ts
|
|
1645
|
+
import { parse } from "jsonc-parser";
|
|
1646
|
+
function extractCommentsFromJsonc(jsoncString) {
|
|
1647
|
+
const lines = jsoncString.split("\n");
|
|
1648
|
+
const comments = {};
|
|
1649
|
+
const errors = [];
|
|
1650
|
+
const result = parse(jsoncString, errors, {
|
|
1651
|
+
allowTrailingComma: true,
|
|
1652
|
+
disallowComments: false,
|
|
1653
|
+
allowEmptyContent: true
|
|
1654
|
+
});
|
|
1655
|
+
if (errors.length > 0) {
|
|
1656
|
+
return {};
|
|
1657
|
+
}
|
|
1658
|
+
const contextStack = [];
|
|
1659
|
+
for (let i = 0; i < lines.length; i++) {
|
|
1660
|
+
const line = lines[i];
|
|
1661
|
+
const trimmedLine = line.trim();
|
|
1662
|
+
if (!trimmedLine) continue;
|
|
1663
|
+
const commentData = extractCommentFromLine(line, lines, i);
|
|
1664
|
+
if (commentData.hint) {
|
|
1665
|
+
let keyInfo;
|
|
1666
|
+
if (commentData.isInline) {
|
|
1667
|
+
const keyMatch = line.match(/^\s*["']?([^"':,\s]+)["']?\s*:/);
|
|
1668
|
+
if (keyMatch) {
|
|
1669
|
+
const key = keyMatch[1];
|
|
1670
|
+
const path17 = contextStack.map((ctx) => ctx.key).filter(Boolean);
|
|
1671
|
+
keyInfo = { key, path: path17 };
|
|
1672
|
+
}
|
|
1673
|
+
} else {
|
|
1674
|
+
keyInfo = findAssociatedKey(lines, commentData.lineIndex, contextStack);
|
|
1675
|
+
}
|
|
1676
|
+
if (keyInfo && keyInfo.key) {
|
|
1677
|
+
setCommentAtPath(comments, keyInfo.path, keyInfo.key, commentData.hint);
|
|
1678
|
+
}
|
|
1679
|
+
i = commentData.endIndex;
|
|
1680
|
+
continue;
|
|
1681
|
+
}
|
|
1682
|
+
updateContext(contextStack, line, result);
|
|
1683
|
+
}
|
|
1684
|
+
return comments;
|
|
1685
|
+
}
|
|
1686
|
+
function extractCommentFromLine(line, lines, lineIndex) {
|
|
1687
|
+
const trimmed = line.trim();
|
|
1688
|
+
if (trimmed.startsWith("//")) {
|
|
1689
|
+
const hint = trimmed.replace(/^\/\/\s*/, "").trim();
|
|
1690
|
+
return { hint, lineIndex, endIndex: lineIndex, isInline: false };
|
|
1691
|
+
}
|
|
1692
|
+
if (trimmed.startsWith("/*")) {
|
|
1693
|
+
const blockResult = extractBlockComment(lines, lineIndex);
|
|
1694
|
+
return { ...blockResult, isInline: false };
|
|
1695
|
+
}
|
|
1696
|
+
const singleInlineMatch = line.match(/^(.+?)\s*\/\/\s*(.+)$/);
|
|
1697
|
+
if (singleInlineMatch && singleInlineMatch[1].includes(":")) {
|
|
1698
|
+
const hint = singleInlineMatch[2].trim();
|
|
1699
|
+
return { hint, lineIndex, endIndex: lineIndex, isInline: true };
|
|
1700
|
+
}
|
|
1701
|
+
const blockInlineMatch = line.match(/^(.+?)\s*\/\*\s*(.*?)\s*\*\/.*$/);
|
|
1702
|
+
if (blockInlineMatch && blockInlineMatch[1].includes(":")) {
|
|
1703
|
+
const hint = blockInlineMatch[2].trim();
|
|
1704
|
+
return { hint, lineIndex, endIndex: lineIndex, isInline: true };
|
|
1705
|
+
}
|
|
1706
|
+
return { hint: null, lineIndex, endIndex: lineIndex, isInline: false };
|
|
1707
|
+
}
|
|
1708
|
+
function extractBlockComment(lines, startIndex) {
|
|
1709
|
+
const startLine = lines[startIndex];
|
|
1710
|
+
const singleMatch = startLine.match(/\/\*\s*(.*?)\s*\*\//);
|
|
1711
|
+
if (singleMatch) {
|
|
1712
|
+
return {
|
|
1713
|
+
hint: singleMatch[1].trim(),
|
|
1714
|
+
lineIndex: startIndex,
|
|
1715
|
+
endIndex: startIndex
|
|
1716
|
+
};
|
|
1717
|
+
}
|
|
1718
|
+
const commentParts = [];
|
|
1719
|
+
let endIndex = startIndex;
|
|
1720
|
+
const firstContent = startLine.replace(/.*?\/\*\s*/, "").trim();
|
|
1721
|
+
if (firstContent && !firstContent.includes("*/")) {
|
|
1722
|
+
commentParts.push(firstContent);
|
|
1723
|
+
}
|
|
1724
|
+
for (let i = startIndex + 1; i < lines.length; i++) {
|
|
1725
|
+
const line = lines[i];
|
|
1726
|
+
endIndex = i;
|
|
1727
|
+
if (line.includes("*/")) {
|
|
1728
|
+
const lastContent = line.replace(/\*\/.*$/, "").replace(/^\s*\*?\s*/, "").trim();
|
|
1729
|
+
if (lastContent) {
|
|
1730
|
+
commentParts.push(lastContent);
|
|
1731
|
+
}
|
|
1732
|
+
break;
|
|
1733
|
+
} else {
|
|
1734
|
+
const content = line.replace(/^\s*\*?\s*/, "").trim();
|
|
1735
|
+
if (content) {
|
|
1736
|
+
commentParts.push(content);
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
return {
|
|
1741
|
+
hint: commentParts.join(" ").trim() || null,
|
|
1742
|
+
lineIndex: startIndex,
|
|
1743
|
+
endIndex
|
|
1744
|
+
};
|
|
1745
|
+
}
|
|
1746
|
+
function findAssociatedKey(lines, commentLineIndex, contextStack) {
|
|
1747
|
+
for (let i = commentLineIndex + 1; i < lines.length; i++) {
|
|
1748
|
+
const line = lines[i].trim();
|
|
1749
|
+
if (!line || line.startsWith("//") || line.startsWith("/*") || line === "{" || line === "}") {
|
|
1750
|
+
continue;
|
|
1751
|
+
}
|
|
1752
|
+
const keyMatch = line.match(/^\s*["']?([^"':,\s]+)["']?\s*:/);
|
|
1753
|
+
if (keyMatch) {
|
|
1754
|
+
const key = keyMatch[1];
|
|
1755
|
+
const path17 = contextStack.map((ctx) => ctx.key).filter(Boolean);
|
|
1756
|
+
return { key, path: path17 };
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
return { key: null, path: [] };
|
|
1760
|
+
}
|
|
1761
|
+
function updateContext(contextStack, line, parsedJson) {
|
|
1762
|
+
const openBraces = (line.match(/\{/g) || []).length;
|
|
1763
|
+
const closeBraces = (line.match(/\}/g) || []).length;
|
|
1764
|
+
if (openBraces > closeBraces) {
|
|
1765
|
+
const keyMatch = line.match(/^\s*["']?([^"':,\s]+)["']?\s*:\s*\{/);
|
|
1766
|
+
if (keyMatch) {
|
|
1767
|
+
contextStack.push({ key: keyMatch[1], isArray: false });
|
|
1768
|
+
}
|
|
1769
|
+
} else if (closeBraces > openBraces) {
|
|
1770
|
+
for (let i = 0; i < closeBraces - openBraces; i++) {
|
|
1771
|
+
contextStack.pop();
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
function setCommentAtPath(comments, path17, key, hint) {
|
|
1776
|
+
let current = comments;
|
|
1777
|
+
for (const pathKey of path17) {
|
|
1778
|
+
if (!current[pathKey]) {
|
|
1779
|
+
current[pathKey] = {};
|
|
1780
|
+
}
|
|
1781
|
+
current = current[pathKey];
|
|
1782
|
+
}
|
|
1783
|
+
if (!current[key]) {
|
|
1784
|
+
current[key] = {};
|
|
1785
|
+
}
|
|
1786
|
+
if (typeof current[key] === "object" && current[key] !== null) {
|
|
1787
|
+
current[key].hint = hint;
|
|
1788
|
+
} else {
|
|
1789
|
+
current[key] = { hint };
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
function createJsoncLoader() {
|
|
1793
|
+
return createLoader({
|
|
1794
|
+
pull: async (locale, input2) => {
|
|
1795
|
+
const jsoncString = input2 || "{}";
|
|
1796
|
+
const errors = [];
|
|
1797
|
+
const result = parse(jsoncString, errors, {
|
|
1798
|
+
allowTrailingComma: true,
|
|
1799
|
+
disallowComments: false,
|
|
1800
|
+
allowEmptyContent: true
|
|
1801
|
+
});
|
|
1802
|
+
if (errors.length > 0) {
|
|
1803
|
+
throw new Error(`Failed to parse JSONC: ${errors[0].error}`);
|
|
1804
|
+
}
|
|
1805
|
+
return result || {};
|
|
1806
|
+
},
|
|
1807
|
+
push: async (locale, data) => {
|
|
1808
|
+
const serializedData = JSON.stringify(data, null, 2);
|
|
1809
|
+
return serializedData;
|
|
1810
|
+
},
|
|
1811
|
+
pullHints: async (input2) => {
|
|
1812
|
+
if (!input2 || typeof input2 !== "string") {
|
|
1813
|
+
return {};
|
|
1814
|
+
}
|
|
1815
|
+
try {
|
|
1816
|
+
return extractCommentsFromJsonc(input2);
|
|
1817
|
+
} catch (error) {
|
|
1818
|
+
console.warn("Failed to extract comments from JSONC:", error);
|
|
1819
|
+
return {};
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
});
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1604
1825
|
// src/cli/loaders/flat.ts
|
|
1605
1826
|
import { flatten, unflatten } from "flat";
|
|
1606
1827
|
import _9 from "lodash";
|
|
1607
1828
|
var OBJECT_NUMERIC_KEY_PREFIX = "__lingodotdev__obj__";
|
|
1608
1829
|
function createFlatLoader() {
|
|
1609
|
-
|
|
1830
|
+
const composedLoader = composeLoaders(
|
|
1831
|
+
createDenormalizeLoader(),
|
|
1832
|
+
createNormalizeLoader()
|
|
1833
|
+
);
|
|
1834
|
+
return {
|
|
1835
|
+
...composedLoader,
|
|
1836
|
+
pullHints: async (input2) => {
|
|
1837
|
+
if (!input2 || typeof input2 !== "object") {
|
|
1838
|
+
return {};
|
|
1839
|
+
}
|
|
1840
|
+
return flattenHints(input2);
|
|
1841
|
+
}
|
|
1842
|
+
};
|
|
1610
1843
|
}
|
|
1611
1844
|
function createDenormalizeLoader() {
|
|
1612
1845
|
return createLoader({
|
|
@@ -1697,6 +1930,33 @@ function normalizeObjectKeys(obj) {
|
|
|
1697
1930
|
return obj;
|
|
1698
1931
|
}
|
|
1699
1932
|
}
|
|
1933
|
+
function flattenHints(obj, parentHints = [], parentPath = "") {
|
|
1934
|
+
const result = {};
|
|
1935
|
+
for (const [key, _value] of Object.entries(obj)) {
|
|
1936
|
+
if (_9.isObject(_value) && !_9.isArray(_value)) {
|
|
1937
|
+
const value = _value;
|
|
1938
|
+
const currentHints = [...parentHints];
|
|
1939
|
+
const currentPath = parentPath ? `${parentPath}/${key}` : key;
|
|
1940
|
+
if (value.hint && typeof value.hint === "string") {
|
|
1941
|
+
currentHints.push(value.hint);
|
|
1942
|
+
}
|
|
1943
|
+
const nestedObj = _9.omit(value, "hint");
|
|
1944
|
+
if (Object.keys(nestedObj).length === 0) {
|
|
1945
|
+
if (currentHints.length > 0) {
|
|
1946
|
+
result[currentPath] = currentHints;
|
|
1947
|
+
}
|
|
1948
|
+
} else {
|
|
1949
|
+
const nestedComments = flattenHints(
|
|
1950
|
+
nestedObj,
|
|
1951
|
+
currentHints,
|
|
1952
|
+
currentPath
|
|
1953
|
+
);
|
|
1954
|
+
Object.assign(result, nestedComments);
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
return result;
|
|
1959
|
+
}
|
|
1700
1960
|
|
|
1701
1961
|
// src/cli/loaders/text-file.ts
|
|
1702
1962
|
import fs8 from "fs/promises";
|
|
@@ -2008,11 +2268,11 @@ function createAndroidLoader() {
|
|
|
2008
2268
|
}
|
|
2009
2269
|
|
|
2010
2270
|
// src/cli/loaders/csv.ts
|
|
2011
|
-
import { parse } from "csv-parse/sync";
|
|
2271
|
+
import { parse as parse2 } from "csv-parse/sync";
|
|
2012
2272
|
import { stringify } from "csv-stringify/sync";
|
|
2013
2273
|
import _11 from "lodash";
|
|
2014
2274
|
function detectKeyColumnName(csvString) {
|
|
2015
|
-
const row =
|
|
2275
|
+
const row = parse2(csvString)[0];
|
|
2016
2276
|
const firstColumn = row?.[0]?.trim();
|
|
2017
2277
|
return firstColumn || "KEY";
|
|
2018
2278
|
}
|
|
@@ -2025,7 +2285,7 @@ function _createCsvLoader() {
|
|
|
2025
2285
|
const keyColumnName = detectKeyColumnName(
|
|
2026
2286
|
input2.split("\n").find((l) => l.length)
|
|
2027
2287
|
);
|
|
2028
|
-
const inputParsed =
|
|
2288
|
+
const inputParsed = parse2(input2, {
|
|
2029
2289
|
columns: true,
|
|
2030
2290
|
skip_empty_lines: true,
|
|
2031
2291
|
relax_column_count_less: true
|
|
@@ -2462,6 +2722,36 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
2462
2722
|
const originalInputWithoutLocale = originalInput ? _removeLocale(originalInput, locale) : {};
|
|
2463
2723
|
const result = _12.merge({}, originalInputWithoutLocale, langDataToMerge);
|
|
2464
2724
|
return result;
|
|
2725
|
+
},
|
|
2726
|
+
async pullHints(originalInput) {
|
|
2727
|
+
if (!originalInput || !originalInput.strings) {
|
|
2728
|
+
return {};
|
|
2729
|
+
}
|
|
2730
|
+
const hints = {};
|
|
2731
|
+
for (const [translationKey, translationEntity] of Object.entries(
|
|
2732
|
+
originalInput.strings
|
|
2733
|
+
)) {
|
|
2734
|
+
const entity = translationEntity;
|
|
2735
|
+
if (entity.comment && typeof entity.comment === "string") {
|
|
2736
|
+
hints[translationKey] = { hint: entity.comment };
|
|
2737
|
+
}
|
|
2738
|
+
if (entity.localizations) {
|
|
2739
|
+
for (const [locale, localization] of Object.entries(
|
|
2740
|
+
entity.localizations
|
|
2741
|
+
)) {
|
|
2742
|
+
if (localization.variations?.plural) {
|
|
2743
|
+
const pluralForms = localization.variations.plural;
|
|
2744
|
+
for (const form in pluralForms) {
|
|
2745
|
+
const pluralKey = `${translationKey}/${form}`;
|
|
2746
|
+
if (entity.comment && typeof entity.comment === "string") {
|
|
2747
|
+
hints[pluralKey] = { hint: entity.comment };
|
|
2748
|
+
}
|
|
2749
|
+
}
|
|
2750
|
+
}
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2754
|
+
return hints;
|
|
2465
2755
|
}
|
|
2466
2756
|
});
|
|
2467
2757
|
}
|
|
@@ -3226,7 +3516,7 @@ function createSrtLoader() {
|
|
|
3226
3516
|
|
|
3227
3517
|
// src/cli/loaders/dato/index.ts
|
|
3228
3518
|
import fs9 from "fs";
|
|
3229
|
-
import
|
|
3519
|
+
import JSON52 from "json5";
|
|
3230
3520
|
|
|
3231
3521
|
// src/cli/loaders/dato/_base.ts
|
|
3232
3522
|
import Z2 from "zod";
|
|
@@ -3913,13 +4203,13 @@ function _isVideo(rawDatoValue) {
|
|
|
3913
4203
|
function createDatoLoader(configFilePath) {
|
|
3914
4204
|
try {
|
|
3915
4205
|
const configContent = fs9.readFileSync(configFilePath, "utf-8");
|
|
3916
|
-
const datoConfig = datoConfigSchema.parse(
|
|
4206
|
+
const datoConfig = datoConfigSchema.parse(JSON52.parse(configContent));
|
|
3917
4207
|
return composeLoaders(
|
|
3918
4208
|
createDatoApiLoader(
|
|
3919
4209
|
datoConfig,
|
|
3920
4210
|
(updatedConfig) => fs9.writeFileSync(
|
|
3921
4211
|
configFilePath,
|
|
3922
|
-
|
|
4212
|
+
JSON52.stringify(updatedConfig, null, 2)
|
|
3923
4213
|
)
|
|
3924
4214
|
),
|
|
3925
4215
|
createDatoFilterLoader(),
|
|
@@ -4244,7 +4534,7 @@ function parseVueFile(input2) {
|
|
|
4244
4534
|
}
|
|
4245
4535
|
|
|
4246
4536
|
// src/cli/loaders/typescript/index.ts
|
|
4247
|
-
import { parse as
|
|
4537
|
+
import { parse as parse3 } from "@babel/parser";
|
|
4248
4538
|
import _21 from "lodash";
|
|
4249
4539
|
import babelTraverseModule from "@babel/traverse";
|
|
4250
4540
|
import * as t from "@babel/types";
|
|
@@ -4293,7 +4583,7 @@ function createTypescriptLoader() {
|
|
|
4293
4583
|
});
|
|
4294
4584
|
}
|
|
4295
4585
|
function parseTypeScript(input2) {
|
|
4296
|
-
return
|
|
4586
|
+
return parse3(input2, {
|
|
4297
4587
|
sourceType: "module",
|
|
4298
4588
|
plugins: ["typescript"]
|
|
4299
4589
|
});
|
|
@@ -6212,9 +6502,11 @@ function extractCodePlaceholders(content) {
|
|
|
6212
6502
|
};
|
|
6213
6503
|
}
|
|
6214
6504
|
function createMdxCodePlaceholderLoader() {
|
|
6505
|
+
const globalPlaceholderRegistry = {};
|
|
6215
6506
|
return createLoader({
|
|
6216
6507
|
async pull(locale, input2) {
|
|
6217
6508
|
const response = extractCodePlaceholders(input2);
|
|
6509
|
+
Object.assign(globalPlaceholderRegistry, response.codePlaceholders);
|
|
6218
6510
|
return response.content;
|
|
6219
6511
|
},
|
|
6220
6512
|
async push(locale, data, originalInput, originalLocale, pullInput) {
|
|
@@ -6222,7 +6514,9 @@ function createMdxCodePlaceholderLoader() {
|
|
|
6222
6514
|
const currentInfo = extractCodePlaceholders(pullInput ?? "");
|
|
6223
6515
|
const codePlaceholders = _24.merge(
|
|
6224
6516
|
sourceInfo.codePlaceholders,
|
|
6225
|
-
currentInfo.codePlaceholders
|
|
6517
|
+
currentInfo.codePlaceholders,
|
|
6518
|
+
globalPlaceholderRegistry
|
|
6519
|
+
// Include ALL placeholders ever created
|
|
6226
6520
|
);
|
|
6227
6521
|
let result = data;
|
|
6228
6522
|
for (const [placeholder, original] of Object.entries(codePlaceholders)) {
|
|
@@ -6686,6 +6980,28 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys,
|
|
|
6686
6980
|
createSyncLoader(),
|
|
6687
6981
|
createUnlocalizableLoader(options.returnUnlocalizedKeys)
|
|
6688
6982
|
);
|
|
6983
|
+
case "json5":
|
|
6984
|
+
return composeLoaders(
|
|
6985
|
+
createTextFileLoader(bucketPathPattern),
|
|
6986
|
+
createJson5Loader(),
|
|
6987
|
+
createEnsureKeyOrderLoader(),
|
|
6988
|
+
createFlatLoader(),
|
|
6989
|
+
createInjectLocaleLoader(options.injectLocale),
|
|
6990
|
+
createLockedKeysLoader(lockedKeys || []),
|
|
6991
|
+
createSyncLoader(),
|
|
6992
|
+
createUnlocalizableLoader(options.returnUnlocalizedKeys)
|
|
6993
|
+
);
|
|
6994
|
+
case "jsonc":
|
|
6995
|
+
return composeLoaders(
|
|
6996
|
+
createTextFileLoader(bucketPathPattern),
|
|
6997
|
+
createJsoncLoader(),
|
|
6998
|
+
createEnsureKeyOrderLoader(),
|
|
6999
|
+
createFlatLoader(),
|
|
7000
|
+
createInjectLocaleLoader(options.injectLocale),
|
|
7001
|
+
createLockedKeysLoader(lockedKeys || []),
|
|
7002
|
+
createSyncLoader(),
|
|
7003
|
+
createUnlocalizableLoader(options.returnUnlocalizedKeys)
|
|
7004
|
+
);
|
|
6689
7005
|
case "markdown":
|
|
6690
7006
|
return composeLoaders(
|
|
6691
7007
|
createTextFileLoader(bucketPathPattern),
|
|
@@ -8276,7 +8592,8 @@ function createLingoDotDevLocalizer(explicitApiKey) {
|
|
|
8276
8592
|
reference: {
|
|
8277
8593
|
[input2.sourceLocale]: input2.sourceData,
|
|
8278
8594
|
[input2.targetLocale]: input2.targetData
|
|
8279
|
-
}
|
|
8595
|
+
},
|
|
8596
|
+
hints: input2.hints
|
|
8280
8597
|
},
|
|
8281
8598
|
onProgress
|
|
8282
8599
|
);
|
|
@@ -8810,6 +9127,7 @@ function createWorkerTask(args) {
|
|
|
8810
9127
|
const sourceData = await bucketLoader.pull(
|
|
8811
9128
|
assignedTask.sourceLocale
|
|
8812
9129
|
);
|
|
9130
|
+
const hints = await bucketLoader.pullHints();
|
|
8813
9131
|
const targetData = await bucketLoader.pull(
|
|
8814
9132
|
assignedTask.targetLocale
|
|
8815
9133
|
);
|
|
@@ -8832,13 +9150,15 @@ function createWorkerTask(args) {
|
|
|
8832
9150
|
});
|
|
8833
9151
|
return { status: "skipped" };
|
|
8834
9152
|
}
|
|
9153
|
+
const relevantHints = _34.pick(hints, Object.keys(processableData));
|
|
8835
9154
|
const processedTargetData = await args.ctx.localizer.localize(
|
|
8836
9155
|
{
|
|
8837
9156
|
sourceLocale: assignedTask.sourceLocale,
|
|
8838
9157
|
targetLocale: assignedTask.targetLocale,
|
|
8839
9158
|
sourceData,
|
|
8840
9159
|
targetData,
|
|
8841
|
-
processableData
|
|
9160
|
+
processableData,
|
|
9161
|
+
hints: relevantHints
|
|
8842
9162
|
},
|
|
8843
9163
|
async (progress, _sourceChunk, processedChunk) => {
|
|
8844
9164
|
await args.ioLimiter(async () => {
|
|
@@ -10468,16 +10788,19 @@ async function renderHero2() {
|
|
|
10468
10788
|
)} - open-source, AI-powered i18n CLI for web & mobile localization.`
|
|
10469
10789
|
);
|
|
10470
10790
|
console.log(" ");
|
|
10791
|
+
console.log(chalk15.hex(colors2.blue)("\u{1F4DA} Docs: https://lingo.dev/go/docs"));
|
|
10792
|
+
console.log(
|
|
10793
|
+
chalk15.hex(colors2.blue)("\u2B50 Star the repo: https://lingo.dev/go/gh")
|
|
10794
|
+
);
|
|
10471
10795
|
console.log(
|
|
10472
|
-
chalk15.hex(colors2.blue)("\
|
|
10796
|
+
chalk15.hex(colors2.blue)("\u{1F3AE} Join Discord: https://lingo.dev/go/discord")
|
|
10473
10797
|
);
|
|
10474
|
-
console.log(chalk15.hex(colors2.blue)("\u{1F4AC} 24/7 Support: hi@lingo.dev"));
|
|
10475
10798
|
}
|
|
10476
10799
|
|
|
10477
10800
|
// package.json
|
|
10478
10801
|
var package_default = {
|
|
10479
10802
|
name: "lingo.dev",
|
|
10480
|
-
version: "0.
|
|
10803
|
+
version: "0.109.0",
|
|
10481
10804
|
description: "Lingo.dev CLI",
|
|
10482
10805
|
private: false,
|
|
10483
10806
|
publishConfig: {
|
|
@@ -10580,7 +10903,8 @@ var package_default = {
|
|
|
10580
10903
|
scripts: {
|
|
10581
10904
|
"lingo.dev": "node --inspect=9229 ./bin/cli.mjs",
|
|
10582
10905
|
dev: "tsup --watch",
|
|
10583
|
-
build: "
|
|
10906
|
+
build: "pnpm typecheck && tsup",
|
|
10907
|
+
typecheck: "tsc --noEmit",
|
|
10584
10908
|
test: "vitest run",
|
|
10585
10909
|
"test:watch": "vitest",
|
|
10586
10910
|
clean: "rm -rf build"
|
|
@@ -10600,7 +10924,7 @@ var package_default = {
|
|
|
10600
10924
|
"@datocms/cma-client-node": "^4.0.1",
|
|
10601
10925
|
"@gitbeaker/rest": "^39.34.3",
|
|
10602
10926
|
"@inkjs/ui": "^2.0.0",
|
|
10603
|
-
"@inquirer/prompts": "^7.
|
|
10927
|
+
"@inquirer/prompts": "^7.7.0",
|
|
10604
10928
|
"@lingo.dev/_compiler": "workspace:*",
|
|
10605
10929
|
"@lingo.dev/_react": "workspace:*",
|
|
10606
10930
|
"@lingo.dev/_sdk": "workspace:*",
|
|
@@ -10625,7 +10949,7 @@ var package_default = {
|
|
|
10625
10949
|
ejs: "^3.1.10",
|
|
10626
10950
|
express: "^5.1.0",
|
|
10627
10951
|
"external-editor": "^3.1.0",
|
|
10628
|
-
figlet: "^1.8.
|
|
10952
|
+
figlet: "^1.8.2",
|
|
10629
10953
|
flat: "^6.0.1",
|
|
10630
10954
|
"gettext-parser": "^8.0.0",
|
|
10631
10955
|
glob: "<11.0.0",
|
|
@@ -10640,6 +10964,7 @@ var package_default = {
|
|
|
10640
10964
|
"is-url": "^1.2.4",
|
|
10641
10965
|
jsdom: "^25.0.1",
|
|
10642
10966
|
json5: "^2.2.3",
|
|
10967
|
+
"jsonc-parser": "^3.3.1",
|
|
10643
10968
|
jsonrepair: "^3.11.2",
|
|
10644
10969
|
listr2: "^8.3.2",
|
|
10645
10970
|
lodash: "^4.17.21",
|
|
@@ -10657,7 +10982,7 @@ var package_default = {
|
|
|
10657
10982
|
"p-limit": "^6.2.0",
|
|
10658
10983
|
"php-array-reader": "^2.1.2",
|
|
10659
10984
|
plist: "^3.1.0",
|
|
10660
|
-
"posthog-node": "^
|
|
10985
|
+
"posthog-node": "^5.5.1",
|
|
10661
10986
|
prettier: "^3.4.2",
|
|
10662
10987
|
react: "^18.3.1",
|
|
10663
10988
|
"rehype-stringify": "^10.0.1",
|