lingo.dev 0.74.17 → 0.75.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 +77 -6
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +77 -6
- package/build/cli.mjs.map +1 -1
- package/package.json +4 -3
package/build/cli.cjs
CHANGED
|
@@ -287,6 +287,8 @@ function findLocaleFiles(bucket) {
|
|
|
287
287
|
return findLocaleFilesWithExtension(".xml");
|
|
288
288
|
case "markdown":
|
|
289
289
|
return findLocaleFilesWithExtension(".md");
|
|
290
|
+
case "php":
|
|
291
|
+
return findLocaleFilesWithExtension(".php");
|
|
290
292
|
case "xcode-xcstrings":
|
|
291
293
|
return findLocaleFilesForFilename("Localizable.xcstrings");
|
|
292
294
|
case "xcode-strings":
|
|
@@ -2537,10 +2539,10 @@ function createSyncLoader() {
|
|
|
2537
2539
|
|
|
2538
2540
|
// src/cli/utils/plutil-formatter.ts
|
|
2539
2541
|
function formatPlutilStyle(jsonData, existingJson) {
|
|
2540
|
-
const
|
|
2542
|
+
const indent2 = existingJson ? detectIndentation(existingJson) : " ";
|
|
2541
2543
|
function format(data, level = 0) {
|
|
2542
|
-
const currentIndent =
|
|
2543
|
-
const nextIndent =
|
|
2544
|
+
const currentIndent = indent2.repeat(level);
|
|
2545
|
+
const nextIndent = indent2.repeat(level + 1);
|
|
2544
2546
|
if (typeof data !== "object" || data === null) {
|
|
2545
2547
|
return JSON.stringify(data);
|
|
2546
2548
|
}
|
|
@@ -2594,6 +2596,66 @@ function createPlutilJsonTextLoader() {
|
|
|
2594
2596
|
});
|
|
2595
2597
|
}
|
|
2596
2598
|
|
|
2599
|
+
// src/cli/loaders/php.ts
|
|
2600
|
+
var _phparrayreader = require('php-array-reader');
|
|
2601
|
+
function createPhpLoader() {
|
|
2602
|
+
return createLoader({
|
|
2603
|
+
pull: async (locale, input2) => {
|
|
2604
|
+
try {
|
|
2605
|
+
const output = _phparrayreader.fromString.call(void 0, input2);
|
|
2606
|
+
return output;
|
|
2607
|
+
} catch (error) {
|
|
2608
|
+
throw new Error(`Error parsing PHP file for locale ${locale}`);
|
|
2609
|
+
}
|
|
2610
|
+
},
|
|
2611
|
+
push: async (locale, data, originalInput) => {
|
|
2612
|
+
const output = toPhpString(data, originalInput);
|
|
2613
|
+
return output;
|
|
2614
|
+
}
|
|
2615
|
+
});
|
|
2616
|
+
}
|
|
2617
|
+
function toPhpString(data, originalPhpString) {
|
|
2618
|
+
const defaultFilePrefix = "<?php\n\n";
|
|
2619
|
+
if (originalPhpString) {
|
|
2620
|
+
const [filePrefix = defaultFilePrefix] = originalPhpString.split("return ");
|
|
2621
|
+
const shortArraySyntax = !originalPhpString.includes("array(");
|
|
2622
|
+
const output = `${filePrefix}return ${toPhpArray(data, shortArraySyntax)};`;
|
|
2623
|
+
return output;
|
|
2624
|
+
}
|
|
2625
|
+
return `${defaultFilePrefix}return ${toPhpArray(data)};`;
|
|
2626
|
+
}
|
|
2627
|
+
function toPhpArray(data, shortSyntax = true, indentLevel = 1) {
|
|
2628
|
+
if (data === null || data === void 0) {
|
|
2629
|
+
return "null";
|
|
2630
|
+
}
|
|
2631
|
+
if (typeof data === "string") {
|
|
2632
|
+
return `'${escapePhpString(data)}'`;
|
|
2633
|
+
}
|
|
2634
|
+
if (typeof data === "number") {
|
|
2635
|
+
return data.toString();
|
|
2636
|
+
}
|
|
2637
|
+
if (typeof data === "boolean") {
|
|
2638
|
+
return data ? "true" : "false";
|
|
2639
|
+
}
|
|
2640
|
+
const arrayStart = shortSyntax ? "[" : "array(";
|
|
2641
|
+
const arrayEnd = shortSyntax ? "]" : ")";
|
|
2642
|
+
if (Array.isArray(data)) {
|
|
2643
|
+
return `${arrayStart}
|
|
2644
|
+
${data.map((value) => `${indent(indentLevel)}${toPhpArray(value, shortSyntax, indentLevel + 1)}`).join(",\n")}
|
|
2645
|
+
${indent(indentLevel - 1)}${arrayEnd}`;
|
|
2646
|
+
}
|
|
2647
|
+
const output = `${arrayStart}
|
|
2648
|
+
${Object.entries(data).map(([key, value]) => `${indent(indentLevel)}'${key}' => ${toPhpArray(value, shortSyntax, indentLevel + 1)}`).join(",\n")}
|
|
2649
|
+
${indent(indentLevel - 1)}${arrayEnd}`;
|
|
2650
|
+
return output;
|
|
2651
|
+
}
|
|
2652
|
+
function indent(level) {
|
|
2653
|
+
return " ".repeat(level);
|
|
2654
|
+
}
|
|
2655
|
+
function escapePhpString(str) {
|
|
2656
|
+
return str.replaceAll("\\", "\\\\").replaceAll("'", "\\'").replaceAll("\r", "\\r").replaceAll("\n", "\\n").replaceAll(" ", "\\t");
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2597
2659
|
// src/cli/loaders/index.ts
|
|
2598
2660
|
function createBucketLoader(bucketType, bucketPathPattern, { isCacheRestore = false } = {}) {
|
|
2599
2661
|
switch (bucketType) {
|
|
@@ -2748,6 +2810,14 @@ function createBucketLoader(bucketType, bucketPathPattern, { isCacheRestore = fa
|
|
|
2748
2810
|
createSyncLoader(),
|
|
2749
2811
|
createUnlocalizableLoader(isCacheRestore)
|
|
2750
2812
|
);
|
|
2813
|
+
case "php":
|
|
2814
|
+
return composeLoaders(
|
|
2815
|
+
createTextFileLoader(bucketPathPattern),
|
|
2816
|
+
createPhpLoader(),
|
|
2817
|
+
createSyncLoader(),
|
|
2818
|
+
createFlatLoader(),
|
|
2819
|
+
createUnlocalizableLoader()
|
|
2820
|
+
);
|
|
2751
2821
|
}
|
|
2752
2822
|
}
|
|
2753
2823
|
|
|
@@ -3441,7 +3511,7 @@ function displaySummary(results) {
|
|
|
3441
3511
|
// package.json
|
|
3442
3512
|
var package_default = {
|
|
3443
3513
|
name: "lingo.dev",
|
|
3444
|
-
version: "0.
|
|
3514
|
+
version: "0.75.0",
|
|
3445
3515
|
description: "Lingo.dev CLI",
|
|
3446
3516
|
private: false,
|
|
3447
3517
|
publishConfig: {
|
|
@@ -3485,10 +3555,10 @@ var package_default = {
|
|
|
3485
3555
|
author: "",
|
|
3486
3556
|
license: "Apache-2.0",
|
|
3487
3557
|
dependencies: {
|
|
3488
|
-
"@lingo.dev/_sdk": "workspace:*",
|
|
3489
|
-
"@lingo.dev/_spec": "workspace:*",
|
|
3490
3558
|
"@datocms/cma-client-node": "^3.4.0",
|
|
3491
3559
|
"@inquirer/prompts": "^7.2.3",
|
|
3560
|
+
"@lingo.dev/_sdk": "workspace:*",
|
|
3561
|
+
"@lingo.dev/_spec": "workspace:*",
|
|
3492
3562
|
"@paralleldrive/cuid2": "^2.2.2",
|
|
3493
3563
|
chalk: "^5.4.1",
|
|
3494
3564
|
cors: "^2.8.5",
|
|
@@ -3522,6 +3592,7 @@ var package_default = {
|
|
|
3522
3592
|
open: "^10.1.0",
|
|
3523
3593
|
ora: "^8.1.1",
|
|
3524
3594
|
"p-limit": "^6.2.0",
|
|
3595
|
+
"php-array-reader": "^2.1.2",
|
|
3525
3596
|
plist: "^3.1.0",
|
|
3526
3597
|
prettier: "^3.4.2",
|
|
3527
3598
|
"properties-parser": "^0.6.0",
|