lingo.dev 0.89.6 → 0.90.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/README.md +1 -1
- package/build/cli.cjs +157 -65
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +157 -65
- package/build/cli.mjs.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -164,11 +164,11 @@ Want to contribute? Create a pull request!
|
|
|
164
164
|
- [English](https://github.com/lingodotdev/lingo.dev)
|
|
165
165
|
- [Chinese](/readme/zh-Hans.md)
|
|
166
166
|
- [Japanese](/readme/ja.md)
|
|
167
|
+
- [Korean](/readme/ko.md)
|
|
167
168
|
- [Spanish](/readme/es.md)
|
|
168
169
|
- [French](/readme/fr.md)
|
|
169
170
|
- [Russian](/readme/ru.md)
|
|
170
171
|
- [German](/readme/de.md)
|
|
171
|
-
- [Korean](/readme/ko.md)
|
|
172
172
|
- [Italian](/readme/it.md)
|
|
173
173
|
- [Arabic](/readme/ar.md)
|
|
174
174
|
- [Hindi](/readme/hi.md)
|
package/build/cli.cjs
CHANGED
|
@@ -1342,42 +1342,105 @@ function createAndroidLoader() {
|
|
|
1342
1342
|
return createLoader({
|
|
1343
1343
|
async pull(locale, input2) {
|
|
1344
1344
|
try {
|
|
1345
|
+
if (!input2) {
|
|
1346
|
+
return {};
|
|
1347
|
+
}
|
|
1345
1348
|
const result = {};
|
|
1346
|
-
const
|
|
1349
|
+
const stringRegex = /<string\s+name="([^"]+)"(?:\s+translatable="([^"]+)")?[^>]*>([\s\S]*?)<\/string>/gi;
|
|
1350
|
+
let stringMatch;
|
|
1351
|
+
while ((stringMatch = stringRegex.exec(input2)) !== null) {
|
|
1352
|
+
const name = stringMatch[1];
|
|
1353
|
+
const translatable = stringMatch[2];
|
|
1354
|
+
let value = stringMatch[3];
|
|
1355
|
+
if (translatable === "false") {
|
|
1356
|
+
continue;
|
|
1357
|
+
}
|
|
1358
|
+
const cdataRegex = /<!\[CDATA\[([\s\S]*?)\]\]>/g;
|
|
1359
|
+
value = value.replace(cdataRegex, (match, content) => content);
|
|
1360
|
+
value = value.replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/"/g, '"').replace(/'/g, "'");
|
|
1361
|
+
if (value.startsWith('"') && value.endsWith('"') && value.length >= 2) {
|
|
1362
|
+
value = value.substring(1, value.length - 1);
|
|
1363
|
+
} else {
|
|
1364
|
+
value = value === "" || /^\s+$/.test(value) ? value : value.trim();
|
|
1365
|
+
}
|
|
1366
|
+
result[name] = value;
|
|
1367
|
+
}
|
|
1368
|
+
const parsed = await _xml2js.parseStringPromise.call(void 0, input2, {
|
|
1369
|
+
explicitArray: true,
|
|
1370
|
+
mergeAttrs: false,
|
|
1371
|
+
normalize: true,
|
|
1372
|
+
normalizeTags: false,
|
|
1373
|
+
trim: true,
|
|
1374
|
+
attrkey: "$",
|
|
1375
|
+
charkey: "_"
|
|
1376
|
+
});
|
|
1347
1377
|
if (!parsed || !parsed.resources) {
|
|
1348
|
-
console.warn("No resources found in the Android resource file");
|
|
1349
1378
|
return result;
|
|
1350
1379
|
}
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1380
|
+
if (parsed.resources["string-array"]) {
|
|
1381
|
+
parsed.resources["string-array"].forEach((arrayItem) => {
|
|
1382
|
+
if (arrayItem.$ && arrayItem.$.translatable === "false") {
|
|
1383
|
+
return;
|
|
1384
|
+
}
|
|
1385
|
+
const name = arrayItem.$.name;
|
|
1386
|
+
const items = [];
|
|
1387
|
+
if (arrayItem.item) {
|
|
1388
|
+
arrayItem.item.forEach((item) => {
|
|
1389
|
+
let itemValue = "";
|
|
1390
|
+
if (typeof item === "string") {
|
|
1391
|
+
itemValue = item;
|
|
1392
|
+
} else if (item._) {
|
|
1393
|
+
itemValue = item._;
|
|
1394
|
+
} else if (item._ === "") {
|
|
1395
|
+
itemValue = "";
|
|
1396
|
+
}
|
|
1397
|
+
items.push(itemValue === "" || /^\s+$/.test(itemValue) ? itemValue : itemValue.trim());
|
|
1398
|
+
});
|
|
1399
|
+
}
|
|
1400
|
+
result[name] = items;
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1403
|
+
if (parsed.resources.plurals) {
|
|
1404
|
+
parsed.resources.plurals.forEach((pluralItem) => {
|
|
1405
|
+
if (pluralItem.$ && pluralItem.$.translatable === "false") {
|
|
1406
|
+
return;
|
|
1407
|
+
}
|
|
1408
|
+
const name = pluralItem.$.name;
|
|
1409
|
+
const pluralObj = {};
|
|
1410
|
+
if (pluralItem.item) {
|
|
1411
|
+
pluralItem.item.forEach((item) => {
|
|
1412
|
+
if (item.$ && item.$.quantity) {
|
|
1413
|
+
let value = "";
|
|
1414
|
+
if (item._) {
|
|
1415
|
+
value = item._;
|
|
1416
|
+
} else if (item._ === "") {
|
|
1417
|
+
value = "";
|
|
1369
1418
|
}
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
} else if (resourceType === "bool") {
|
|
1374
|
-
result[item.$.name] = item._ === "true";
|
|
1375
|
-
} else if (resourceType === "integer") {
|
|
1376
|
-
result[item.$.name] = parseInt(item._ || "0", 10);
|
|
1419
|
+
pluralObj[item.$.quantity] = value === "" || /^\s+$/.test(value) ? value : value.trim();
|
|
1420
|
+
}
|
|
1421
|
+
});
|
|
1377
1422
|
}
|
|
1423
|
+
result[name] = pluralObj;
|
|
1378
1424
|
});
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1425
|
+
}
|
|
1426
|
+
if (parsed.resources.bool) {
|
|
1427
|
+
parsed.resources.bool.forEach((boolItem) => {
|
|
1428
|
+
if (boolItem.$ && boolItem.$.translatable === "false") {
|
|
1429
|
+
return;
|
|
1430
|
+
}
|
|
1431
|
+
const name = boolItem.$.name;
|
|
1432
|
+
result[name] = boolItem._ === "true";
|
|
1433
|
+
});
|
|
1434
|
+
}
|
|
1435
|
+
if (parsed.resources.integer) {
|
|
1436
|
+
parsed.resources.integer.forEach((intItem) => {
|
|
1437
|
+
if (intItem.$ && intItem.$.translatable === "false") {
|
|
1438
|
+
return;
|
|
1439
|
+
}
|
|
1440
|
+
const name = intItem.$.name;
|
|
1441
|
+
result[name] = parseInt(intItem._ || "0", 10);
|
|
1442
|
+
});
|
|
1443
|
+
}
|
|
1381
1444
|
return result;
|
|
1382
1445
|
} catch (error) {
|
|
1383
1446
|
console.error("Error parsing Android resource file:", error);
|
|
@@ -1388,43 +1451,69 @@ function createAndroidLoader() {
|
|
|
1388
1451
|
}
|
|
1389
1452
|
},
|
|
1390
1453
|
async push(locale, payload) {
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
}
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
}
|
|
1406
|
-
}
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1454
|
+
try {
|
|
1455
|
+
const xmlObj = {
|
|
1456
|
+
resources: {
|
|
1457
|
+
string: [],
|
|
1458
|
+
"string-array": [],
|
|
1459
|
+
plurals: [],
|
|
1460
|
+
bool: [],
|
|
1461
|
+
integer: []
|
|
1462
|
+
}
|
|
1463
|
+
};
|
|
1464
|
+
const processHtmlContent = (str) => {
|
|
1465
|
+
if (typeof str !== "string") return { _: String(str) };
|
|
1466
|
+
const containsHtml = /<[a-z][\s\S]*>/i.test(str);
|
|
1467
|
+
const containsSpecialChars = /[<>&]/.test(str);
|
|
1468
|
+
return { _: str };
|
|
1469
|
+
};
|
|
1470
|
+
for (const [key, value] of Object.entries(payload)) {
|
|
1471
|
+
if (typeof value === "string") {
|
|
1472
|
+
xmlObj.resources.string.push({
|
|
1473
|
+
$: { name: key },
|
|
1474
|
+
...processHtmlContent(value)
|
|
1475
|
+
});
|
|
1476
|
+
} else if (Array.isArray(value)) {
|
|
1477
|
+
xmlObj.resources["string-array"].push({
|
|
1478
|
+
$: { name: key },
|
|
1479
|
+
item: value.map((item) => processHtmlContent(item))
|
|
1480
|
+
});
|
|
1481
|
+
} else if (typeof value === "object") {
|
|
1482
|
+
xmlObj.resources.plurals.push({
|
|
1483
|
+
$: { name: key },
|
|
1484
|
+
item: Object.entries(value).map(([quantity, text]) => ({
|
|
1485
|
+
$: { quantity },
|
|
1486
|
+
...processHtmlContent(text)
|
|
1487
|
+
}))
|
|
1488
|
+
});
|
|
1489
|
+
} else if (typeof value === "boolean") {
|
|
1490
|
+
xmlObj.resources.bool.push({
|
|
1491
|
+
$: { name: key },
|
|
1492
|
+
_: value.toString()
|
|
1493
|
+
});
|
|
1494
|
+
} else if (typeof value === "number") {
|
|
1495
|
+
xmlObj.resources.integer.push({
|
|
1496
|
+
$: { name: key },
|
|
1497
|
+
_: value.toString()
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1424
1500
|
}
|
|
1501
|
+
const builder = new (0, _xml2js.Builder)({
|
|
1502
|
+
headless: true,
|
|
1503
|
+
renderOpts: {
|
|
1504
|
+
pretty: true,
|
|
1505
|
+
indent: " ",
|
|
1506
|
+
newline: "\n"
|
|
1507
|
+
}
|
|
1508
|
+
});
|
|
1509
|
+
return builder.buildObject(xmlObj);
|
|
1510
|
+
} catch (error) {
|
|
1511
|
+
console.error("Error generating Android resource file:", error);
|
|
1512
|
+
throw new CLIError({
|
|
1513
|
+
message: "Failed to generate Android resource file",
|
|
1514
|
+
docUrl: "androidResouceError"
|
|
1515
|
+
});
|
|
1425
1516
|
}
|
|
1426
|
-
const result = builder.buildObject(xmlObj);
|
|
1427
|
-
return result;
|
|
1428
1517
|
}
|
|
1429
1518
|
});
|
|
1430
1519
|
}
|
|
@@ -5459,6 +5548,9 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
5459
5548
|
LINGODOTDEV_PROCESS_OWN_COMMITS: options.processOwnCommits.toString()
|
|
5460
5549
|
}
|
|
5461
5550
|
};
|
|
5551
|
+
console.log("--- config ---");
|
|
5552
|
+
console.log(env);
|
|
5553
|
+
console.log("--- ---");
|
|
5462
5554
|
process.env = { ...process.env, ...env };
|
|
5463
5555
|
const ora = _ora2.default.call(void 0, );
|
|
5464
5556
|
const platformKit = getPlatformKit();
|
|
@@ -5896,7 +5988,7 @@ function validateParams2(i18nConfig, flags) {
|
|
|
5896
5988
|
// package.json
|
|
5897
5989
|
var package_default = {
|
|
5898
5990
|
name: "lingo.dev",
|
|
5899
|
-
version: "0.
|
|
5991
|
+
version: "0.90.0",
|
|
5900
5992
|
description: "Lingo.dev CLI",
|
|
5901
5993
|
private: false,
|
|
5902
5994
|
publishConfig: {
|