gtx-cli 2.0.19 → 2.0.21

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # gtx-cli
2
2
 
3
+ ## 2.0.21
4
+
5
+ ### Patch Changes
6
+
7
+ - [#524](https://github.com/generaltranslation/gt/pull/524) [`39b36e5`](https://github.com/generaltranslation/gt/commit/39b36e56f50fff663826c66022d798147a622898) Thanks [@brian-lou](https://github.com/brian-lou)! - Add support for translating YAML files via the General Translation API
8
+
9
+ ## 2.0.20
10
+
11
+ ### Patch Changes
12
+
13
+ - [#521](https://github.com/generaltranslation/gt/pull/521) [`6b137bc`](https://github.com/generaltranslation/gt/commit/6b137bcf0b2aaf50adacd5fb03ed64525fb12473) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - refactor: add support for experimental flags in config file
14
+
3
15
  ## 2.0.19
4
16
 
5
17
  ### Patch Changes
@@ -27,9 +27,9 @@ export async function downloadFile(translationId, outputPath, inputPath, locale,
27
27
  }
28
28
  let data = new TextDecoder().decode(fileData);
29
29
  if (options.options?.jsonSchema && locale) {
30
- const jsonSchema = validateJsonSchema(options.options, outputPath);
30
+ const jsonSchema = validateJsonSchema(options.options, inputPath);
31
31
  if (jsonSchema) {
32
- const originalContent = fs.readFileSync(outputPath, 'utf8');
32
+ const originalContent = fs.readFileSync(inputPath, 'utf8');
33
33
  if (originalContent) {
34
34
  data = mergeJson(originalContent, inputPath, options.options, [
35
35
  {
@@ -41,11 +41,11 @@ export async function downloadFile(translationId, outputPath, inputPath, locale,
41
41
  }
42
42
  }
43
43
  if (options.options?.yamlSchema && locale) {
44
- const yamlSchema = validateYamlSchema(options.options, outputPath);
44
+ const yamlSchema = validateYamlSchema(options.options, inputPath);
45
45
  if (yamlSchema) {
46
- const originalContent = fs.readFileSync(outputPath, 'utf8');
46
+ const originalContent = fs.readFileSync(inputPath, 'utf8');
47
47
  if (originalContent) {
48
- data = mergeYaml(originalContent, outputPath, options.options, [
48
+ data = mergeYaml(originalContent, inputPath, options.options, [
49
49
  {
50
50
  translatedContent: data,
51
51
  targetLocale: locale,
package/dist/cli/base.js CHANGED
@@ -284,6 +284,7 @@ See the docs for more information: https://generaltranslation.com/docs/react/tut
284
284
  { value: 'mdx', label: FILE_EXT_TO_EXT_LABEL.mdx },
285
285
  { value: 'ts', label: FILE_EXT_TO_EXT_LABEL.ts },
286
286
  { value: 'js', label: FILE_EXT_TO_EXT_LABEL.js },
287
+ { value: 'yaml', label: FILE_EXT_TO_EXT_LABEL.yaml },
287
288
  ],
288
289
  required: !isUsingGT,
289
290
  });
@@ -76,7 +76,7 @@ export async function generateSettings(options, cwd = process.cwd()) {
76
76
  }
77
77
  }
78
78
  // merge options
79
- const mergedOptions = { ...gtConfig, ...options };
79
+ let mergedOptions = { ...gtConfig, ...options };
80
80
  // merge locales
81
81
  mergedOptions.locales = Array.from(new Set([...(gtConfig.locales || []), ...(options.locales || [])]));
82
82
  // Add apiKey if not provided
@@ -107,6 +107,13 @@ export async function generateSettings(options, cwd = process.cwd()) {
107
107
  mergedOptions.files = mergedOptions.files
108
108
  ? resolveFiles(mergedOptions.files, mergedOptions.defaultLocale, mergedOptions.locales, cwd)
109
109
  : undefined;
110
+ mergedOptions = {
111
+ ...mergedOptions,
112
+ experimentalLocalizeStaticImports: gtConfig.options?.experimentalLocalizeStaticImports,
113
+ experimentalLocalizeStaticUrls: gtConfig.options?.experimentalLocalizeStaticUrls,
114
+ experimentalHideDefaultLocale: gtConfig.options?.experimentalHideDefaultLocale,
115
+ experimentalFlattenJsonFiles: gtConfig.options?.experimentalFlattenJsonFiles,
116
+ };
110
117
  // Add additional options if provided
111
118
  if (mergedOptions.options) {
112
119
  if (mergedOptions.options.jsonSchema) {
@@ -50,12 +50,12 @@ export async function translateFiles(filePaths, placeholderPaths, transformPaths
50
50
  }
51
51
  const yamlFiles = filePaths.yaml.map((filePath) => {
52
52
  const content = readFile(filePath);
53
- const parsedYaml = parseYaml(content, filePath, additionalOptions);
53
+ const { content: parsedYaml, fileFormat } = parseYaml(content, filePath, additionalOptions);
54
54
  const relativePath = getRelative(filePath);
55
55
  return {
56
56
  content: parsedYaml,
57
57
  fileName: relativePath,
58
- fileFormat: 'JSON', // Translate as a JSON file
58
+ fileFormat,
59
59
  dataFormat,
60
60
  };
61
61
  });
@@ -51,12 +51,12 @@ export async function upload(filePaths, placeholderPaths, transformPaths, dataFo
51
51
  }
52
52
  const yamlFiles = filePaths.yaml.map((filePath) => {
53
53
  const content = readFile(filePath);
54
- const parsedYaml = parseYaml(content, filePath, additionalOptions);
54
+ const { content: parsedYaml, fileFormat } = parseYaml(content, filePath, additionalOptions);
55
55
  const relativePath = getRelative(filePath);
56
56
  return {
57
57
  content: parsedYaml,
58
58
  fileName: relativePath,
59
- fileFormat: 'JSON', // Translate as a JSON file
59
+ fileFormat,
60
60
  dataFormat,
61
61
  locale: options.defaultLocale,
62
62
  };
@@ -1,2 +1,5 @@
1
1
  import { AdditionalOptions } from '../../types/index.js';
2
- export default function parseYaml(content: string, filePath: string, options: AdditionalOptions): string;
2
+ export default function parseYaml(content: string, filePath: string, options: AdditionalOptions): {
3
+ content: string;
4
+ fileFormat: 'JSON' | 'YAML';
5
+ };
@@ -5,7 +5,7 @@ import { flattenJsonWithStringFilter } from '../json/flattenJson.js';
5
5
  export default function parseYaml(content, filePath, options) {
6
6
  const yamlSchema = validateYamlSchema(options, filePath);
7
7
  if (!yamlSchema) {
8
- return content;
8
+ return { content, fileFormat: 'YAML' };
9
9
  }
10
10
  let yaml;
11
11
  try {
@@ -17,7 +17,7 @@ export default function parseYaml(content, filePath, options) {
17
17
  }
18
18
  if (yamlSchema.include) {
19
19
  const flattenedYaml = flattenJsonWithStringFilter(yaml, yamlSchema.include);
20
- return JSON.stringify(flattenedYaml);
20
+ return { content: JSON.stringify(flattenedYaml), fileFormat: 'JSON' };
21
21
  }
22
- return content;
22
+ return { content, fileFormat: 'YAML' };
23
23
  }
@@ -110,6 +110,10 @@ export type AdditionalOptions = {
110
110
  docsImportPattern?: string;
111
111
  docsHideDefaultLocaleImport?: boolean;
112
112
  copyFiles?: string[];
113
+ experimentalLocalizeStaticImports?: boolean;
114
+ experimentalLocalizeStaticUrls?: boolean;
115
+ experimentalHideDefaultLocale?: boolean;
116
+ experimentalFlattenJsonFiles?: boolean;
113
117
  };
114
118
  export type JsonSchema = {
115
119
  preset?: 'mintlify';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gtx-cli",
3
- "version": "2.0.19",
3
+ "version": "2.0.21",
4
4
  "main": "dist/index.js",
5
5
  "bin": "dist/main.js",
6
6
  "files": [