langctl 0.2.0 → 0.4.0
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 +53 -0
- package/README.md +158 -1188
- package/dist/commands/auth.js +85 -19
- package/dist/commands/config.js +36 -26
- package/dist/commands/export.js +11 -122
- package/dist/commands/import.js +32 -143
- package/dist/commands/init.js +61 -72
- package/dist/commands/keys.js +145 -279
- package/dist/commands/org.js +45 -111
- package/dist/commands/projects.js +124 -312
- package/dist/commands/pull.js +86 -129
- package/dist/commands/push.js +125 -0
- package/dist/commands/review.js +65 -0
- package/dist/commands/team.js +68 -257
- package/dist/commands/translate.js +99 -0
- package/dist/core/cache.js +48 -0
- package/dist/core/config.js +130 -0
- package/dist/core/errors.js +67 -0
- package/dist/core/files.js +38 -0
- package/dist/core/http.js +156 -0
- package/dist/core/output.js +96 -0
- package/dist/core/project.js +58 -0
- package/dist/core/prompts.js +56 -0
- package/dist/formats/index.js +285 -0
- package/dist/index.js +277 -508
- package/dist/version.js +4 -0
- package/package.json +22 -15
- package/.gitattributes +0 -2
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -26
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -19
- package/CONTRIBUTING.md +0 -33
- package/dist/api.d.ts +0 -20
- package/dist/api.js +0 -75
- package/dist/auth.d.ts +0 -38
- package/dist/auth.js +0 -106
- package/dist/commands/auth.d.ts +0 -3
- package/dist/commands/config.d.ts +0 -2
- package/dist/commands/debug.d.ts +0 -3
- package/dist/commands/debug.js +0 -61
- package/dist/commands/export.d.ts +0 -13
- package/dist/commands/import.d.ts +0 -12
- package/dist/commands/init.d.ts +0 -2
- package/dist/commands/keys.d.ts +0 -25
- package/dist/commands/org.d.ts +0 -13
- package/dist/commands/projects.d.ts +0 -33
- package/dist/commands/pull.d.ts +0 -9
- package/dist/commands/team.d.ts +0 -29
- package/dist/config.d.ts +0 -48
- package/dist/config.js +0 -69
- package/dist/exporters/index.d.ts +0 -36
- package/dist/exporters/index.js +0 -214
- package/dist/index.d.ts +0 -3
- package/dist/utils/banner.d.ts +0 -9
- package/dist/utils/banner.js +0 -24
- package/translations/en.json +0 -5
- package/translations/en.xml +0 -9
- package/translations/fr.json +0 -4
- package/translations/fr.xml +0 -7
- package/translations/hi.json +0 -4
- package/translations/hi.xml +0 -7
- package/translations/ios/en.strings +0 -9
- package/translations/ios/fr.strings +0 -6
- package/translations/ios/hi.strings +0 -6
- package/translations/ios/ja.strings +0 -6
- package/translations/ja.json +0 -4
- package/translations/ja.xml +0 -7
package/dist/config.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import Conf from 'conf';
|
|
2
|
-
import { join } from 'path';
|
|
3
|
-
import { homedir } from 'os';
|
|
4
|
-
class ConfigManager {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.configDir = join(homedir(), '.langctl');
|
|
7
|
-
this.config = new Conf({
|
|
8
|
-
projectName: 'langctl',
|
|
9
|
-
cwd: this.configDir,
|
|
10
|
-
configName: 'config'
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Get a configuration value
|
|
15
|
-
*/
|
|
16
|
-
get(key) {
|
|
17
|
-
return this.config.get(key);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Set a configuration value
|
|
21
|
-
*/
|
|
22
|
-
set(key, value) {
|
|
23
|
-
this.config.set(key, value);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Get all configuration
|
|
27
|
-
*/
|
|
28
|
-
getAll() {
|
|
29
|
-
return this.config.store;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Set multiple configuration values
|
|
33
|
-
*/
|
|
34
|
-
setAll(config) {
|
|
35
|
-
Object.entries(config).forEach(([key, value]) => {
|
|
36
|
-
if (value !== undefined) {
|
|
37
|
-
this.config.set(key, value);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Delete a configuration value
|
|
43
|
-
*/
|
|
44
|
-
delete(key) {
|
|
45
|
-
this.config.delete(key);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Clear all configuration
|
|
49
|
-
*/
|
|
50
|
-
clear() {
|
|
51
|
-
this.config.clear();
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Check if user is authenticated
|
|
55
|
-
*/
|
|
56
|
-
isConfigured() {
|
|
57
|
-
return !!(this.config.get('apiKey') &&
|
|
58
|
-
this.config.get('organizationId'));
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Get the configuration file path
|
|
62
|
-
*/
|
|
63
|
-
getConfigPath() {
|
|
64
|
-
return this.config.path;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
// Singleton instance
|
|
68
|
-
export const config = new ConfigManager();
|
|
69
|
-
//# sourceMappingURL=config.js.map
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export interface TranslationKey {
|
|
2
|
-
key: string;
|
|
3
|
-
translations: Record<string, string>;
|
|
4
|
-
description?: string;
|
|
5
|
-
module?: string;
|
|
6
|
-
}
|
|
7
|
-
export type ExportFormat = 'json' | 'json-nested' | 'ios' | 'android' | 'flutter';
|
|
8
|
-
export interface ExportResult {
|
|
9
|
-
content: string;
|
|
10
|
-
filename: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Export as flat JSON (simple key-value pairs)
|
|
14
|
-
*/
|
|
15
|
-
export declare function exportFlatJson(keys: TranslationKey[], languageCode: string): ExportResult;
|
|
16
|
-
/**
|
|
17
|
-
* Export as nested JSON (organized by key structure)
|
|
18
|
-
*/
|
|
19
|
-
export declare function exportNestedJson(keys: TranslationKey[], languageCode: string): ExportResult;
|
|
20
|
-
/**
|
|
21
|
-
* Export as iOS .strings format
|
|
22
|
-
*/
|
|
23
|
-
export declare function exportIosStrings(keys: TranslationKey[], languageCode: string): ExportResult;
|
|
24
|
-
/**
|
|
25
|
-
* Export as Android XML format
|
|
26
|
-
*/
|
|
27
|
-
export declare function exportAndroidXml(keys: TranslationKey[], languageCode: string): ExportResult;
|
|
28
|
-
/**
|
|
29
|
-
* Export as Flutter ARB format
|
|
30
|
-
*/
|
|
31
|
-
export declare function exportFlutterArb(keys: TranslationKey[], languageCode: string): ExportResult;
|
|
32
|
-
/**
|
|
33
|
-
* Export translations in the specified format
|
|
34
|
-
*/
|
|
35
|
-
export declare function exportTranslations(keys: TranslationKey[], languageCode: string, format: ExportFormat): ExportResult;
|
|
36
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/exporters/index.js
DELETED
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Helper: Set nested value in object based on dot-notation key
|
|
3
|
-
*/
|
|
4
|
-
function setNestedValue(obj, path, value) {
|
|
5
|
-
const keys = path.split('.');
|
|
6
|
-
let current = obj;
|
|
7
|
-
for (let i = 0; i < keys.length - 1; i++) {
|
|
8
|
-
const key = keys[i];
|
|
9
|
-
if (!current[key] || typeof current[key] !== 'object') {
|
|
10
|
-
current[key] = {};
|
|
11
|
-
}
|
|
12
|
-
current = current[key];
|
|
13
|
-
}
|
|
14
|
-
current[keys[keys.length - 1]] = value;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Helper: Convert i18n format {{param}} to Android format %1$s, %2$s, etc.
|
|
18
|
-
*/
|
|
19
|
-
function convertToAndroidFormat(text) {
|
|
20
|
-
const matches = text.match(/\{\{([^}]+)\}\}/g);
|
|
21
|
-
if (!matches)
|
|
22
|
-
return text;
|
|
23
|
-
let result = text;
|
|
24
|
-
matches.forEach((match, index) => {
|
|
25
|
-
const paramNum = index + 1;
|
|
26
|
-
result = result.replace(match, `%${paramNum}$s`);
|
|
27
|
-
});
|
|
28
|
-
return result;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Helper: Convert i18n format {{param}} to iOS format %1$@, %2$@, etc.
|
|
32
|
-
*/
|
|
33
|
-
function convertToIosFormat(text) {
|
|
34
|
-
const matches = text.match(/\{\{([^}]+)\}\}/g);
|
|
35
|
-
if (!matches)
|
|
36
|
-
return text;
|
|
37
|
-
let result = text;
|
|
38
|
-
matches.forEach((match, index) => {
|
|
39
|
-
const paramNum = index + 1;
|
|
40
|
-
result = result.replace(match, `%${paramNum}$@`);
|
|
41
|
-
});
|
|
42
|
-
return result;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Helper: Convert i18n format {{param}} to Flutter format {param}
|
|
46
|
-
*/
|
|
47
|
-
function convertToFlutterFormat(text) {
|
|
48
|
-
return text.replace(/\{\{([^}]+)\}\}/g, '{$1}');
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Helper: Extract placeholder names from Flutter format {param}
|
|
52
|
-
*/
|
|
53
|
-
function extractPlaceholders(text) {
|
|
54
|
-
const matches = text.match(/\{([^}]+)\}/g);
|
|
55
|
-
if (!matches)
|
|
56
|
-
return [];
|
|
57
|
-
return matches.map(match => match.slice(1, -1));
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Helper: Escape XML special characters
|
|
61
|
-
*/
|
|
62
|
-
function escapeXml(text) {
|
|
63
|
-
return text
|
|
64
|
-
.replace(/&/g, '&')
|
|
65
|
-
.replace(/</g, '<')
|
|
66
|
-
.replace(/>/g, '>')
|
|
67
|
-
.replace(/"/g, '"')
|
|
68
|
-
.replace(/'/g, ''');
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Helper: Escape .strings special characters
|
|
72
|
-
*/
|
|
73
|
-
function escapeStrings(text) {
|
|
74
|
-
return text
|
|
75
|
-
.replace(/\\/g, '\\\\')
|
|
76
|
-
.replace(/"/g, '\\"')
|
|
77
|
-
.replace(/\n/g, '\\n')
|
|
78
|
-
.replace(/\r/g, '\\r')
|
|
79
|
-
.replace(/\t/g, '\\t');
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Export as flat JSON (simple key-value pairs)
|
|
83
|
-
*/
|
|
84
|
-
export function exportFlatJson(keys, languageCode) {
|
|
85
|
-
const translations = {};
|
|
86
|
-
keys.forEach(key => {
|
|
87
|
-
const translation = key.translations[languageCode];
|
|
88
|
-
if (translation) {
|
|
89
|
-
translations[key.key] = translation;
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
return {
|
|
93
|
-
content: JSON.stringify(translations, null, 2),
|
|
94
|
-
filename: `${languageCode}.json`
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Export as nested JSON (organized by key structure)
|
|
99
|
-
*/
|
|
100
|
-
export function exportNestedJson(keys, languageCode) {
|
|
101
|
-
const translations = {};
|
|
102
|
-
keys.forEach(key => {
|
|
103
|
-
const translation = key.translations[languageCode];
|
|
104
|
-
if (translation) {
|
|
105
|
-
setNestedValue(translations, key.key, translation);
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
return {
|
|
109
|
-
content: JSON.stringify(translations, null, 2),
|
|
110
|
-
filename: `${languageCode}.json`
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Export as iOS .strings format
|
|
115
|
-
*/
|
|
116
|
-
export function exportIosStrings(keys, languageCode) {
|
|
117
|
-
let content = '';
|
|
118
|
-
keys.forEach(key => {
|
|
119
|
-
const translation = key.translations[languageCode];
|
|
120
|
-
if (translation) {
|
|
121
|
-
const iosTranslation = convertToIosFormat(translation);
|
|
122
|
-
const escapedTranslation = escapeStrings(iosTranslation);
|
|
123
|
-
if (key.description) {
|
|
124
|
-
content += `/* ${key.description} */\n`;
|
|
125
|
-
}
|
|
126
|
-
content += `"${key.key}" = "${escapedTranslation}";\n\n`;
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
return {
|
|
130
|
-
content,
|
|
131
|
-
filename: `Localizable.strings`
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Export as Android XML format
|
|
136
|
-
*/
|
|
137
|
-
export function exportAndroidXml(keys, languageCode) {
|
|
138
|
-
let xml = '<?xml version="1.0" encoding="utf-8"?>\n';
|
|
139
|
-
xml += '<resources>\n';
|
|
140
|
-
keys.forEach(key => {
|
|
141
|
-
const translation = key.translations[languageCode];
|
|
142
|
-
if (translation) {
|
|
143
|
-
const androidTranslation = convertToAndroidFormat(translation);
|
|
144
|
-
const escapedTranslation = escapeXml(androidTranslation);
|
|
145
|
-
if (key.description) {
|
|
146
|
-
xml += ` <!-- ${escapeXml(key.description)} -->\n`;
|
|
147
|
-
}
|
|
148
|
-
xml += ` <string name="${key.key}">${escapedTranslation}</string>\n`;
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
xml += '</resources>\n';
|
|
152
|
-
return {
|
|
153
|
-
content: xml,
|
|
154
|
-
filename: `strings.xml`
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Export as Flutter ARB format
|
|
159
|
-
*/
|
|
160
|
-
export function exportFlutterArb(keys, languageCode) {
|
|
161
|
-
const arb = {
|
|
162
|
-
'@@locale': languageCode,
|
|
163
|
-
'@@last_modified': new Date().toISOString()
|
|
164
|
-
};
|
|
165
|
-
keys.forEach(key => {
|
|
166
|
-
const translation = key.translations[languageCode];
|
|
167
|
-
if (translation) {
|
|
168
|
-
const flutterTranslation = convertToFlutterFormat(translation);
|
|
169
|
-
arb[key.key] = flutterTranslation;
|
|
170
|
-
// Add metadata
|
|
171
|
-
const metadata = {};
|
|
172
|
-
if (key.description) {
|
|
173
|
-
metadata.description = key.description;
|
|
174
|
-
}
|
|
175
|
-
// Extract placeholders from translation
|
|
176
|
-
const placeholders = extractPlaceholders(flutterTranslation);
|
|
177
|
-
if (placeholders.length > 0) {
|
|
178
|
-
metadata.placeholders = {};
|
|
179
|
-
placeholders.forEach(placeholder => {
|
|
180
|
-
metadata.placeholders[placeholder] = {
|
|
181
|
-
type: 'String'
|
|
182
|
-
};
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
if (Object.keys(metadata).length > 0) {
|
|
186
|
-
arb[`@${key.key}`] = metadata;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
return {
|
|
191
|
-
content: JSON.stringify(arb, null, 2),
|
|
192
|
-
filename: `intl_${languageCode}.arb`
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Export translations in the specified format
|
|
197
|
-
*/
|
|
198
|
-
export function exportTranslations(keys, languageCode, format) {
|
|
199
|
-
switch (format) {
|
|
200
|
-
case 'json':
|
|
201
|
-
return exportFlatJson(keys, languageCode);
|
|
202
|
-
case 'json-nested':
|
|
203
|
-
return exportNestedJson(keys, languageCode);
|
|
204
|
-
case 'ios':
|
|
205
|
-
return exportIosStrings(keys, languageCode);
|
|
206
|
-
case 'android':
|
|
207
|
-
return exportAndroidXml(keys, languageCode);
|
|
208
|
-
case 'flutter':
|
|
209
|
-
return exportFlutterArb(keys, languageCode);
|
|
210
|
-
default:
|
|
211
|
-
throw new Error(`Unsupported export format: ${format}`);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.d.ts
DELETED
package/dist/utils/banner.d.ts
DELETED
package/dist/utils/banner.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
/**
|
|
3
|
-
* Langctl ASCII Logo - Emerald Green
|
|
4
|
-
*/
|
|
5
|
-
export function showLogo() {
|
|
6
|
-
const logo = `
|
|
7
|
-
██╗ █████╗ ███╗ ██╗ ██████╗ ██████╗████████╗██╗
|
|
8
|
-
██║ ██╔══██╗████╗ ██║██╔════╝ ██╔════╝╚══██╔══╝██║
|
|
9
|
-
██║ ███████║██╔██╗ ██║██║ ███╗██║ ██║ ██║
|
|
10
|
-
██║ ██╔══██║██║╚██╗██║██║ ██║██║ ██║ ██║
|
|
11
|
-
███████╗██║ ██║██║ ╚████║╚██████╔╝╚██████╗ ██║ ███████╗
|
|
12
|
-
╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝
|
|
13
|
-
`;
|
|
14
|
-
console.log(chalk.hex('#10b981')(logo)); // Emerald-500
|
|
15
|
-
console.log(chalk.gray(' CLI-first translation management for developers\n'));
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Simple banner for quick commands
|
|
19
|
-
*/
|
|
20
|
-
export function showBanner(title) {
|
|
21
|
-
console.log(chalk.hex('#10b981').bold(`\n${title}`));
|
|
22
|
-
console.log(chalk.gray('─'.repeat(title.length)));
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=banner.js.map
|
package/translations/en.json
DELETED
package/translations/en.xml
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<resources>
|
|
3
|
-
<!-- Hero text -->
|
|
4
|
-
<string name="home.translation_mgmt">Translation Management</string>
|
|
5
|
-
<!-- Homepage wlecome message -->
|
|
6
|
-
<string name="home.welcome_message">Welcome Home</string>
|
|
7
|
-
<!-- This is a new item -->
|
|
8
|
-
<string name="new_item">New Item</string>
|
|
9
|
-
</resources>
|
package/translations/fr.json
DELETED
package/translations/fr.xml
DELETED
package/translations/hi.json
DELETED
package/translations/hi.xml
DELETED
package/translations/ja.json
DELETED
package/translations/ja.xml
DELETED