@umituz/react-native-google-translate 1.0.5 → 1.0.6

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.
@@ -1,5 +1,6 @@
1
+ "use strict";
1
2
  /**
2
3
  * Language Entity
3
4
  * @description Language code mappings and metadata
4
5
  */
5
- export {};
6
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +1,6 @@
1
+ "use strict";
1
2
  /**
2
3
  * Translation Entity
3
4
  * @description Represents a translation request and response
4
5
  */
5
- export {};
6
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +1,6 @@
1
+ "use strict";
1
2
  /**
2
3
  * Domain Entities
3
4
  * @description Exports all entity types
4
5
  */
5
- export {};
6
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,8 +1,24 @@
1
+ "use strict";
1
2
  /**
2
3
  * Domain Layer
3
4
  * @description Subpath: @umituz/react-native-google-translate/core
4
5
  *
5
6
  * Exports all domain entities and interfaces
6
7
  */
7
- export * from "./entities";
8
- export * from "./interfaces";
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ __exportStar(require("./entities"), exports);
24
+ __exportStar(require("./interfaces"), exports);
@@ -1,5 +1,6 @@
1
+ "use strict";
1
2
  /**
2
3
  * Translation Service Interface
3
4
  * @description Defines the contract for translation services
4
5
  */
5
- export {};
6
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +1,6 @@
1
+ "use strict";
1
2
  /**
2
3
  * Domain Interfaces
3
4
  * @description Exports all interface definitions
4
5
  */
5
- export {};
6
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,8 +1,11 @@
1
+ "use strict";
1
2
  /**
2
3
  * API Constants
3
4
  * @description Google Translate API configuration
4
5
  */
5
- export const GOOGLE_TRANSLATE_API_URL = "https://translate.googleapis.com/translate_a/single";
6
- export const DEFAULT_TIMEOUT = 10000;
7
- export const DEFAULT_MIN_DELAY = 100;
8
- export const DEFAULT_MAX_RETRIES = 3;
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.DEFAULT_MAX_RETRIES = exports.DEFAULT_MIN_DELAY = exports.DEFAULT_TIMEOUT = exports.GOOGLE_TRANSLATE_API_URL = void 0;
8
+ exports.GOOGLE_TRANSLATE_API_URL = "https://translate.googleapis.com/translate_a/single";
9
+ exports.DEFAULT_TIMEOUT = 10000;
10
+ exports.DEFAULT_MIN_DELAY = 100;
11
+ exports.DEFAULT_MAX_RETRIES = 3;
@@ -1,6 +1,16 @@
1
+ "use strict";
1
2
  /**
2
3
  * Infrastructure Constants
3
4
  * @description Exports all constant definitions
4
5
  */
5
- export { LANGUAGE_MAP, SKIP_WORDS, LANGUAGE_NAMES, } from "./languages.constants";
6
- export { GOOGLE_TRANSLATE_API_URL, DEFAULT_TIMEOUT, DEFAULT_MIN_DELAY, DEFAULT_MAX_RETRIES, } from "./api.constants";
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.DEFAULT_MAX_RETRIES = exports.DEFAULT_MIN_DELAY = exports.DEFAULT_TIMEOUT = exports.GOOGLE_TRANSLATE_API_URL = exports.LANGUAGE_NAMES = exports.SKIP_WORDS = exports.LANGUAGE_MAP = void 0;
8
+ var languages_constants_1 = require("./languages.constants");
9
+ Object.defineProperty(exports, "LANGUAGE_MAP", { enumerable: true, get: function () { return languages_constants_1.LANGUAGE_MAP; } });
10
+ Object.defineProperty(exports, "SKIP_WORDS", { enumerable: true, get: function () { return languages_constants_1.SKIP_WORDS; } });
11
+ Object.defineProperty(exports, "LANGUAGE_NAMES", { enumerable: true, get: function () { return languages_constants_1.LANGUAGE_NAMES; } });
12
+ var api_constants_1 = require("./api.constants");
13
+ Object.defineProperty(exports, "GOOGLE_TRANSLATE_API_URL", { enumerable: true, get: function () { return api_constants_1.GOOGLE_TRANSLATE_API_URL; } });
14
+ Object.defineProperty(exports, "DEFAULT_TIMEOUT", { enumerable: true, get: function () { return api_constants_1.DEFAULT_TIMEOUT; } });
15
+ Object.defineProperty(exports, "DEFAULT_MIN_DELAY", { enumerable: true, get: function () { return api_constants_1.DEFAULT_MIN_DELAY; } });
16
+ Object.defineProperty(exports, "DEFAULT_MAX_RETRIES", { enumerable: true, get: function () { return api_constants_1.DEFAULT_MAX_RETRIES; } });
@@ -1,8 +1,11 @@
1
+ "use strict";
1
2
  /**
2
3
  * Language Constants
3
4
  * @description Language mappings and metadata
4
5
  */
5
- export const LANGUAGE_MAP = {
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.LANGUAGE_NAMES = exports.SKIP_WORDS = exports.LANGUAGE_MAP = void 0;
8
+ exports.LANGUAGE_MAP = {
6
9
  "ar-SA": "ar",
7
10
  "bg-BG": "bg",
8
11
  "cs-CZ": "cs",
@@ -43,7 +46,7 @@ export const LANGUAGE_MAP = {
43
46
  "zh-CN": "zh-CN",
44
47
  "zh-TW": "zh-TW",
45
48
  };
46
- export const SKIP_WORDS = new Set([
49
+ exports.SKIP_WORDS = new Set([
47
50
  "Google",
48
51
  "Apple",
49
52
  "Facebook",
@@ -52,7 +55,7 @@ export const SKIP_WORDS = new Set([
52
55
  "YouTube",
53
56
  "WhatsApp",
54
57
  ]);
55
- export const LANGUAGE_NAMES = {
58
+ exports.LANGUAGE_NAMES = {
56
59
  "ar-SA": "Arabic (Saudi Arabia)",
57
60
  "bg-BG": "Bulgarian",
58
61
  "cs-CZ": "Czech",
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ /**
3
+ * Infrastructure Layer
4
+ * @description Subpath: @umituz/react-native-google-translate/infrastructure
5
+ *
6
+ * Exports all infrastructure services, utils, and constants
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ __exportStar(require("./services"), exports);
24
+ __exportStar(require("./utils"), exports);
25
+ __exportStar(require("./constants"), exports);
@@ -1,21 +1,24 @@
1
+ "use strict";
1
2
  /**
2
3
  * Google Translate Service
3
4
  * @description Main translation service using Google Translate API
4
5
  */
5
- import { RateLimiter } from "../utils/rateLimit.util";
6
- import { shouldSkipWord, needsTranslation, isValidText, } from "../utils/textValidator.util";
7
- import { GOOGLE_TRANSLATE_API_URL, DEFAULT_MIN_DELAY, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT, } from "../constants";
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.googleTranslateService = void 0;
8
+ const rateLimit_util_1 = require("../utils/rateLimit.util");
9
+ const textValidator_util_1 = require("../utils/textValidator.util");
10
+ const constants_1 = require("../constants");
8
11
  class GoogleTranslateService {
9
12
  config = null;
10
13
  rateLimiter = null;
11
14
  initialize(config) {
12
15
  this.config = {
13
- minDelay: DEFAULT_MIN_DELAY,
14
- maxRetries: DEFAULT_MAX_RETRIES,
15
- timeout: DEFAULT_TIMEOUT,
16
+ minDelay: constants_1.DEFAULT_MIN_DELAY,
17
+ maxRetries: constants_1.DEFAULT_MAX_RETRIES,
18
+ timeout: constants_1.DEFAULT_TIMEOUT,
16
19
  ...config,
17
20
  };
18
- this.rateLimiter = new RateLimiter(this.config.minDelay);
21
+ this.rateLimiter = new rateLimit_util_1.RateLimiter(this.config.minDelay);
19
22
  }
20
23
  isInitialized() {
21
24
  return this.config !== null && this.rateLimiter !== null;
@@ -28,7 +31,7 @@ class GoogleTranslateService {
28
31
  async translate(request) {
29
32
  this.ensureInitialized();
30
33
  const { text, targetLanguage, sourceLanguage = "en" } = request;
31
- if (!isValidText(text) || shouldSkipWord(text)) {
34
+ if (!(0, textValidator_util_1.isValidText)(text) || (0, textValidator_util_1.shouldSkipWord)(text)) {
32
35
  return {
33
36
  originalText: text,
34
37
  translatedText: text,
@@ -139,7 +142,7 @@ class GoogleTranslateService {
139
142
  }
140
143
  else if (typeof enValue === "string") {
141
144
  stats.totalCount++;
142
- if (needsTranslation(targetValue, enValue)) {
145
+ if ((0, textValidator_util_1.needsTranslation)(targetValue, enValue)) {
143
146
  const request = {
144
147
  text: enValue,
145
148
  targetLanguage,
@@ -168,9 +171,9 @@ class GoogleTranslateService {
168
171
  }
169
172
  }
170
173
  async callTranslateAPI(text, targetLanguage, sourceLanguage) {
171
- const timeout = this.config?.timeout || DEFAULT_TIMEOUT;
174
+ const timeout = this.config?.timeout || constants_1.DEFAULT_TIMEOUT;
172
175
  const encodedText = encodeURIComponent(text);
173
- const url = `${GOOGLE_TRANSLATE_API_URL}?client=gtx&sl=${sourceLanguage}&tl=${targetLanguage}&dt=t&q=${encodedText}`;
176
+ const url = `${constants_1.GOOGLE_TRANSLATE_API_URL}?client=gtx&sl=${sourceLanguage}&tl=${targetLanguage}&dt=t&q=${encodedText}`;
174
177
  const controller = new AbortController();
175
178
  const timeoutId = setTimeout(() => controller.abort(), timeout);
176
179
  try {
@@ -197,4 +200,4 @@ class GoogleTranslateService {
197
200
  }
198
201
  }
199
202
  }
200
- export const googleTranslateService = new GoogleTranslateService();
203
+ exports.googleTranslateService = new GoogleTranslateService();
@@ -1,7 +1,20 @@
1
+ "use strict";
1
2
  /**
2
3
  * Infrastructure Services
3
4
  * @description Exports all services and utilities
4
5
  */
5
- export { googleTranslateService } from "./GoogleTranslate.service";
6
- export { shouldSkipWord, needsTranslation, isValidText, getTargetLanguage, isEnglishVariant, getLanguageDisplayName, } from "../utils/textValidator.util";
7
- export { LANGUAGE_MAP, SKIP_WORDS, LANGUAGE_NAMES, } from "../constants/languages.constants";
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.LANGUAGE_NAMES = exports.SKIP_WORDS = exports.LANGUAGE_MAP = exports.getLanguageDisplayName = exports.isEnglishVariant = exports.getTargetLanguage = exports.isValidText = exports.needsTranslation = exports.shouldSkipWord = exports.googleTranslateService = void 0;
8
+ var GoogleTranslate_service_1 = require("./GoogleTranslate.service");
9
+ Object.defineProperty(exports, "googleTranslateService", { enumerable: true, get: function () { return GoogleTranslate_service_1.googleTranslateService; } });
10
+ var textValidator_util_1 = require("../utils/textValidator.util");
11
+ Object.defineProperty(exports, "shouldSkipWord", { enumerable: true, get: function () { return textValidator_util_1.shouldSkipWord; } });
12
+ Object.defineProperty(exports, "needsTranslation", { enumerable: true, get: function () { return textValidator_util_1.needsTranslation; } });
13
+ Object.defineProperty(exports, "isValidText", { enumerable: true, get: function () { return textValidator_util_1.isValidText; } });
14
+ Object.defineProperty(exports, "getTargetLanguage", { enumerable: true, get: function () { return textValidator_util_1.getTargetLanguage; } });
15
+ Object.defineProperty(exports, "isEnglishVariant", { enumerable: true, get: function () { return textValidator_util_1.isEnglishVariant; } });
16
+ Object.defineProperty(exports, "getLanguageDisplayName", { enumerable: true, get: function () { return textValidator_util_1.getLanguageDisplayName; } });
17
+ var languages_constants_1 = require("../constants/languages.constants");
18
+ Object.defineProperty(exports, "LANGUAGE_MAP", { enumerable: true, get: function () { return languages_constants_1.LANGUAGE_MAP; } });
19
+ Object.defineProperty(exports, "SKIP_WORDS", { enumerable: true, get: function () { return languages_constants_1.SKIP_WORDS; } });
20
+ Object.defineProperty(exports, "LANGUAGE_NAMES", { enumerable: true, get: function () { return languages_constants_1.LANGUAGE_NAMES; } });
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ /**
3
+ * Infrastructure Utils
4
+ * @description Exports all utility functions
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.getLanguageDisplayName = exports.isEnglishVariant = exports.getTargetLanguage = exports.isValidText = exports.needsTranslation = exports.shouldSkipWord = exports.RateLimiter = void 0;
8
+ var rateLimit_util_1 = require("./rateLimit.util");
9
+ Object.defineProperty(exports, "RateLimiter", { enumerable: true, get: function () { return rateLimit_util_1.RateLimiter; } });
10
+ var textValidator_util_1 = require("./textValidator.util");
11
+ Object.defineProperty(exports, "shouldSkipWord", { enumerable: true, get: function () { return textValidator_util_1.shouldSkipWord; } });
12
+ Object.defineProperty(exports, "needsTranslation", { enumerable: true, get: function () { return textValidator_util_1.needsTranslation; } });
13
+ Object.defineProperty(exports, "isValidText", { enumerable: true, get: function () { return textValidator_util_1.isValidText; } });
14
+ Object.defineProperty(exports, "getTargetLanguage", { enumerable: true, get: function () { return textValidator_util_1.getTargetLanguage; } });
15
+ Object.defineProperty(exports, "isEnglishVariant", { enumerable: true, get: function () { return textValidator_util_1.isEnglishVariant; } });
16
+ Object.defineProperty(exports, "getLanguageDisplayName", { enumerable: true, get: function () { return textValidator_util_1.getLanguageDisplayName; } });
@@ -1,8 +1,11 @@
1
+ "use strict";
1
2
  /**
2
3
  * Rate Limit Utility
3
4
  * @description Handles rate limiting for API requests
4
5
  */
5
- export class RateLimiter {
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.RateLimiter = void 0;
8
+ class RateLimiter {
6
9
  lastCallTime = 0;
7
10
  minDelay;
8
11
  constructor(minDelay = 100) {
@@ -21,3 +24,4 @@ export class RateLimiter {
21
24
  this.lastCallTime = 0;
22
25
  }
23
26
  }
27
+ exports.RateLimiter = RateLimiter;
@@ -1,12 +1,20 @@
1
+ "use strict";
1
2
  /**
2
3
  * Text Validator Utility
3
4
  * @description Validates text for translation eligibility
4
5
  */
5
- import { SKIP_WORDS, LANGUAGE_MAP, LANGUAGE_NAMES } from "../constants";
6
- export function shouldSkipWord(word) {
7
- return SKIP_WORDS.has(word);
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.shouldSkipWord = shouldSkipWord;
8
+ exports.needsTranslation = needsTranslation;
9
+ exports.isValidText = isValidText;
10
+ exports.getTargetLanguage = getTargetLanguage;
11
+ exports.isEnglishVariant = isEnglishVariant;
12
+ exports.getLanguageDisplayName = getLanguageDisplayName;
13
+ const constants_1 = require("../constants");
14
+ function shouldSkipWord(word) {
15
+ return constants_1.SKIP_WORDS.has(word);
8
16
  }
9
- export function needsTranslation(value, enValue) {
17
+ function needsTranslation(value, enValue) {
10
18
  if (typeof enValue !== "string" || !enValue.trim()) {
11
19
  return false;
12
20
  }
@@ -35,16 +43,16 @@ export function needsTranslation(value, enValue) {
35
43
  }
36
44
  return false;
37
45
  }
38
- export function isValidText(text) {
46
+ function isValidText(text) {
39
47
  return typeof text === "string" && text.length > 0;
40
48
  }
41
- export function getTargetLanguage(langCode) {
42
- return LANGUAGE_MAP[langCode];
49
+ function getTargetLanguage(langCode) {
50
+ return constants_1.LANGUAGE_MAP[langCode];
43
51
  }
44
- export function isEnglishVariant(langCode) {
52
+ function isEnglishVariant(langCode) {
45
53
  const targetLang = getTargetLanguage(langCode);
46
54
  return targetLang === "en";
47
55
  }
48
- export function getLanguageDisplayName(code) {
49
- return LANGUAGE_NAMES[code] || code;
56
+ function getLanguageDisplayName(code) {
57
+ return constants_1.LANGUAGE_NAMES[code] || code;
50
58
  }
@@ -1,8 +1,24 @@
1
+ "use strict";
1
2
  /**
2
3
  * Translation Scripts
3
4
  * Scripts for translating and synchronizing localization files
4
5
  */
5
- export * from './translate';
6
- export * from './sync';
7
- export * from './setup';
8
- export * from './utils';
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ __exportStar(require("./translate"), exports);
22
+ __exportStar(require("./sync"), exports);
23
+ __exportStar(require("./setup"), exports);
24
+ __exportStar(require("./utils"), exports);
@@ -1,30 +1,37 @@
1
1
  #!/usr/bin/env node
2
+ "use strict";
2
3
  /**
3
4
  * Setup Languages Script
4
5
  * Creates stub files for all supported languages (if not exist),
5
6
  * then generates index.ts from all available translation files.
6
7
  * Usage: node setup.ts [locales-dir]
7
8
  */
8
- import fs from 'fs';
9
- import path from 'path';
10
- import { LANGUAGE_MAP, getLanguageDisplayName } from '../infrastructure/services';
11
- export function setupLanguages(options) {
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.setupLanguages = setupLanguages;
14
+ exports.runSetupLanguages = runSetupLanguages;
15
+ const fs_1 = __importDefault(require("fs"));
16
+ const path_1 = __importDefault(require("path"));
17
+ const services_1 = require("../infrastructure/services");
18
+ function setupLanguages(options) {
12
19
  const { targetDir } = options;
13
- const localesDir = path.resolve(process.cwd(), targetDir);
14
- if (!fs.existsSync(localesDir)) {
20
+ const localesDir = path_1.default.resolve(process.cwd(), targetDir);
21
+ if (!fs_1.default.existsSync(localesDir)) {
15
22
  console.error(`❌ Locales directory not found: ${localesDir}`);
16
23
  return false;
17
24
  }
18
25
  // Create stub files for all supported languages that don't exist yet
19
26
  let created = 0;
20
- for (const langCode of Object.keys(LANGUAGE_MAP)) {
27
+ for (const langCode of Object.keys(services_1.LANGUAGE_MAP)) {
21
28
  // Skip English variants — en-US is the base, others (en-AU, en-GB) are redundant
22
29
  if (langCode.startsWith('en-') && langCode !== 'en-US')
23
30
  continue;
24
- const filePath = path.join(localesDir, `${langCode}.ts`);
25
- if (!fs.existsSync(filePath)) {
26
- const langName = getLanguageDisplayName(langCode);
27
- fs.writeFileSync(filePath, `/**\n * ${langName} Translations\n * Auto-synced from en-US.ts\n */\n\nexport default {};\n`);
31
+ const filePath = path_1.default.join(localesDir, `${langCode}.ts`);
32
+ if (!fs_1.default.existsSync(filePath)) {
33
+ const langName = (0, services_1.getLanguageDisplayName)(langCode);
34
+ fs_1.default.writeFileSync(filePath, `/**\n * ${langName} Translations\n * Auto-synced from en-US.ts\n */\n\nexport default {};\n`);
28
35
  console.log(` ✅ Created ${langCode}.ts (${langName})`);
29
36
  created++;
30
37
  }
@@ -33,7 +40,7 @@ export function setupLanguages(options) {
33
40
  console.log(`\n📦 Created ${created} new language stubs.\n`);
34
41
  }
35
42
  // Generate index.ts from all language files
36
- const files = fs.readdirSync(localesDir)
43
+ const files = fs_1.default.readdirSync(localesDir)
37
44
  .filter(f => f.match(/^[a-z]{2}-[A-Z]{2}\.ts$/))
38
45
  .sort();
39
46
  const imports = [];
@@ -60,16 +67,17 @@ export type TranslationKey = keyof typeof translations;
60
67
 
61
68
  export default translations;
62
69
  `;
63
- fs.writeFileSync(path.join(localesDir, 'index.ts'), content);
70
+ fs_1.default.writeFileSync(path_1.default.join(localesDir, 'index.ts'), content);
64
71
  console.log(`✅ Generated index.ts with ${files.length} languages`);
65
72
  return true;
66
73
  }
67
74
  // CLI interface
68
- export function runSetupLanguages() {
75
+ function runSetupLanguages() {
69
76
  const targetDir = process.argv[2] || 'src/infrastructure/locales';
70
77
  console.log('🚀 Setting up language files...\n');
71
78
  setupLanguages({ targetDir });
72
79
  }
73
- if (import.meta.url === `file://${process.argv[1]}`) {
80
+ // Check if this file is being run directly
81
+ if (require.main === module || process.argv[1].endsWith('/setup.js') || process.argv[1].endsWith('\\setup.js')) {
74
82
  runSetupLanguages();
75
83
  }
@@ -1,33 +1,41 @@
1
1
  #!/usr/bin/env node
2
+ "use strict";
2
3
  /**
3
4
  * Sync Translations Script
4
5
  * Synchronizes translation keys from en-US.ts to all other language files
5
6
  */
6
- import fs from 'fs';
7
- import path from 'path';
8
- import { parseTypeScriptFile, generateTypeScriptContent, } from './utils/file-parser';
9
- import { addMissingKeys, removeExtraKeys, } from './utils/sync-helper';
10
- import { detectNewKeys } from './utils/key-detector';
11
- import { extractUsedKeys } from './utils/key-extractor';
12
- import { setDeep, countKeys } from './utils/object-helper';
13
- export function syncLanguageFile(enUSPath, targetPath, langCode) {
14
- const enUS = parseTypeScriptFile(enUSPath);
7
+ var __importDefault = (this && this.__importDefault) || function (mod) {
8
+ return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.syncLanguageFile = syncLanguageFile;
12
+ exports.syncTranslations = syncTranslations;
13
+ exports.runSyncTranslations = runSyncTranslations;
14
+ const fs_1 = __importDefault(require("fs"));
15
+ const path_1 = __importDefault(require("path"));
16
+ const file_parser_1 = require("./utils/file-parser");
17
+ const sync_helper_1 = require("./utils/sync-helper");
18
+ const key_detector_1 = require("./utils/key-detector");
19
+ const key_extractor_1 = require("./utils/key-extractor");
20
+ const object_helper_1 = require("./utils/object-helper");
21
+ function syncLanguageFile(enUSPath, targetPath, langCode) {
22
+ const enUS = (0, file_parser_1.parseTypeScriptFile)(enUSPath);
15
23
  let target;
16
24
  try {
17
- target = parseTypeScriptFile(targetPath);
25
+ target = (0, file_parser_1.parseTypeScriptFile)(targetPath);
18
26
  }
19
27
  catch {
20
28
  target = {};
21
29
  }
22
- const detectedNewKeys = detectNewKeys(enUS, target);
30
+ const detectedNewKeys = (0, key_detector_1.detectNewKeys)(enUS, target);
23
31
  const addStats = { added: 0, newKeys: [] };
24
32
  const removeStats = { removed: 0, removedKeys: [] };
25
- addMissingKeys(enUS, target, addStats);
26
- removeExtraKeys(enUS, target, removeStats);
33
+ (0, sync_helper_1.addMissingKeys)(enUS, target, addStats);
34
+ (0, sync_helper_1.removeExtraKeys)(enUS, target, removeStats);
27
35
  const changed = (addStats.added || 0) > 0 || (removeStats.removed || 0) > 0;
28
36
  if (changed) {
29
- const content = generateTypeScriptContent(target, langCode);
30
- fs.writeFileSync(targetPath, content);
37
+ const content = (0, file_parser_1.generateTypeScriptContent)(target, langCode);
38
+ fs_1.default.writeFileSync(targetPath, content);
31
39
  }
32
40
  return {
33
41
  added: addStats.added,
@@ -42,9 +50,9 @@ function processExtraction(srcDir, enUSPath) {
42
50
  if (!srcDir)
43
51
  return;
44
52
  console.log(`🔍 Scanning source code and dependencies: ${srcDir}...`);
45
- const usedKeyMap = extractUsedKeys(srcDir);
53
+ const usedKeyMap = (0, key_extractor_1.extractUsedKeys)(srcDir);
46
54
  console.log(` Found ${usedKeyMap.size} unique keys.`);
47
- const oldEnUS = parseTypeScriptFile(enUSPath);
55
+ const oldEnUS = (0, file_parser_1.parseTypeScriptFile)(enUSPath);
48
56
  const newEnUS = {};
49
57
  let addedCount = 0;
50
58
  for (const [key, defaultValue] of usedKeyMap) {
@@ -58,34 +66,34 @@ function processExtraction(srcDir, enUSPath) {
58
66
  // We treat it as "not translated" if the value is exactly the key string
59
67
  const isActuallyTranslated = typeof existingValue === 'string' && existingValue !== key;
60
68
  const valueToSet = isActuallyTranslated ? existingValue : defaultValue;
61
- if (setDeep(newEnUS, key, valueToSet)) {
69
+ if ((0, object_helper_1.setDeep)(newEnUS, key, valueToSet)) {
62
70
  if (!isActuallyTranslated)
63
71
  addedCount++;
64
72
  }
65
73
  }
66
- const oldTotal = countKeys(oldEnUS);
67
- const newTotal = countKeys(newEnUS);
74
+ const oldTotal = (0, object_helper_1.countKeys)(oldEnUS);
75
+ const newTotal = (0, object_helper_1.countKeys)(newEnUS);
68
76
  const removedCount = Math.max(0, oldTotal - (newTotal - addedCount));
69
77
  console.log(` ✨ Optimized en-US.ts: ${addedCount} keys populated/updated, pruned ${removedCount} unused.`);
70
- const content = generateTypeScriptContent(newEnUS, 'en-US');
71
- fs.writeFileSync(enUSPath, content);
78
+ const content = (0, file_parser_1.generateTypeScriptContent)(newEnUS, 'en-US');
79
+ fs_1.default.writeFileSync(enUSPath, content);
72
80
  }
73
- export function syncTranslations(options) {
81
+ function syncTranslations(options) {
74
82
  const { targetDir, srcDir } = options;
75
- const localesDir = path.resolve(process.cwd(), targetDir);
76
- const enUSPath = path.join(localesDir, 'en-US.ts');
77
- if (!fs.existsSync(localesDir) || !fs.existsSync(enUSPath)) {
83
+ const localesDir = path_1.default.resolve(process.cwd(), targetDir);
84
+ const enUSPath = path_1.default.join(localesDir, 'en-US.ts');
85
+ if (!fs_1.default.existsSync(localesDir) || !fs_1.default.existsSync(enUSPath)) {
78
86
  console.error(`❌ Localization files not found in: ${localesDir}`);
79
87
  return false;
80
88
  }
81
89
  processExtraction(srcDir, enUSPath);
82
- const files = fs.readdirSync(localesDir)
90
+ const files = fs_1.default.readdirSync(localesDir)
83
91
  .filter(f => f.match(/^[a-z]{2}-[A-Z]{2}\.ts$/) && f !== 'en-US.ts')
84
92
  .sort();
85
93
  console.log(`📊 Languages to sync: ${files.length}\n`);
86
94
  files.forEach(file => {
87
95
  const langCode = file.replace('.ts', '');
88
- const targetPath = path.join(localesDir, file);
96
+ const targetPath = path_1.default.join(localesDir, file);
89
97
  const result = syncLanguageFile(enUSPath, targetPath, langCode);
90
98
  if (result.changed) {
91
99
  console.log(` 🌍 ${langCode}: ✏️ +${result.added || 0} keys, -${result.removed || 0} keys`);
@@ -95,12 +103,13 @@ export function syncTranslations(options) {
95
103
  return true;
96
104
  }
97
105
  // CLI interface
98
- export function runSyncTranslations() {
106
+ function runSyncTranslations() {
99
107
  const targetDir = process.argv[2] || 'src/infrastructure/locales';
100
108
  const srcDir = process.argv[3];
101
109
  console.log('🚀 Starting translation synchronization...\n');
102
110
  syncTranslations({ targetDir, srcDir });
103
111
  }
104
- if (import.meta.url === `file://${process.argv[1]}`) {
112
+ // Check if this file is being run directly
113
+ if (require.main === module || process.argv[1].endsWith('/sync.js') || process.argv[1].endsWith('\\sync.js')) {
105
114
  runSyncTranslations();
106
115
  }
@@ -1,45 +1,52 @@
1
1
  #!/usr/bin/env node
2
+ "use strict";
2
3
  /**
3
4
  * Translate Missing Script
4
5
  * Automatically translates missing strings using Google Translate
5
6
  */
6
- import fs from 'fs';
7
- import path from 'path';
8
- import { parseTypeScriptFile, generateTypeScriptContent, } from './utils/file-parser';
9
- import { googleTranslateService, getTargetLanguage, getLanguageDisplayName } from '../infrastructure/services';
7
+ var __importDefault = (this && this.__importDefault) || function (mod) {
8
+ return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.translateMissing = translateMissing;
12
+ exports.runTranslateMissing = runTranslateMissing;
13
+ const fs_1 = __importDefault(require("fs"));
14
+ const path_1 = __importDefault(require("path"));
15
+ const file_parser_1 = require("./utils/file-parser");
16
+ const services_1 = require("../infrastructure/services");
10
17
  // Width of terminal line to clear for progress updates
11
18
  const PROGRESS_LINE_WIDTH = 80;
12
- export async function translateMissing(options) {
19
+ async function translateMissing(options) {
13
20
  const { targetDir, srcDir, skipSync = false } = options;
14
21
  // Initialize the translation service
15
- googleTranslateService.initialize({
22
+ services_1.googleTranslateService.initialize({
16
23
  minDelay: 100,
17
24
  maxRetries: 3,
18
25
  timeout: 10000,
19
26
  });
20
- const localesDir = path.resolve(process.cwd(), targetDir);
21
- const enUSPath = path.join(localesDir, 'en-US.ts');
22
- if (!fs.existsSync(localesDir) || !fs.existsSync(enUSPath)) {
27
+ const localesDir = path_1.default.resolve(process.cwd(), targetDir);
28
+ const enUSPath = path_1.default.join(localesDir, 'en-US.ts');
29
+ if (!fs_1.default.existsSync(localesDir) || !fs_1.default.existsSync(enUSPath)) {
23
30
  console.error(`❌ Localization files not found in: ${localesDir}`);
24
31
  return;
25
32
  }
26
- const files = fs.readdirSync(localesDir)
33
+ const files = fs_1.default.readdirSync(localesDir)
27
34
  .filter(f => f.match(/^[a-z]{2}-[A-Z]{2}\.ts$/) && f !== 'en-US.ts')
28
35
  .sort();
29
36
  console.log(`\n📊 Languages to translate: ${files.length}\n`);
30
- const enUS = parseTypeScriptFile(enUSPath);
37
+ const enUS = (0, file_parser_1.parseTypeScriptFile)(enUSPath);
31
38
  for (const file of files) {
32
39
  const langCode = file.replace('.ts', '');
33
40
  // Skip English variants
34
- const targetLang = getTargetLanguage(langCode);
41
+ const targetLang = (0, services_1.getTargetLanguage)(langCode);
35
42
  if (!targetLang || targetLang === 'en') {
36
43
  console.log(`⏭️ Skipping ${langCode} (English variant)`);
37
44
  continue;
38
45
  }
39
- const langName = getLanguageDisplayName(langCode);
46
+ const langName = (0, services_1.getLanguageDisplayName)(langCode);
40
47
  console.log(`🌍 Translating ${langCode} (${langName})...`);
41
- const targetPath = path.join(localesDir, file);
42
- const target = parseTypeScriptFile(targetPath);
48
+ const targetPath = path_1.default.join(localesDir, file);
49
+ const target = (0, file_parser_1.parseTypeScriptFile)(targetPath);
43
50
  const stats = {
44
51
  totalCount: 0,
45
52
  successCount: 0,
@@ -47,12 +54,12 @@ export async function translateMissing(options) {
47
54
  skippedCount: 0,
48
55
  translatedKeys: [],
49
56
  };
50
- await googleTranslateService.translateObject(enUS, target, targetLang, '', stats);
57
+ await services_1.googleTranslateService.translateObject(enUS, target, targetLang, '', stats);
51
58
  // Clear progress line
52
59
  process.stdout.write('\r' + ' '.repeat(PROGRESS_LINE_WIDTH) + '\r');
53
60
  if (stats.successCount > 0) {
54
- const content = generateTypeScriptContent(target, langCode);
55
- fs.writeFileSync(targetPath, content);
61
+ const content = (0, file_parser_1.generateTypeScriptContent)(target, langCode);
62
+ fs_1.default.writeFileSync(targetPath, content);
56
63
  console.log(` ✅ Successfully translated ${stats.successCount} keys:`);
57
64
  // Detailed logging of translated keys
58
65
  const displayCount = Math.min(stats.translatedKeys.length, 15);
@@ -70,7 +77,7 @@ export async function translateMissing(options) {
70
77
  console.log('\n✅ All translations completed!');
71
78
  }
72
79
  // CLI interface
73
- export function runTranslateMissing() {
80
+ function runTranslateMissing() {
74
81
  const args = process.argv.slice(2).filter(arg => !arg.startsWith('--'));
75
82
  const targetDir = args[0] || 'src/infrastructure/locales';
76
83
  const srcDir = args[1];
@@ -81,6 +88,7 @@ export function runTranslateMissing() {
81
88
  process.exit(1);
82
89
  });
83
90
  }
84
- if (import.meta.url === `file://${process.argv[1]}`) {
91
+ // Check if this file is being run directly
92
+ if (require.main === module || process.argv[1].endsWith('/translate.js') || process.argv[1].endsWith('\\translate.js')) {
85
93
  runTranslateMissing();
86
94
  }
@@ -1,12 +1,20 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import { getLanguageDisplayName } from '../../infrastructure/utils/textValidator.util';
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.parseTypeScriptFile = parseTypeScriptFile;
7
+ exports.stringifyValue = stringifyValue;
8
+ exports.generateTypeScriptContent = generateTypeScriptContent;
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const path_1 = __importDefault(require("path"));
11
+ const textValidator_util_1 = require("../../infrastructure/utils/textValidator.util");
4
12
  /**
5
13
  * File Parser
6
14
  * Parse and generate TypeScript translation files
7
15
  */
8
- export function parseTypeScriptFile(filePath) {
9
- const content = fs.readFileSync(filePath, 'utf8');
16
+ function parseTypeScriptFile(filePath) {
17
+ const content = fs_1.default.readFileSync(filePath, 'utf8');
10
18
  // Match: export default { ... } OR export const NAME = { ... }
11
19
  const match = content.match(/export\s+(?:default|const\s+\w+\s*=)\s*(\{[\s\S]*\});?\s*$/);
12
20
  if (!match) {
@@ -21,13 +29,13 @@ export function parseTypeScriptFile(filePath) {
21
29
  }
22
30
  catch (error) {
23
31
  // File might be a barrel file with named imports
24
- const dir = path.dirname(filePath);
32
+ const dir = path_1.default.dirname(filePath);
25
33
  const importMatches = [...content.matchAll(/import\s*\{\s*(\w+)\s*\}\s*from\s*["']\.\/(\w+)["']/g)];
26
34
  if (importMatches.length > 0) {
27
35
  const result = {};
28
36
  for (const [, varName, moduleName] of importMatches) {
29
- const subFilePath = path.join(dir, `${moduleName}.ts`);
30
- if (fs.existsSync(subFilePath)) {
37
+ const subFilePath = path_1.default.join(dir, `${moduleName}.ts`);
38
+ if (fs_1.default.existsSync(subFilePath)) {
31
39
  try {
32
40
  result[varName] = parseTypeScriptFile(subFilePath);
33
41
  }
@@ -44,7 +52,7 @@ export function parseTypeScriptFile(filePath) {
44
52
  }
45
53
  return {};
46
54
  }
47
- export function stringifyValue(value, indent = 2) {
55
+ function stringifyValue(value, indent = 2) {
48
56
  if (typeof value === 'string') {
49
57
  const escaped = value
50
58
  .replace(/\\/g, '\\\\')
@@ -76,8 +84,8 @@ export function stringifyValue(value, indent = 2) {
76
84
  }
77
85
  return String(value);
78
86
  }
79
- export function generateTypeScriptContent(obj, langCode) {
80
- const langName = getLanguageDisplayName(langCode);
87
+ function generateTypeScriptContent(obj, langCode) {
88
+ const langName = (0, textValidator_util_1.getLanguageDisplayName)(langCode);
81
89
  const isBase = langCode === 'en-US';
82
90
  const objString = stringifyValue(obj, 0);
83
91
  return `/**
@@ -1,9 +1,25 @@
1
+ "use strict";
1
2
  /**
2
3
  * Scripts Utils
3
4
  * Utility functions for translation scripts
4
5
  */
5
- export * from './file-parser';
6
- export * from './key-detector';
7
- export * from './key-extractor';
8
- export * from './object-helper';
9
- export * from './sync-helper';
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ __exportStar(require("./file-parser"), exports);
22
+ __exportStar(require("./key-detector"), exports);
23
+ __exportStar(require("./key-extractor"), exports);
24
+ __exportStar(require("./object-helper"), exports);
25
+ __exportStar(require("./sync-helper"), exports);
@@ -1,8 +1,12 @@
1
+ "use strict";
1
2
  /**
2
3
  * Key Detector
3
4
  * Detects new, missing, and removed keys between source and target objects
4
5
  */
5
- export function detectNewKeys(sourceObj, targetObj, path = '', newKeys = []) {
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.detectNewKeys = detectNewKeys;
8
+ exports.detectMissingKeys = detectMissingKeys;
9
+ function detectNewKeys(sourceObj, targetObj, path = '', newKeys = []) {
6
10
  for (const key in sourceObj) {
7
11
  const currentPath = path ? `${path}.${key}` : key;
8
12
  const sourceValue = sourceObj[key];
@@ -20,7 +24,7 @@ export function detectNewKeys(sourceObj, targetObj, path = '', newKeys = []) {
20
24
  }
21
25
  return newKeys;
22
26
  }
23
- export function detectMissingKeys(sourceObj, targetObj, path = '', missingKeys = []) {
27
+ function detectMissingKeys(sourceObj, targetObj, path = '', missingKeys = []) {
24
28
  for (const key in targetObj) {
25
29
  const currentPath = path ? `${path}.${key}` : key;
26
30
  if (!Object.prototype.hasOwnProperty.call(sourceObj, key)) {
@@ -1,5 +1,11 @@
1
- import fs from 'fs';
2
- import path from 'path';
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.extractUsedKeys = extractUsedKeys;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
3
9
  /**
4
10
  * Generic Key Extractor
5
11
  * Scans source code for i18n translation keys
@@ -61,34 +67,34 @@ function extractFromFile(content, keyMap) {
61
67
  }
62
68
  }
63
69
  function walkDirectory(dir, keyMap, skipDirs = ['node_modules', '.expo', '.git', 'build', 'ios', 'android', 'assets', 'locales', '__tests__']) {
64
- if (!fs.existsSync(dir))
70
+ if (!fs_1.default.existsSync(dir))
65
71
  return;
66
- const files = fs.readdirSync(dir);
72
+ const files = fs_1.default.readdirSync(dir);
67
73
  for (const file of files) {
68
- const fullPath = path.join(dir, file);
69
- const stat = fs.statSync(fullPath);
74
+ const fullPath = path_1.default.join(dir, file);
75
+ const stat = fs_1.default.statSync(fullPath);
70
76
  if (stat.isDirectory()) {
71
77
  if (!skipDirs.includes(file)) {
72
78
  walkDirectory(fullPath, keyMap, skipDirs);
73
79
  }
74
80
  }
75
81
  else if (/\.(ts|tsx|js|jsx)$/.test(file)) {
76
- const content = fs.readFileSync(fullPath, 'utf8');
82
+ const content = fs_1.default.readFileSync(fullPath, 'utf8');
77
83
  extractFromFile(content, keyMap);
78
84
  }
79
85
  }
80
86
  }
81
- export function extractUsedKeys(srcDir) {
87
+ function extractUsedKeys(srcDir) {
82
88
  const keyMap = new Map();
83
89
  if (!srcDir)
84
90
  return keyMap;
85
91
  const projectRoot = process.cwd();
86
- const absoluteSrcDir = path.resolve(projectRoot, srcDir);
92
+ const absoluteSrcDir = path_1.default.resolve(projectRoot, srcDir);
87
93
  // Scan project source
88
94
  walkDirectory(absoluteSrcDir, keyMap);
89
95
  // Scan @umituz packages for shared keys
90
- const packagesDir = path.resolve(projectRoot, 'node_modules/@umituz');
91
- if (fs.existsSync(packagesDir)) {
96
+ const packagesDir = path_1.default.resolve(projectRoot, 'node_modules/@umituz');
97
+ if (fs_1.default.existsSync(packagesDir)) {
92
98
  walkDirectory(packagesDir, keyMap);
93
99
  }
94
100
  return keyMap;
@@ -1,12 +1,16 @@
1
+ "use strict";
1
2
  /**
2
3
  * Object Helper
3
4
  * Utilities for deep object manipulation
4
5
  */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.setDeep = setDeep;
8
+ exports.countKeys = countKeys;
5
9
  /**
6
10
  * Set a value in a nested object, creating intermediate objects if necessary
7
11
  * Returns true if the key was newly added, false if it already existed
8
12
  */
9
- export function setDeep(obj, path, value) {
13
+ function setDeep(obj, path, value) {
10
14
  const keys = path.split('.');
11
15
  let current = obj;
12
16
  for (let i = 0; i < keys.length - 1; i++) {
@@ -26,7 +30,7 @@ export function setDeep(obj, path, value) {
26
30
  /**
27
31
  * Count all leaf keys in a nested object
28
32
  */
29
- export function countKeys(obj) {
33
+ function countKeys(obj) {
30
34
  let count = 0;
31
35
  const walk = (o) => {
32
36
  for (const k in o) {
@@ -1,8 +1,12 @@
1
+ "use strict";
1
2
  /**
2
3
  * Sync Helper
3
4
  * Helper functions for synchronizing translation keys
4
5
  */
5
- export function addMissingKeys(sourceObj, targetObj, stats = {}) {
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.addMissingKeys = addMissingKeys;
8
+ exports.removeExtraKeys = removeExtraKeys;
9
+ function addMissingKeys(sourceObj, targetObj, stats = {}) {
6
10
  stats.added = stats.added || 0;
7
11
  stats.newKeys = stats.newKeys || [];
8
12
  for (const key in sourceObj) {
@@ -24,7 +28,7 @@ export function addMissingKeys(sourceObj, targetObj, stats = {}) {
24
28
  }
25
29
  return stats;
26
30
  }
27
- export function removeExtraKeys(sourceObj, targetObj, stats = {}) {
31
+ function removeExtraKeys(sourceObj, targetObj, stats = {}) {
28
32
  stats.removed = stats.removed || 0;
29
33
  stats.removedKeys = stats.removedKeys || [];
30
34
  for (const key in targetObj) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-google-translate",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Google Translate integration for React Native apps with rate limiting, batch translation, and TypeScript support",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -90,6 +90,7 @@ export function runSetupLanguages(): void {
90
90
  setupLanguages({ targetDir });
91
91
  }
92
92
 
93
- if (import.meta.url === `file://${process.argv[1]}`) {
93
+ // Check if this file is being run directly
94
+ if (require.main === module || process.argv[1].endsWith('/setup.js') || process.argv[1].endsWith('\\setup.js')) {
94
95
  runSetupLanguages();
95
96
  }
@@ -148,6 +148,7 @@ export function runSyncTranslations(): void {
148
148
  syncTranslations({ targetDir, srcDir });
149
149
  }
150
150
 
151
- if (import.meta.url === `file://${process.argv[1]}`) {
151
+ // Check if this file is being run directly
152
+ if (require.main === module || process.argv[1].endsWith('/sync.js') || process.argv[1].endsWith('\\sync.js')) {
152
153
  runSyncTranslations();
153
154
  }
@@ -121,6 +121,7 @@ export function runTranslateMissing(): void {
121
121
  });
122
122
  }
123
123
 
124
- if (import.meta.url === `file://${process.argv[1]}`) {
124
+ // Check if this file is being run directly
125
+ if (require.main === module || process.argv[1].endsWith('/translate.js') || process.argv[1].endsWith('\\translate.js')) {
125
126
  runTranslateMissing();
126
127
  }