gtx-cli 2.0.0 → 2.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # gtx-cli
2
2
 
3
+ ## 2.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#440](https://github.com/generaltranslation/gt/pull/440) [`e6fdedf`](https://github.com/generaltranslation/gt/commit/e6fdedffcdfbac5d257ea35140cbb81de6aa2729) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - fixes to breaking changes
8
+
9
+ - Updated dependencies [[`e6fdedf`](https://github.com/generaltranslation/gt/commit/e6fdedffcdfbac5d257ea35140cbb81de6aa2729)]:
10
+ - generaltranslation@7.0.1
11
+
3
12
  ## 2.0.0
4
13
 
5
14
  ### Major Changes
@@ -1,5 +1,5 @@
1
1
  import { Settings } from '../types/index.js';
2
- import { FileExtension, DataFormat } from '../types/data.js';
2
+ import { FileFormat, DataFormat } from '../types/data.js';
3
3
  /**
4
4
  * File object structure
5
5
  * @param content - The content of the file
@@ -10,7 +10,7 @@ import { FileExtension, DataFormat } from '../types/data.js';
10
10
  export interface FileToTranslate {
11
11
  content: string;
12
12
  fileName: string;
13
- fileExtension: FileExtension;
13
+ fileFormat: FileFormat;
14
14
  dataFormat: DataFormat;
15
15
  }
16
16
  type ApiOptions = Settings & {
@@ -19,8 +19,8 @@ export async function sendFiles(files, options) {
19
19
  // Add each file to the form data
20
20
  files.forEach((file, index) => {
21
21
  formData.append(`file${index}`, new Blob([file.content]), file.fileName);
22
- formData.append(`fileExtension${index}`, file.fileExtension);
23
- formData.append(`dataFormat${index}`, file.dataFormat); // Only used when translating JSON files
22
+ formData.append(`fileFormat${index}`, file.fileFormat);
23
+ formData.append(`fileDataFormat${index}`, file.dataFormat);
24
24
  formData.append(`fileName${index}`, file.fileName);
25
25
  });
26
26
  // Add number of files
@@ -38,7 +38,7 @@ export async function translateFiles(filePaths, placeholderPaths, transformPaths
38
38
  return {
39
39
  content,
40
40
  fileName: relativePath,
41
- fileExtension: 'JSON',
41
+ fileFormat: 'JSON',
42
42
  dataFormat,
43
43
  };
44
44
  });
@@ -55,7 +55,7 @@ export async function translateFiles(filePaths, placeholderPaths, transformPaths
55
55
  return {
56
56
  content: sanitizedContent,
57
57
  fileName: relativePath,
58
- fileExtension: fileType.toUpperCase(),
58
+ fileFormat: fileType.toUpperCase(),
59
59
  dataFormat,
60
60
  };
61
61
  });
@@ -1,4 +1,5 @@
1
1
  export declare const GT_TRANSLATION_FUNCS: string[];
2
2
  export declare const VARIABLE_COMPONENTS: string[];
3
+ export declare const GT_ATTRIBUTES_WITH_SUGAR: string[];
3
4
  export declare const GT_ATTRIBUTES: string[];
4
5
  export declare function mapAttributeName(attrName: string): string;
@@ -12,7 +12,8 @@ export const GT_TRANSLATION_FUNCS = [
12
12
  ];
13
13
  // Valid variable components
14
14
  export const VARIABLE_COMPONENTS = ['Var', 'DateTime', 'Currency', 'Num'];
15
- export const GT_ATTRIBUTES = ['$id', '$context'];
15
+ export const GT_ATTRIBUTES_WITH_SUGAR = ['$id', '$context'];
16
+ export const GT_ATTRIBUTES = ['id', 'context', ...GT_ATTRIBUTES_WITH_SUGAR];
16
17
  export function mapAttributeName(attrName) {
17
18
  if (attrName === '$id')
18
19
  return 'id';
@@ -7,7 +7,7 @@ import { warnHasUnwrappedExpressionSync, warnVariablePropSync, warnNestedTCompon
7
7
  import { isAcceptedPluralForm } from 'generaltranslation/internal';
8
8
  import { handleChildrenWhitespace } from '../trimJsxStringChildren.js';
9
9
  import { isStaticExpression } from '../evaluateJsx.js';
10
- import { GT_ATTRIBUTES, VARIABLE_COMPONENTS } from './constants.js';
10
+ import { GT_ATTRIBUTES, mapAttributeName, VARIABLE_COMPONENTS, } from './constants.js';
11
11
  /**
12
12
  * Builds a JSX tree from a given node, recursively handling children.
13
13
  * @param node - The node to build the tree from
@@ -188,7 +188,7 @@ export function parseJSXElement(importAliases, node, updates, errors, file) {
188
188
  }
189
189
  // Use the static value if available
190
190
  if (staticAnalysis.isStatic && staticAnalysis.value !== undefined) {
191
- metadata[attrName] = staticAnalysis.value;
191
+ metadata[mapAttributeName(attrName)] = staticAnalysis.value;
192
192
  }
193
193
  else {
194
194
  // Only store the code if we couldn't extract a static value
@@ -1,6 +1,6 @@
1
1
  import * as t from '@babel/types';
2
2
  import { isStaticExpression } from '../evaluateJsx.js';
3
- import { GT_ATTRIBUTES, mapAttributeName } from './constants.js';
3
+ import { GT_ATTRIBUTES_WITH_SUGAR, mapAttributeName } from './constants.js';
4
4
  import { warnNonStaticExpressionSync, warnNonStringSync, warnTemplateLiteralSync, } from '../../../console/index.js';
5
5
  import generateModule from '@babel/generator';
6
6
  import traverseModule from '@babel/traverse';
@@ -37,7 +37,7 @@ function processTranslationCall(tPath, updates, errors, file) {
37
37
  if (prop.type === 'ObjectProperty' &&
38
38
  prop.key.type === 'Identifier') {
39
39
  const attribute = prop.key.name;
40
- if (GT_ATTRIBUTES.includes(attribute) &&
40
+ if (GT_ATTRIBUTES_WITH_SUGAR.includes(attribute) &&
41
41
  t.isExpression(prop.value)) {
42
42
  const result = isStaticExpression(prop.value);
43
43
  if (!result.isStatic) {
@@ -18,7 +18,7 @@ export type FlattenedJSONDictionary = {
18
18
  [key: string]: string;
19
19
  };
20
20
  export type DataFormat = 'JSX' | 'ICU' | 'I18NEXT';
21
- export type FileExtension = 'JSON' | 'YAML' | 'MDX' | 'MD' | 'TS' | 'JS';
21
+ export type FileFormat = 'JSON' | 'YAML' | 'MDX' | 'MD' | 'TS' | 'JS';
22
22
  export type JsxChildren = string | string[] | any;
23
23
  export type Translations = {
24
24
  [key: string]: JsxChildren;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gtx-cli",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "main": "dist/index.js",
5
5
  "bin": "dist/main.js",
6
6
  "files": [
@@ -87,7 +87,7 @@
87
87
  "esbuild": "^0.25.4",
88
88
  "fast-glob": "^3.3.3",
89
89
  "form-data": "^4.0.2",
90
- "generaltranslation": "^7.0.0",
90
+ "generaltranslation": "^7.0.1",
91
91
  "open": "^10.1.1",
92
92
  "ora": "^8.2.0",
93
93
  "resolve": "^1.22.10",