@localheroai/cli 0.0.70 → 0.0.71-rc.1
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/dist/utils/translation-utils.js +11 -11
- package/dist/utils/translation-utils.js.map +1 -1
- package/package.json +1 -1
- package/dist/api/auth.d.ts +0 -2
- package/dist/api/client.d.ts +0 -3
- package/dist/api/imports.d.ts +0 -5
- package/dist/api/projects.d.ts +0 -2
- package/dist/api/translation-jobs.js +0 -28
- package/dist/api/translation-jobs.js.map +0 -1
- package/dist/api/translations.d.ts +0 -15
- package/dist/cli.d.ts +0 -2
- package/dist/commands/_sync.js +0 -22
- package/dist/commands/_sync.js.map +0 -1
- package/dist/commands/_translate.js +0 -3
- package/dist/commands/_translate.js.map +0 -1
- package/dist/commands/github-action.js +0 -111
- package/dist/commands/github-action.js.map +0 -1
- package/dist/commands/init.d.ts +0 -1
- package/dist/commands/login.d.ts +0 -16
- package/dist/commands/sync.d.ts +0 -20
- package/dist/commands/sync.js +0 -22
- package/dist/commands/sync.js.map +0 -1
- package/dist/commands/translate.d.ts +0 -14
- package/dist/index.d.ts +0 -5
- package/dist/types/index.d.ts +0 -75
- package/dist/types/translate/index.js +0 -2
- package/dist/types/translate/index.js.map +0 -1
- package/dist/utils/auth.d.ts +0 -2
- package/dist/utils/chunked-json-processor.js +0 -52
- package/dist/utils/chunked-json-processor.js.map +0 -1
- package/dist/utils/common.js +0 -9
- package/dist/utils/common.js.map +0 -1
- package/dist/utils/config.d.ts +0 -23
- package/dist/utils/errors.js +0 -37
- package/dist/utils/errors.js.map +0 -1
- package/dist/utils/files.d.ts +0 -32
- package/dist/utils/git-diff.js +0 -251
- package/dist/utils/git-diff.js.map +0 -1
- package/dist/utils/git.d.ts +0 -21
- package/dist/utils/github.d.ts +0 -241
- package/dist/utils/import-service.d.ts +0 -4
- package/dist/utils/po-utils-fallback.js +0 -254
- package/dist/utils/po-utils-fallback.js.map +0 -1
- package/dist/utils/prompt-service.d.ts +0 -44
- package/dist/utils/streaming-json-processor.js +0 -125
- package/dist/utils/streaming-json-processor.js.map +0 -1
- package/dist/utils/sync-service.d.ts +0 -58
- package/dist/utils/translation-updater/common.d.ts +0 -6
- package/dist/utils/translation-updater/index.d.ts +0 -5
- package/dist/utils/translation-updater/json-handler.d.ts +0 -5
- package/dist/utils/translation-updater/yaml-handler.d.ts +0 -5
- package/dist/utils/translation-utils.d.ts +0 -30
- package/dist/utils/updater.js +0 -38
- package/dist/utils/updater.js.map +0 -1
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import { po } from 'gettext-parser';
|
|
2
|
-
import { createUniqueKey, parseUniqueKey, parsePoFile, normalizeStringValue, PLURAL_SUFFIX } from './po-utils.js';
|
|
3
|
-
/**
|
|
4
|
-
* Build a map of msgid_plural values to check for duplicates
|
|
5
|
-
*/
|
|
6
|
-
function buildPluralFormsMap(parsed) {
|
|
7
|
-
const pluralForms = new Map();
|
|
8
|
-
Object.entries(parsed.translations).forEach(([context, entries]) => {
|
|
9
|
-
if (typeof entries === 'object' && entries !== null) {
|
|
10
|
-
Object.entries(entries).forEach(([msgid, entry]) => {
|
|
11
|
-
if (msgid === '' || !entry.msgid_plural)
|
|
12
|
-
return;
|
|
13
|
-
// Map the plural form to its context and original msgid
|
|
14
|
-
const pluralKey = createUniqueKey(entry.msgid_plural, context !== '' ? context : undefined);
|
|
15
|
-
pluralForms.set(pluralKey, { context, msgid });
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
return pluralForms;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Check if a key is a plural suffix key
|
|
23
|
-
*/
|
|
24
|
-
function isPluralKey(key) {
|
|
25
|
-
return key.endsWith(PLURAL_SUFFIX);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Get the base key from a plural suffix key
|
|
29
|
-
*/
|
|
30
|
-
function getBaseKeyFromPlural(key) {
|
|
31
|
-
return key.replace(/__plural_\d+$/, '');
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Group plural translations together
|
|
35
|
-
*/
|
|
36
|
-
function groupPluralTranslations(translations) {
|
|
37
|
-
const regular = {};
|
|
38
|
-
const pluralGroups = new Map();
|
|
39
|
-
// First pass: identify plural pairs
|
|
40
|
-
Object.keys(translations).forEach(key => {
|
|
41
|
-
if (isPluralKey(key)) {
|
|
42
|
-
const baseKey = getBaseKeyFromPlural(key);
|
|
43
|
-
if (translations[baseKey]) {
|
|
44
|
-
// This is a plural pair
|
|
45
|
-
pluralGroups.set(baseKey, {
|
|
46
|
-
singular: translations[baseKey],
|
|
47
|
-
plural: translations[key]
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
// Second pass: add regular keys (excluding those in plural pairs)
|
|
53
|
-
Object.entries(translations).forEach(([key, value]) => {
|
|
54
|
-
if (!isPluralKey(key) && !pluralGroups.has(key)) {
|
|
55
|
-
regular[key] = value;
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
return { regular, pluralGroups };
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Detect the fold length used in the original .po file by analyzing line lengths
|
|
62
|
-
* Returns the detected fold length, or 76 (gettext default) if no clear pattern
|
|
63
|
-
*/
|
|
64
|
-
function detectFoldLength(content) {
|
|
65
|
-
const lines = content.split('\n');
|
|
66
|
-
const quotedLines = lines.filter(line => line.trim().startsWith('"') && line.trim().endsWith('"'));
|
|
67
|
-
if (quotedLines.length < 5) {
|
|
68
|
-
return 76; // Use gettext default
|
|
69
|
-
}
|
|
70
|
-
// Check if the file has multiline strings (indicates intentional wrapping)
|
|
71
|
-
const hasMultilineStrings = lines.some(line => line.trim() === 'msgid ""' || line.trim() === 'msgstr ""');
|
|
72
|
-
if (!hasMultilineStrings) {
|
|
73
|
-
return 76; // Use default for simple files
|
|
74
|
-
}
|
|
75
|
-
// Find the longest line length - this represents the wrap point used
|
|
76
|
-
const maxLength = Math.max(...quotedLines.map(line => line.length));
|
|
77
|
-
// If the longest line is in a reasonable range, use it
|
|
78
|
-
// Otherwise fall back to gettext standard
|
|
79
|
-
if (maxLength >= 70 && maxLength <= 100) {
|
|
80
|
-
return maxLength;
|
|
81
|
-
}
|
|
82
|
-
return 76; // gettext default
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Old implementation of updatePoFile for fallback when new entries need to be added
|
|
86
|
-
*/
|
|
87
|
-
export function updatePoFileOld(originalContent, translations, options) {
|
|
88
|
-
const parsed = po.parse(originalContent);
|
|
89
|
-
const updatedTranslations = new Set();
|
|
90
|
-
const pluralFormsMap = buildPluralFormsMap(parsed);
|
|
91
|
-
let hasChanges = false;
|
|
92
|
-
const { regular, pluralGroups } = groupPluralTranslations(translations);
|
|
93
|
-
Object.entries(parsed.translations).forEach(([context, entries]) => {
|
|
94
|
-
if (typeof entries === 'object' && entries !== null) {
|
|
95
|
-
Object.entries(entries).forEach(([msgid, entry]) => {
|
|
96
|
-
if (msgid === '')
|
|
97
|
-
return; // Skip header
|
|
98
|
-
const uniqueKey = createUniqueKey(msgid, context !== '' ? context : undefined);
|
|
99
|
-
// Check if this is a plural entry (either complete pair or partial)
|
|
100
|
-
if (entry.msgid_plural) {
|
|
101
|
-
const isCompletePair = pluralGroups.has(uniqueKey);
|
|
102
|
-
const hasSingularOnly = regular[uniqueKey];
|
|
103
|
-
if (isCompletePair) {
|
|
104
|
-
const pluralData = pluralGroups.get(uniqueKey);
|
|
105
|
-
const singularValue = pluralData.singular;
|
|
106
|
-
const currentValue = entry.msgstr[0] || '';
|
|
107
|
-
// Skip updating only if this is a source language entry and values match AND current value is not empty
|
|
108
|
-
const skipSingular = (singularValue === msgid && options?.sourceLanguage === options?.targetLanguage && currentValue.trim() !== '');
|
|
109
|
-
if (!skipSingular && currentValue.trim() !== singularValue.trim()) {
|
|
110
|
-
entry.msgstr[0] = singularValue;
|
|
111
|
-
hasChanges = true;
|
|
112
|
-
}
|
|
113
|
-
const pluralValue = pluralData.plural;
|
|
114
|
-
const currentPluralValue = entry.msgstr[1] || '';
|
|
115
|
-
// Skip updating only if this is a source language entry and values match AND current value is not empty
|
|
116
|
-
const skipPlural = (pluralValue === entry.msgid_plural && options?.sourceLanguage === options?.targetLanguage && currentPluralValue.trim() !== '');
|
|
117
|
-
if (!skipPlural && currentPluralValue.trim() !== pluralValue.trim()) {
|
|
118
|
-
entry.msgstr[1] = pluralValue;
|
|
119
|
-
hasChanges = true;
|
|
120
|
-
}
|
|
121
|
-
updatedTranslations.add(uniqueKey);
|
|
122
|
-
updatedTranslations.add(uniqueKey + PLURAL_SUFFIX);
|
|
123
|
-
}
|
|
124
|
-
else if (hasSingularOnly) {
|
|
125
|
-
// Handle partial plural translation (singular only)
|
|
126
|
-
const singularValue = regular[uniqueKey];
|
|
127
|
-
const currentValue = entry.msgstr[0] || '';
|
|
128
|
-
// Skip updating only if this is a source language entry and values match AND current value is not empty
|
|
129
|
-
const skipSingular = (singularValue === msgid && options?.sourceLanguage === options?.targetLanguage && currentValue.trim() !== '');
|
|
130
|
-
if (!skipSingular && currentValue.trim() !== singularValue.trim()) {
|
|
131
|
-
entry.msgstr[0] = singularValue;
|
|
132
|
-
hasChanges = true;
|
|
133
|
-
}
|
|
134
|
-
updatedTranslations.add(uniqueKey);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
else if (regular[uniqueKey]) {
|
|
138
|
-
const newValue = regular[uniqueKey];
|
|
139
|
-
// Skip updating if this is a source language entry (msgid === msgstr)
|
|
140
|
-
if (newValue === msgid && options?.sourceLanguage === options?.targetLanguage) {
|
|
141
|
-
updatedTranslations.add(uniqueKey);
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
const currentValue = normalizeStringValue(entry.msgstr);
|
|
145
|
-
const normalizedNewValue = normalizeStringValue(newValue);
|
|
146
|
-
// Only update if the normalized content is actually different
|
|
147
|
-
// This prevents unnecessary line wrapping changes
|
|
148
|
-
if (currentValue !== normalizedNewValue) {
|
|
149
|
-
entry.msgstr = [newValue];
|
|
150
|
-
hasChanges = true;
|
|
151
|
-
}
|
|
152
|
-
updatedTranslations.add(uniqueKey);
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
// Add new translations that weren't found in existing entries
|
|
158
|
-
// But skip plural suffix keys - they should not be added as separate entries
|
|
159
|
-
Object.entries(regular).forEach(([uniqueKey, value]) => {
|
|
160
|
-
if (!updatedTranslations.has(uniqueKey)) {
|
|
161
|
-
const { msgid, context } = parseUniqueKey(uniqueKey);
|
|
162
|
-
const contextKey = context || '';
|
|
163
|
-
// this can happen with malformed keys
|
|
164
|
-
if (!msgid || msgid.trim() === '') {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
// Skip adding new entries where msgid === msgstr (source language files only)
|
|
168
|
-
if (value === msgid && options?.sourceLanguage === options?.targetLanguage) {
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
// Skip if this msgid is already used as msgid_plural in an existing entry
|
|
172
|
-
if (pluralFormsMap.has(uniqueKey)) {
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
// Initialize context if it doesn't exist
|
|
176
|
-
if (!parsed.translations[contextKey]) {
|
|
177
|
-
parsed.translations[contextKey] = {};
|
|
178
|
-
}
|
|
179
|
-
parsed.translations[contextKey][msgid] = {
|
|
180
|
-
msgid: msgid,
|
|
181
|
-
msgstr: [value]
|
|
182
|
-
};
|
|
183
|
-
hasChanges = true;
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
// Add new plural translations that weren't found in existing entries
|
|
187
|
-
pluralGroups.forEach((pluralData, uniqueKey) => {
|
|
188
|
-
if (!updatedTranslations.has(uniqueKey)) {
|
|
189
|
-
const { msgid, context } = parseUniqueKey(uniqueKey);
|
|
190
|
-
const contextKey = context || '';
|
|
191
|
-
// this can happen with malformed keys
|
|
192
|
-
if (!msgid || msgid.trim() === '') {
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
const pluralKey = uniqueKey + PLURAL_SUFFIX;
|
|
196
|
-
// Try to find the proper msgid_plural from the source file if available
|
|
197
|
-
let msgid_plural = pluralData.plural; // fallback
|
|
198
|
-
if (options?.sourceContent) {
|
|
199
|
-
try {
|
|
200
|
-
const sourceParsed = parsePoFile(options.sourceContent);
|
|
201
|
-
const sourceEntries = sourceParsed.entries;
|
|
202
|
-
// Find the matching source entry with msgid_plural
|
|
203
|
-
const sourceEntry = sourceEntries.find(entry => {
|
|
204
|
-
const sourceKey = createUniqueKey(entry.msgid, entry.msgctxt);
|
|
205
|
-
return sourceKey === uniqueKey && entry.msgid_plural;
|
|
206
|
-
});
|
|
207
|
-
if (sourceEntry && sourceEntry.msgid_plural) {
|
|
208
|
-
msgid_plural = sourceEntry.msgid_plural;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
catch (error) {
|
|
212
|
-
// If source parsing fails, continue with fallback
|
|
213
|
-
console.warn('Failed to parse source content for msgid_plural lookup', error);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
// Initialize context if it doesn't exist
|
|
217
|
-
if (!parsed.translations[contextKey]) {
|
|
218
|
-
parsed.translations[contextKey] = {};
|
|
219
|
-
}
|
|
220
|
-
// Create new plural entry with proper msgid_plural
|
|
221
|
-
parsed.translations[contextKey][msgid] = {
|
|
222
|
-
msgid: msgid,
|
|
223
|
-
msgid_plural: msgid_plural,
|
|
224
|
-
msgstr: [pluralData.singular, pluralData.plural]
|
|
225
|
-
};
|
|
226
|
-
hasChanges = true;
|
|
227
|
-
// Mark both keys as updated
|
|
228
|
-
updatedTranslations.add(uniqueKey);
|
|
229
|
-
updatedTranslations.add(pluralKey);
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
// If no actual changes were made, return original content to preserve formatting
|
|
233
|
-
if (!hasChanges) {
|
|
234
|
-
return originalContent;
|
|
235
|
-
}
|
|
236
|
-
// Extract header section from original content
|
|
237
|
-
const lines = originalContent.split('\n');
|
|
238
|
-
const headerEndIndex = lines.findIndex((line, index) => index > 0 && line.trim() === '' && lines[index - 1].includes('"'));
|
|
239
|
-
let headerSection = '';
|
|
240
|
-
if (headerEndIndex > 0) {
|
|
241
|
-
headerSection = lines.slice(0, headerEndIndex + 1).join('\n') + '\n';
|
|
242
|
-
}
|
|
243
|
-
// Use detected fold length from original content
|
|
244
|
-
const foldLength = detectFoldLength(originalContent);
|
|
245
|
-
const compiled = po.compile(parsed, { foldLength }).toString();
|
|
246
|
-
const compiledLines = compiled.split('\n');
|
|
247
|
-
const compiledHeaderEndIndex = compiledLines.findIndex((line, index) => index > 0 && line.trim() === '' && compiledLines[index - 1].includes('"'));
|
|
248
|
-
if (headerSection && compiledHeaderEndIndex > 0) {
|
|
249
|
-
const bodySection = compiledLines.slice(compiledHeaderEndIndex + 1).join('\n');
|
|
250
|
-
return headerSection + bodySection;
|
|
251
|
-
}
|
|
252
|
-
return compiled;
|
|
253
|
-
}
|
|
254
|
-
//# sourceMappingURL=po-utils-fallback.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"po-utils-fallback.js","sourceRoot":"","sources":["../../src/utils/po-utils-fallback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAElH;;GAEG;AACH,SAAS,mBAAmB,CAAC,MAAW;IACtC,MAAM,WAAW,GAAG,IAAI,GAAG,EAA8C,CAAC;IAE1E,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,EAAE;QACjE,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACpD,MAAM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,CAAC,eAAe,CAAC,CAAC;IACrD,MAAM,QAAQ,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC/D,MAAM,aAAa,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3C,MAAM,sBAAsB,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACrE,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,aAAa,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAC1E,CAAC;IAEF,IAAI,aAAa,IAAI,sBAAsB,GAAG,CAAC,EAAE,CAAC;QAChD,MAAM,WAAW,GAAG,aAAa,CAAC,KAAK,CAAC,sBAAsB,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/E,OAAO,aAAa,GAAG,WAAW,CAAC;IACrC,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
interface ProjectService {
|
|
2
|
-
listProjects: () => Promise<Array<{
|
|
3
|
-
id: string;
|
|
4
|
-
name: string;
|
|
5
|
-
}>>;
|
|
6
|
-
}
|
|
7
|
-
interface ProjectSetup {
|
|
8
|
-
projectName: string;
|
|
9
|
-
sourceLocale: string;
|
|
10
|
-
outputLocales: string[];
|
|
11
|
-
translationPath: string;
|
|
12
|
-
ignorePaths: string[];
|
|
13
|
-
}
|
|
14
|
-
interface ProjectSelection {
|
|
15
|
-
choice: string;
|
|
16
|
-
project?: {
|
|
17
|
-
id: string;
|
|
18
|
-
name: string;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
export declare function createPromptService(deps?: {
|
|
22
|
-
inquirer?: any;
|
|
23
|
-
}): {
|
|
24
|
-
getApiKey: () => Promise<string>;
|
|
25
|
-
getProjectSetup: () => Promise<ProjectSetup>;
|
|
26
|
-
select: <T>(options: {
|
|
27
|
-
message: string;
|
|
28
|
-
choices: Array<{
|
|
29
|
-
name: string;
|
|
30
|
-
value: T;
|
|
31
|
-
disabled?: boolean;
|
|
32
|
-
}>;
|
|
33
|
-
}) => Promise<T>;
|
|
34
|
-
input: (options: {
|
|
35
|
-
message: string;
|
|
36
|
-
default?: string;
|
|
37
|
-
}) => Promise<string>;
|
|
38
|
-
confirm: (options: {
|
|
39
|
-
message: string;
|
|
40
|
-
default?: boolean;
|
|
41
|
-
}) => Promise<boolean>;
|
|
42
|
-
selectProject: (projectService: ProjectService) => Promise<ProjectSelection>;
|
|
43
|
-
};
|
|
44
|
-
export {};
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { createReadStream } from 'fs';
|
|
2
|
-
import { JSONParser } from '@streamparser/json';
|
|
3
|
-
import { flattenTranslations } from './files.js';
|
|
4
|
-
import { FILE_SIZE_LIMITS } from './file-size.js';
|
|
5
|
-
const DEFAULT_CHUNK_SIZE = 1000;
|
|
6
|
-
export async function processLargeJsonFileStreaming(filePath, options = {}) {
|
|
7
|
-
const { chunkSize = DEFAULT_CHUNK_SIZE, onProgress, onChunk, maxMemoryAccumulation = 50 * 1024 * 1024 // 50MB default limit
|
|
8
|
-
} = options;
|
|
9
|
-
let accumulator = {};
|
|
10
|
-
let currentChunk = {};
|
|
11
|
-
let totalKeys = 0;
|
|
12
|
-
let chunksProcessed = 0;
|
|
13
|
-
let estimatedMemoryUsage = 0;
|
|
14
|
-
return new Promise((resolve, reject) => {
|
|
15
|
-
const parser = new JSONParser();
|
|
16
|
-
const stream = createReadStream(filePath);
|
|
17
|
-
parser.onValue = async (data) => {
|
|
18
|
-
try {
|
|
19
|
-
const { value, key, stack } = data;
|
|
20
|
-
// Only process top-level key-value pairs (stack length 1 means direct child of root)
|
|
21
|
-
if (stack && stack.length === 1 && typeof key === 'string') {
|
|
22
|
-
currentChunk[key] = value;
|
|
23
|
-
totalKeys++;
|
|
24
|
-
if (Object.keys(currentChunk).length >= chunkSize) {
|
|
25
|
-
if (onChunk) {
|
|
26
|
-
// Use callback mode - don't accumulate in memory
|
|
27
|
-
const flattened = flattenTranslations(currentChunk);
|
|
28
|
-
await onChunk(flattened);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
// Check memory usage before accumulating
|
|
32
|
-
const chunkMemorySize = estimateObjectSize(currentChunk);
|
|
33
|
-
if (estimatedMemoryUsage + chunkMemorySize > maxMemoryAccumulation) {
|
|
34
|
-
const error = new Error(`Memory limit exceeded: Estimated usage ${Math.round((estimatedMemoryUsage + chunkMemorySize) / 1024 / 1024)}MB > limit ${Math.round(maxMemoryAccumulation / 1024 / 1024)}MB. Consider using onChunk callback for large files.`);
|
|
35
|
-
reject(error);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
await processChunk(currentChunk, accumulator);
|
|
39
|
-
estimatedMemoryUsage += chunkMemorySize;
|
|
40
|
-
}
|
|
41
|
-
chunksProcessed++;
|
|
42
|
-
if (onProgress) {
|
|
43
|
-
onProgress(totalKeys);
|
|
44
|
-
}
|
|
45
|
-
currentChunk = {};
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
const wrappedError = new Error(`Error processing chunk: ${error.message}`);
|
|
51
|
-
wrappedError.cause = error;
|
|
52
|
-
reject(wrappedError);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
parser.onEnd = async () => {
|
|
56
|
-
try {
|
|
57
|
-
if (Object.keys(currentChunk).length > 0) {
|
|
58
|
-
if (onChunk) {
|
|
59
|
-
const flattened = flattenTranslations(currentChunk);
|
|
60
|
-
await onChunk(flattened);
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
await processChunk(currentChunk, accumulator);
|
|
64
|
-
}
|
|
65
|
-
chunksProcessed++;
|
|
66
|
-
}
|
|
67
|
-
if (onProgress) {
|
|
68
|
-
onProgress(totalKeys, totalKeys);
|
|
69
|
-
}
|
|
70
|
-
resolve({
|
|
71
|
-
translations: accumulator,
|
|
72
|
-
isStreamed: true,
|
|
73
|
-
totalKeys,
|
|
74
|
-
chunksProcessed
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
const wrappedError = new Error(`Error processing final chunk: ${error.message}`);
|
|
79
|
-
wrappedError.cause = error;
|
|
80
|
-
reject(wrappedError);
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
parser.onError = (error) => {
|
|
84
|
-
const wrappedError = new Error(`Streaming parser error: ${error.message}`);
|
|
85
|
-
wrappedError.cause = error;
|
|
86
|
-
reject(wrappedError);
|
|
87
|
-
};
|
|
88
|
-
stream.on('error', (error) => {
|
|
89
|
-
const wrappedError = new Error(`File read error: ${error.message}`);
|
|
90
|
-
wrappedError.cause = error;
|
|
91
|
-
reject(wrappedError);
|
|
92
|
-
});
|
|
93
|
-
stream.on('data', (chunk) => {
|
|
94
|
-
parser.write(chunk);
|
|
95
|
-
});
|
|
96
|
-
stream.on('end', () => {
|
|
97
|
-
parser.end();
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
async function processChunk(chunk, accumulator) {
|
|
102
|
-
const flattened = flattenTranslations(chunk);
|
|
103
|
-
Object.assign(accumulator, flattened);
|
|
104
|
-
}
|
|
105
|
-
function estimateObjectSize(obj) {
|
|
106
|
-
// Rough estimation of object memory usage in bytes
|
|
107
|
-
let size = 0;
|
|
108
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
109
|
-
size += key.length * 2; // String keys (UTF-16)
|
|
110
|
-
if (typeof value === 'string') {
|
|
111
|
-
size += value.length * 2; // String values (UTF-16)
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
size += JSON.stringify(value).length * 2; // Approximate for other types
|
|
115
|
-
}
|
|
116
|
-
size += 32; // Object overhead per property
|
|
117
|
-
}
|
|
118
|
-
return size;
|
|
119
|
-
}
|
|
120
|
-
export function shouldUseStreamingProcessing(fileSize, format) {
|
|
121
|
-
return format === 'json' &&
|
|
122
|
-
fileSize > FILE_SIZE_LIMITS.CHUNKING_THRESHOLD &&
|
|
123
|
-
fileSize <= FILE_SIZE_LIMITS.MAX_SIZE;
|
|
124
|
-
}
|
|
125
|
-
//# sourceMappingURL=streaming-json-processor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"streaming-json-processor.js","sourceRoot":"","sources":["../../src/utils/streaming-json-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,IAAI,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAgBlD,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAEhC,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,QAAgB,EAChB,UAAsC,EAAE;IAExC,MAAM,EACJ,SAAS,GAAG,kBAAkB,EAC9B,UAAU,EACV,OAAO,EACP,qBAAqB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,qBAAqB;MAC/D,GAAG,OAAO,CAAC;IAEZ,IAAI,WAAW,GAAwB,EAAE,CAAC;IAC1C,IAAI,YAAY,GAAwB,EAAE,CAAC;IAC3C,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,eAAe,GAAG,CAAC,CAAC;IACxB,IAAI,oBAAoB,GAAG,CAAC,CAAC;IAE7B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAChC,MAAM,MAAM,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAE1C,MAAM,CAAC,OAAO,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BAAyB;QACrD,CAAC;aAAM,CAAC;YACN,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,8BAA8B;QAC1E,CAAC;QACD,IAAI,IAAI,EAAE,CAAC,CAAC,+BAA+B;IAC7C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,QAAgB,EAAE,MAAc;IAC3E,OAAO,MAAM,KAAK,MAAM;QACjB,QAAQ,GAAG,gBAAgB,CAAC,kBAAkB;QAC9C,QAAQ,IAAI,gBAAgB,CAAC,QAAQ,CAAC;AAC/C,CAAC"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
export interface SyncOptions {
|
|
2
|
-
verbose?: boolean;
|
|
3
|
-
}
|
|
4
|
-
export interface Translation {
|
|
5
|
-
key: string;
|
|
6
|
-
value: string;
|
|
7
|
-
}
|
|
8
|
-
export interface Language {
|
|
9
|
-
code: string;
|
|
10
|
-
translations: Translation[];
|
|
11
|
-
}
|
|
12
|
-
export interface FileUpdate {
|
|
13
|
-
path: string;
|
|
14
|
-
languages: Language[];
|
|
15
|
-
}
|
|
16
|
-
export interface DeletedKey {
|
|
17
|
-
name: string;
|
|
18
|
-
}
|
|
19
|
-
export interface PaginationInfo {
|
|
20
|
-
current_page: number;
|
|
21
|
-
total_pages: number;
|
|
22
|
-
}
|
|
23
|
-
export interface UpdateResponse {
|
|
24
|
-
updates?: {
|
|
25
|
-
updated_keys?: FileUpdate[];
|
|
26
|
-
deleted_keys?: DeletedKey[];
|
|
27
|
-
};
|
|
28
|
-
pagination?: PaginationInfo;
|
|
29
|
-
}
|
|
30
|
-
export interface UpdatesContainer {
|
|
31
|
-
updates: {
|
|
32
|
-
files: FileUpdate[];
|
|
33
|
-
deleted_keys: DeletedKey[];
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
export interface CheckUpdatesResult {
|
|
37
|
-
hasUpdates: boolean;
|
|
38
|
-
updates?: UpdatesContainer;
|
|
39
|
-
}
|
|
40
|
-
export interface TranslationFile {
|
|
41
|
-
path: string;
|
|
42
|
-
locale: string;
|
|
43
|
-
}
|
|
44
|
-
export interface SourceFile {
|
|
45
|
-
path: string;
|
|
46
|
-
}
|
|
47
|
-
export interface FindTranslationFilesResult {
|
|
48
|
-
sourceFiles: SourceFile[];
|
|
49
|
-
[key: string]: any;
|
|
50
|
-
}
|
|
51
|
-
export interface SyncResult {
|
|
52
|
-
totalUpdates: number;
|
|
53
|
-
totalDeleted: number;
|
|
54
|
-
}
|
|
55
|
-
export declare const syncService: {
|
|
56
|
-
checkForUpdates({ verbose }?: SyncOptions): Promise<CheckUpdatesResult>;
|
|
57
|
-
applyUpdates(updates: UpdatesContainer, { verbose }?: SyncOptions): Promise<SyncResult>;
|
|
58
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export function fileExists(filePath: any): Promise<boolean>;
|
|
2
|
-
export function ensureDirectoryExists(filePath: any): Promise<void>;
|
|
3
|
-
export function tryParseJsonArray(value: any): any[] | null;
|
|
4
|
-
export const SPECIAL_CHARS_REGEX: RegExp;
|
|
5
|
-
export const INTERPOLATION: "%{";
|
|
6
|
-
export const MAX_ARRAY_LENGTH: 1000;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export function updateTranslationFile(filePath: any, translations: any, languageCode?: string, sourceFilePath?: null): Promise<{
|
|
2
|
-
updatedKeys: string[];
|
|
3
|
-
created: boolean;
|
|
4
|
-
}>;
|
|
5
|
-
export function deleteKeysFromTranslationFile(filePath: any, keysToDelete: any, languageCode?: string): Promise<any[]>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export function updateJsonFile(filePath: any, translations: any, languageCode: any, sourceFilePath?: null): Promise<{
|
|
2
|
-
updatedKeys: string[];
|
|
3
|
-
created: boolean;
|
|
4
|
-
}>;
|
|
5
|
-
export function deleteKeysFromJsonFile(filePath: any, keysToDelete: any, languageCode: any): Promise<any[]>;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export function findMissingTranslations(sourceKeys: any, targetKeys: any): {
|
|
2
|
-
missingKeys: {};
|
|
3
|
-
skippedKeys: {};
|
|
4
|
-
};
|
|
5
|
-
export function batchKeysWithMissing(sourceFiles: any, missingByLocale: any, batchSize?: number): {
|
|
6
|
-
batches: {
|
|
7
|
-
sourceFilePath: string;
|
|
8
|
-
sourceFile: {
|
|
9
|
-
path: any;
|
|
10
|
-
format: any;
|
|
11
|
-
content: string;
|
|
12
|
-
};
|
|
13
|
-
localeEntries: any;
|
|
14
|
-
locales: any[];
|
|
15
|
-
}[];
|
|
16
|
-
errors: {
|
|
17
|
-
type: string;
|
|
18
|
-
message: string;
|
|
19
|
-
path: string;
|
|
20
|
-
}[];
|
|
21
|
-
};
|
|
22
|
-
export function findTargetFile(targetFiles: any, targetLocale: any, sourceFile: any, sourceLocale: any): any;
|
|
23
|
-
export function generateTargetPath(sourceFile: any, targetLocale: any, sourceLocale: any): string;
|
|
24
|
-
export function processTargetContent(targetContent: any, targetLocale: any): {};
|
|
25
|
-
export function processLocaleTranslations(sourceKeys: any, targetLocale: any, targetFiles: any, sourceFile: any, sourceLocale: any): {
|
|
26
|
-
targetPath: string;
|
|
27
|
-
missingKeys: {};
|
|
28
|
-
skippedKeys: {};
|
|
29
|
-
targetFile: any;
|
|
30
|
-
};
|
package/dist/utils/updater.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { readTranslationFile } from './files.js';
|
|
2
|
-
import { updateTranslationFile } from './translation-updater/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* Apply translation updates to files
|
|
5
|
-
* @param files Array of translation files to update
|
|
6
|
-
* @returns Result of the update operation
|
|
7
|
-
*/
|
|
8
|
-
export async function applyTranslationUpdates(files) {
|
|
9
|
-
const errors = [];
|
|
10
|
-
try {
|
|
11
|
-
for (const file of files) {
|
|
12
|
-
try {
|
|
13
|
-
const currentFile = await readTranslationFile(file.path);
|
|
14
|
-
await updateTranslationFile(file.path, file.translations || {}, file.locale, currentFile.path);
|
|
15
|
-
}
|
|
16
|
-
catch (error) {
|
|
17
|
-
errors.push({
|
|
18
|
-
path: file.path,
|
|
19
|
-
message: error instanceof Error ? error.message : String(error)
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return {
|
|
24
|
-
success: errors.length === 0,
|
|
25
|
-
errors: errors.length > 0 ? errors : undefined
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
return {
|
|
30
|
-
success: false,
|
|
31
|
-
errors: [{
|
|
32
|
-
path: 'unknown',
|
|
33
|
-
message: error instanceof Error ? error.message : String(error)
|
|
34
|
-
}]
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=updater.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"updater.js","sourceRoot":"","sources":["../../src/utils/updater.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAOvE;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,KAAwB;IACpE,MAAM,MAAM,GAA6C,EAAE,CAAC;IAE5D,IAAI,CAAC;QACH,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC;gBACH,MAAM,WAAW,GAAG,MAAM,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACzD,MAAM,qBAAqB,CACzB,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,YAAY,IAAI,EAAE,EACvB,IAAI,CAAC,MAAM,EACX,WAAW,CAAC,IAAI,CACjB,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,CAAC,IAAI,CAAC;oBACV,IAAI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