gtx-cli 1.2.25-alpha.11 → 1.2.25-alpha.12
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/api/sendFiles.d.ts +3 -3
- package/dist/api/sendFiles.js +1 -1
- package/dist/api/sendUpdates.d.ts +2 -2
- package/dist/api/sendUpdates.js +2 -2
- package/dist/cli/base.js +7 -7
- package/dist/formats/files/save.d.ts +2 -2
- package/dist/formats/files/save.js +2 -2
- package/dist/formats/files/translate.d.ts +3 -3
- package/dist/formats/files/translate.js +5 -5
- package/dist/formats/gt/save.d.ts +2 -2
- package/dist/formats/gt/save.js +2 -2
- package/dist/react/jsx/parse/parseStringFunction.js +1 -1
- package/dist/react/jsx/utils/parseJsx.js +1 -1
- package/dist/react/jsx/utils/parseStringFunction.js +1 -1
- package/dist/react/parse/createDictionaryUpdates.js +2 -2
- package/dist/react/parse/createInlineUpdates.js +1 -1
- package/dist/translation/stage.js +1 -1
- package/dist/types/data.d.ts +1 -1
- package/dist/types/index.d.ts +3 -3
- package/package.json +2 -2
package/dist/api/sendFiles.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Settings } from '../types';
|
|
2
|
-
import { FileExtension,
|
|
2
|
+
import { FileExtension, DataFormat } from '../types/data';
|
|
3
3
|
/**
|
|
4
4
|
* File object structure
|
|
5
5
|
* @param content - The content of the file
|
|
6
6
|
* @param fileName - The name of the file
|
|
7
7
|
* @param fileExtension - The format of the file (JSON, MDX, MD, etc.)
|
|
8
|
-
* @param
|
|
8
|
+
* @param dataFormat - The format of the data within the file
|
|
9
9
|
*/
|
|
10
10
|
export interface FileToTranslate {
|
|
11
11
|
content: string;
|
|
12
12
|
fileName: string;
|
|
13
13
|
fileExtension: FileExtension;
|
|
14
|
-
|
|
14
|
+
dataFormat: DataFormat;
|
|
15
15
|
}
|
|
16
16
|
type ApiOptions = Settings & {
|
|
17
17
|
publish: boolean;
|
package/dist/api/sendFiles.js
CHANGED
|
@@ -26,7 +26,7 @@ async function sendFiles(files, options) {
|
|
|
26
26
|
files.forEach((file, index) => {
|
|
27
27
|
formData.append(`file${index}`, new Blob([file.content]), file.fileName);
|
|
28
28
|
formData.append(`fileExtension${index}`, file.fileExtension);
|
|
29
|
-
formData.append(`
|
|
29
|
+
formData.append(`dataFormat${index}`, file.dataFormat); // Only used when translating JSON files
|
|
30
30
|
formData.append(`fileName${index}`, file.fileName);
|
|
31
31
|
});
|
|
32
32
|
// Add number of files
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Settings, SupportedLibraries, Updates } from '../types';
|
|
2
|
-
import {
|
|
2
|
+
import { DataFormat } from '../types/data';
|
|
3
3
|
type ApiOptions = Settings & {
|
|
4
4
|
timeout: string;
|
|
5
|
-
|
|
5
|
+
dataFormat: DataFormat;
|
|
6
6
|
description?: string;
|
|
7
7
|
requireApproval?: boolean;
|
|
8
8
|
};
|
package/dist/api/sendUpdates.js
CHANGED
|
@@ -15,7 +15,7 @@ const utils_1 = require("../config/utils");
|
|
|
15
15
|
* @returns The versionId of the updated project
|
|
16
16
|
*/
|
|
17
17
|
async function sendUpdates(updates, options, library) {
|
|
18
|
-
const { apiKey, projectId, defaultLocale,
|
|
18
|
+
const { apiKey, projectId, defaultLocale, dataFormat } = options;
|
|
19
19
|
const globalMetadata = {
|
|
20
20
|
...(projectId && { projectId }),
|
|
21
21
|
...(defaultLocale && { sourceLocale: defaultLocale }),
|
|
@@ -27,7 +27,7 @@ async function sendUpdates(updates, options, library) {
|
|
|
27
27
|
updates,
|
|
28
28
|
...(options.locales && { locales: options.locales }),
|
|
29
29
|
metadata: globalMetadata,
|
|
30
|
-
...(
|
|
30
|
+
...(dataFormat && { dataFormat }),
|
|
31
31
|
...(options.version && { versionId: options.version }),
|
|
32
32
|
...(options.description && { description: options.description }),
|
|
33
33
|
...(options.requireApproval && {
|
package/dist/cli/base.js
CHANGED
|
@@ -187,21 +187,21 @@ See the docs for more information: https://generaltranslation.com/docs/react/tut
|
|
|
187
187
|
});
|
|
188
188
|
}
|
|
189
189
|
async handleGenericTranslate(settings) {
|
|
190
|
-
//
|
|
191
|
-
let
|
|
190
|
+
// dataFormat for JSONs
|
|
191
|
+
let dataFormat;
|
|
192
192
|
if (this.library === 'next-intl') {
|
|
193
|
-
|
|
193
|
+
dataFormat = 'ICU';
|
|
194
194
|
}
|
|
195
195
|
else if (this.library === 'i18next') {
|
|
196
196
|
if (this.additionalModules.includes('i18next-icu')) {
|
|
197
|
-
|
|
197
|
+
dataFormat = 'ICU';
|
|
198
198
|
}
|
|
199
199
|
else {
|
|
200
|
-
|
|
200
|
+
dataFormat = 'I18NEXT';
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
else {
|
|
204
|
-
|
|
204
|
+
dataFormat = 'JSX';
|
|
205
205
|
}
|
|
206
206
|
if (!settings.files ||
|
|
207
207
|
(Object.keys(settings.files.placeholderPaths).length === 1 &&
|
|
@@ -210,7 +210,7 @@ See the docs for more information: https://generaltranslation.com/docs/react/tut
|
|
|
210
210
|
}
|
|
211
211
|
const { resolvedPaths: sourceFiles, placeholderPaths, transformPaths, } = settings.files;
|
|
212
212
|
// Process all file types at once with a single call
|
|
213
|
-
await (0, translate_1.translateFiles)(sourceFiles, placeholderPaths, transformPaths,
|
|
213
|
+
await (0, translate_1.translateFiles)(sourceFiles, placeholderPaths, transformPaths, dataFormat, settings);
|
|
214
214
|
}
|
|
215
215
|
async handleSetupReactCommand(options) {
|
|
216
216
|
await (0, wizard_1.handleSetupReactCommand)(options);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DataFormat } from '../../types/data';
|
|
2
2
|
/**
|
|
3
3
|
* Saves translated MDX/MD file content to the appropriate location
|
|
4
4
|
*/
|
|
5
|
-
export declare function saveTranslatedFile(translatedContent: string, outputDir: string, fileName: string,
|
|
5
|
+
export declare function saveTranslatedFile(translatedContent: string, outputDir: string, fileName: string, dataFormat: DataFormat, locales: string[]): Promise<void>;
|
|
@@ -10,7 +10,7 @@ const console_1 = require("../../console");
|
|
|
10
10
|
/**
|
|
11
11
|
* Saves translated MDX/MD file content to the appropriate location
|
|
12
12
|
*/
|
|
13
|
-
async function saveTranslatedFile(translatedContent, outputDir, fileName,
|
|
13
|
+
async function saveTranslatedFile(translatedContent, outputDir, fileName, dataFormat, locales) {
|
|
14
14
|
// Create locale-specific directories if they don't exist
|
|
15
15
|
for (const locale of locales) {
|
|
16
16
|
const localeDir = node_path_1.default.join(outputDir, locale);
|
|
@@ -18,6 +18,6 @@ async function saveTranslatedFile(translatedContent, outputDir, fileName, format
|
|
|
18
18
|
// Save the translated file with the appropriate extension
|
|
19
19
|
const outputPath = node_path_1.default.join(localeDir, fileName);
|
|
20
20
|
await promises_1.default.writeFile(outputPath, translatedContent);
|
|
21
|
-
(0, console_1.logSuccess)(`Saved translated ${
|
|
21
|
+
(0, console_1.logSuccess)(`Saved translated ${dataFormat} file to: ${outputPath}`);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ResolvedFiles, Settings, TransformFiles } from '../../types';
|
|
2
|
-
import {
|
|
2
|
+
import { DataFormat } from '../../types/data';
|
|
3
3
|
import { TranslateOptions } from '../../cli/base';
|
|
4
4
|
/**
|
|
5
5
|
* Sends multiple files to the API for translation
|
|
6
6
|
* @param filePaths - Resolved file paths for different file types
|
|
7
7
|
* @param placeholderPaths - Placeholder paths for translated files
|
|
8
8
|
* @param transformPaths - Transform paths for file naming
|
|
9
|
-
* @param
|
|
9
|
+
* @param dataFormat - Format of the data within the files
|
|
10
10
|
* @param options - Translation options including API settings
|
|
11
11
|
* @returns Promise that resolves when translation is complete
|
|
12
12
|
*/
|
|
13
|
-
export declare function translateFiles(filePaths: ResolvedFiles, placeholderPaths: ResolvedFiles, transformPaths: TransformFiles,
|
|
13
|
+
export declare function translateFiles(filePaths: ResolvedFiles, placeholderPaths: ResolvedFiles, transformPaths: TransformFiles, dataFormat: DataFormat | undefined, options: Settings & TranslateOptions): Promise<void>;
|
|
@@ -21,16 +21,16 @@ const SUPPORTED_FORMATS = ['JSX', 'ICU', 'I18NEXT'];
|
|
|
21
21
|
* @param filePaths - Resolved file paths for different file types
|
|
22
22
|
* @param placeholderPaths - Placeholder paths for translated files
|
|
23
23
|
* @param transformPaths - Transform paths for file naming
|
|
24
|
-
* @param
|
|
24
|
+
* @param dataFormat - Format of the data within the files
|
|
25
25
|
* @param options - Translation options including API settings
|
|
26
26
|
* @returns Promise that resolves when translation is complete
|
|
27
27
|
*/
|
|
28
|
-
async function translateFiles(filePaths, placeholderPaths, transformPaths,
|
|
28
|
+
async function translateFiles(filePaths, placeholderPaths, transformPaths, dataFormat = 'JSX', options) {
|
|
29
29
|
// Collect all files to translate
|
|
30
30
|
const allFiles = [];
|
|
31
31
|
// Process JSON files
|
|
32
32
|
if (filePaths.json) {
|
|
33
|
-
if (!SUPPORTED_FORMATS.includes(
|
|
33
|
+
if (!SUPPORTED_FORMATS.includes(dataFormat)) {
|
|
34
34
|
(0, console_1.logErrorAndExit)(console_1.noSupportedFormatError);
|
|
35
35
|
}
|
|
36
36
|
const jsonFiles = filePaths.json.map((filePath) => {
|
|
@@ -43,7 +43,7 @@ async function translateFiles(filePaths, placeholderPaths, transformPaths, forma
|
|
|
43
43
|
content,
|
|
44
44
|
fileName: relativePath,
|
|
45
45
|
fileExtension: 'JSON',
|
|
46
|
-
|
|
46
|
+
dataFormat,
|
|
47
47
|
};
|
|
48
48
|
});
|
|
49
49
|
allFiles.push(...jsonFiles);
|
|
@@ -59,7 +59,7 @@ async function translateFiles(filePaths, placeholderPaths, transformPaths, forma
|
|
|
59
59
|
content,
|
|
60
60
|
fileName: relativePath,
|
|
61
61
|
fileExtension: fileType.toUpperCase(),
|
|
62
|
-
|
|
62
|
+
dataFormat,
|
|
63
63
|
};
|
|
64
64
|
});
|
|
65
65
|
allFiles.push(...files);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { RetrievedTranslations } from '../../types/api';
|
|
2
2
|
import { ResolvedFiles } from '../../types';
|
|
3
|
-
import {
|
|
3
|
+
import { DataFormat } from '../../types/data';
|
|
4
4
|
/**
|
|
5
5
|
* Saves translations to a local directory
|
|
6
6
|
* @param translations - The translations to save
|
|
7
7
|
* @param translationsDir - The directory to save the translations to
|
|
8
8
|
* @param fileType - The file type to save the translations as (file extension)
|
|
9
9
|
*/
|
|
10
|
-
export declare function saveTranslations(translations: RetrievedTranslations, placeholderPaths: ResolvedFiles,
|
|
10
|
+
export declare function saveTranslations(translations: RetrievedTranslations, placeholderPaths: ResolvedFiles, dataFormat: DataFormat): Promise<void>;
|
package/dist/formats/gt/save.js
CHANGED
|
@@ -14,7 +14,7 @@ const parseFilesConfig_1 = require("../../fs/config/parseFilesConfig");
|
|
|
14
14
|
* @param translationsDir - The directory to save the translations to
|
|
15
15
|
* @param fileType - The file type to save the translations as (file extension)
|
|
16
16
|
*/
|
|
17
|
-
async function saveTranslations(translations, placeholderPaths,
|
|
17
|
+
async function saveTranslations(translations, placeholderPaths, dataFormat) {
|
|
18
18
|
for (const translation of translations) {
|
|
19
19
|
const locale = translation.locale;
|
|
20
20
|
const translationFiles = (0, parseFilesConfig_1.resolveLocaleFiles)(placeholderPaths, locale);
|
|
@@ -27,7 +27,7 @@ async function saveTranslations(translations, placeholderPaths, format) {
|
|
|
27
27
|
// Ensure directory exists
|
|
28
28
|
await node_fs_1.default.promises.mkdir(node_path_1.default.dirname(filepath), { recursive: true });
|
|
29
29
|
// Handle different file types
|
|
30
|
-
if (
|
|
30
|
+
if (dataFormat === 'JSX') {
|
|
31
31
|
await node_fs_1.default.promises.writeFile(filepath, JSON.stringify(translationData, null, 2));
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -63,11 +63,11 @@ async function createDictionaryUpdates(options, dictionaryPath, esbuildConfig) {
|
|
|
63
63
|
source: entry,
|
|
64
64
|
...(context && { context }),
|
|
65
65
|
...(id && { id }),
|
|
66
|
-
|
|
66
|
+
dataFormat: 'ICU',
|
|
67
67
|
}),
|
|
68
68
|
};
|
|
69
69
|
updates.push({
|
|
70
|
-
|
|
70
|
+
dataFormat: 'ICU',
|
|
71
71
|
source: entry,
|
|
72
72
|
metadata,
|
|
73
73
|
});
|
|
@@ -132,7 +132,7 @@ async function createInlineUpdates(options, pkg) {
|
|
|
132
132
|
source: update.source,
|
|
133
133
|
...(context && { context }),
|
|
134
134
|
...(update.metadata.id && { id: update.metadata.id }),
|
|
135
|
-
|
|
135
|
+
dataFormat: update.dataFormat,
|
|
136
136
|
});
|
|
137
137
|
update.metadata.hash = hash;
|
|
138
138
|
}));
|
|
@@ -73,7 +73,7 @@ async function stageProject(settings, pkg) {
|
|
|
73
73
|
const updateResponse = await (0, sendUpdates_1.sendUpdates)(updates, {
|
|
74
74
|
...settings,
|
|
75
75
|
timeout: settings.timeout,
|
|
76
|
-
|
|
76
|
+
dataFormat: 'JSX',
|
|
77
77
|
}, pkg);
|
|
78
78
|
const { versionId, locales } = updateResponse;
|
|
79
79
|
return { versionId, locales };
|
package/dist/types/data.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type JSONDictionary = {
|
|
|
17
17
|
export type FlattenedJSONDictionary = {
|
|
18
18
|
[key: string]: string;
|
|
19
19
|
};
|
|
20
|
-
export type
|
|
20
|
+
export type DataFormat = 'JSX' | 'ICU' | 'I18NEXT';
|
|
21
21
|
export type FileExtension = 'JSON' | 'YAML' | 'MDX' | 'MD' | 'TS' | 'JS';
|
|
22
22
|
export type JsxChildren = string | string[] | any;
|
|
23
23
|
export type Translations = {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,13 +3,13 @@ import { SUPPORTED_FILE_EXTENSIONS } from '../formats/files/supportedFiles';
|
|
|
3
3
|
export type Updates = ({
|
|
4
4
|
metadata: Record<string, any>;
|
|
5
5
|
} & ({
|
|
6
|
-
|
|
6
|
+
dataFormat: 'JSX';
|
|
7
7
|
source: JsxChildren;
|
|
8
8
|
} | {
|
|
9
|
-
|
|
9
|
+
dataFormat: 'ICU';
|
|
10
10
|
source: string;
|
|
11
11
|
} | {
|
|
12
|
-
|
|
12
|
+
dataFormat: 'I18NEXT';
|
|
13
13
|
source: string;
|
|
14
14
|
}))[];
|
|
15
15
|
export type Options = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gtx-cli",
|
|
3
|
-
"version": "1.2.25-alpha.
|
|
3
|
+
"version": "1.2.25-alpha.12",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"bin": "dist/main.js",
|
|
6
6
|
"files": [
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"esbuild": "^0.25.4",
|
|
80
80
|
"fast-glob": "^3.3.3",
|
|
81
81
|
"form-data": "^4.0.2",
|
|
82
|
-
"generaltranslation": "^7.0.0-alpha.
|
|
82
|
+
"generaltranslation": "^7.0.0-alpha.12",
|
|
83
83
|
"open": "^10.1.1",
|
|
84
84
|
"ora": "^8.2.0",
|
|
85
85
|
"resolve": "^1.22.10",
|