gtx-cli 2.0.23-alpha.0 → 2.0.23
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,11 @@
|
|
|
1
1
|
# gtx-cli
|
|
2
2
|
|
|
3
|
+
## 2.0.23
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#539](https://github.com/generaltranslation/gt/pull/539) [`b88e468`](https://github.com/generaltranslation/gt/commit/b88e4684be9cd82a7d23e38fc893c2a8b7f0165f) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - feat: add ability to exclude import paths and url paths from localization
|
|
8
|
+
|
|
3
9
|
## 2.0.22
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/cli/base.d.ts
CHANGED
|
@@ -17,7 +17,8 @@ export type TranslateOptions = {
|
|
|
17
17
|
experimentalHideDefaultLocale?: boolean;
|
|
18
18
|
experimentalFlattenJsonFiles?: boolean;
|
|
19
19
|
experimentalLocalizeStaticImports?: boolean;
|
|
20
|
-
|
|
20
|
+
excludeStaticUrls?: string[];
|
|
21
|
+
excludeStaticImports?: string[];
|
|
21
22
|
};
|
|
22
23
|
export type LoginOptions = {
|
|
23
24
|
keyType?: 'development' | 'production';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -108,14 +108,14 @@ export type AdditionalOptions = {
|
|
|
108
108
|
};
|
|
109
109
|
docsUrlPattern?: string;
|
|
110
110
|
docsImportPattern?: string;
|
|
111
|
+
excludeStaticUrls?: string[];
|
|
112
|
+
excludeStaticImports?: string[];
|
|
111
113
|
docsHideDefaultLocaleImport?: boolean;
|
|
112
114
|
copyFiles?: string[];
|
|
113
115
|
experimentalLocalizeStaticImports?: boolean;
|
|
114
116
|
experimentalLocalizeStaticUrls?: boolean;
|
|
115
117
|
experimentalHideDefaultLocale?: boolean;
|
|
116
118
|
experimentalFlattenJsonFiles?: boolean;
|
|
117
|
-
experimentalExcludeStaticUrls?: string[];
|
|
118
|
-
experimentalExcludeStaticImports?: string[];
|
|
119
119
|
};
|
|
120
120
|
export type JsonSchema = {
|
|
121
121
|
preset?: 'mintlify';
|
|
@@ -33,7 +33,7 @@ export default async function localizeStaticImports(settings) {
|
|
|
33
33
|
// Get file content
|
|
34
34
|
const fileContent = await fs.promises.readFile(filePath, 'utf8');
|
|
35
35
|
// Localize the file
|
|
36
|
-
const localizedFile = localizeStaticImportsForFile(fileContent, settings.defaultLocale, locale, settings.options?.docsHideDefaultLocaleImport || false, settings.options?.docsImportPattern, settings.options?.
|
|
36
|
+
const localizedFile = localizeStaticImportsForFile(fileContent, settings.defaultLocale, locale, settings.options?.docsHideDefaultLocaleImport || false, settings.options?.docsImportPattern, settings.options?.excludeStaticImports);
|
|
37
37
|
// Write the localized file to the target path
|
|
38
38
|
await fs.promises.writeFile(filePath, localizedFile);
|
|
39
39
|
}));
|
|
@@ -69,12 +69,18 @@ exclude = []) {
|
|
|
69
69
|
const localizedFile = file.replace(regex, (match, bindings, quoteType, pathContent) => {
|
|
70
70
|
// Check if this path should be excluded from localization
|
|
71
71
|
if (exclude.length > 0) {
|
|
72
|
-
let matchPath =
|
|
72
|
+
let matchPath = '';
|
|
73
|
+
// let matchPath = patternHead;
|
|
73
74
|
if (pathContent) {
|
|
74
75
|
matchPath = hideDefaultLocale
|
|
75
76
|
? `${patternHead}${pathContent}`
|
|
76
77
|
: `${patternHead}${defaultLocale}/${pathContent}`;
|
|
77
78
|
}
|
|
79
|
+
else {
|
|
80
|
+
matchPath = hideDefaultLocale
|
|
81
|
+
? `${patternHead}`
|
|
82
|
+
: `${patternHead}${defaultLocale}`;
|
|
83
|
+
}
|
|
78
84
|
if (exclude.some((pattern) => isMatch(matchPath, pattern))) {
|
|
79
85
|
return match; // Don't localize excluded paths
|
|
80
86
|
}
|
|
@@ -32,8 +32,8 @@ export default async function localizeStaticUrls(settings) {
|
|
|
32
32
|
// Get file content
|
|
33
33
|
const fileContent = await fs.promises.readFile(filePath, 'utf8');
|
|
34
34
|
// Localize the file
|
|
35
|
-
const localizedFile = localizeStaticUrlsForFile(fileContent, settings.defaultLocale, locale, settings.experimentalHideDefaultLocale || false, settings.options?.docsUrlPattern, settings.options?.
|
|
36
|
-
const localizedFileHrefs = localizeStaticHrefsForFile(localizedFile, settings.defaultLocale, locale, settings.experimentalHideDefaultLocale || false, settings.options?.docsUrlPattern, settings.options?.
|
|
35
|
+
const localizedFile = localizeStaticUrlsForFile(fileContent, settings.defaultLocale, locale, settings.experimentalHideDefaultLocale || false, settings.options?.docsUrlPattern, settings.options?.excludeStaticUrls);
|
|
36
|
+
const localizedFileHrefs = localizeStaticHrefsForFile(localizedFile, settings.defaultLocale, locale, settings.experimentalHideDefaultLocale || false, settings.options?.docsUrlPattern, settings.options?.excludeStaticUrls);
|
|
37
37
|
// Write the localized file to the target path
|
|
38
38
|
await fs.promises.writeFile(filePath, localizedFileHrefs);
|
|
39
39
|
}));
|
|
@@ -69,12 +69,17 @@ exclude = []) {
|
|
|
69
69
|
const localizedFile = file.replace(regex, (match, pathContent) => {
|
|
70
70
|
if (exclude.length > 0) {
|
|
71
71
|
// Check if this path should be excluded from localization
|
|
72
|
-
let matchPath =
|
|
72
|
+
let matchPath = '';
|
|
73
73
|
if (pathContent) {
|
|
74
74
|
matchPath = hideDefaultLocale
|
|
75
75
|
? `${patternHead}${pathContent}`
|
|
76
76
|
: `${patternHead}${defaultLocale}/${pathContent}`;
|
|
77
77
|
}
|
|
78
|
+
else {
|
|
79
|
+
matchPath = hideDefaultLocale
|
|
80
|
+
? `${patternHead}`
|
|
81
|
+
: `${patternHead}${defaultLocale}`;
|
|
82
|
+
}
|
|
78
83
|
if (exclude.some((pattern) => isMatch(matchPath, pattern))) {
|
|
79
84
|
return match; // Don't localize excluded paths
|
|
80
85
|
}
|