localingos 0.1.12 → 0.1.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "localingos",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "CLI tool to sync translations with Localingos",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -22,11 +22,14 @@ export async function pullCommand(options) {
22
22
 
23
23
  console.log(chalk.green(` āœ… ${translations.length} translations received`));
24
24
 
25
- if (translations.length > 0) {
25
+ // Filter out source locale to avoid overwriting the source file
26
+ const targetTranslations = translations.filter(t => t.locale !== config.sourceLocale);
27
+
28
+ if (targetTranslations.length > 0) {
26
29
  const outputDir = path.resolve(config.outputDir);
27
30
  console.log(chalk.blue(`\nšŸ“ Writing translation files to ${outputDir}`));
28
31
 
29
- const writtenFiles = formatter.write(translations, outputDir, config.outputPattern);
32
+ const writtenFiles = formatter.write(targetTranslations, outputDir, config.outputPattern);
30
33
  for (const file of writtenFiles) {
31
34
  console.log(chalk.green(` āœ… ${file}`));
32
35
  }
@@ -68,18 +68,21 @@ export async function syncCommand(options) {
68
68
  process.exit(1);
69
69
  }
70
70
 
71
- const { translations, pending } = result;
71
+ const translations = result.translations || [];
72
+ const pending = result.pending || [];
72
73
  console.log(chalk.green(` āœ… ${translations.length} translations available`));
73
74
  if (pending.length > 0) {
74
75
  console.log(chalk.yellow(` ā³ ${pending.length} keys pending translation: ${pending.slice(0, 5).join(', ')}${pending.length > 5 ? '...' : ''}`));
75
76
  }
76
77
 
77
- // 3. Write translation files
78
- if (translations.length > 0) {
78
+ // 3. Write translation files (skip source locale to avoid overwriting the source file)
79
+ const targetTranslations = translations.filter(t => t.locale !== config.sourceLocale);
80
+
81
+ if (targetTranslations.length > 0) {
79
82
  const outputDir = path.resolve(config.outputDir);
80
83
  console.log(chalk.blue(`\nšŸ“ Writing translation files to ${outputDir}`));
81
84
 
82
- const writtenFiles = formatter.write(translations, outputDir, config.outputPattern);
85
+ const writtenFiles = formatter.write(targetTranslations, outputDir, config.outputPattern);
83
86
  for (const file of writtenFiles) {
84
87
  console.log(chalk.green(` āœ… ${file}`));
85
88
  }