transcripto-cli 1.0.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.
Files changed (58) hide show
  1. package/README.md +576 -0
  2. package/dist/cli/generate.d.ts +2 -0
  3. package/dist/cli/generate.d.ts.map +1 -0
  4. package/dist/cli/generate.js +416 -0
  5. package/dist/cli/generate.js.map +1 -0
  6. package/dist/cli/index.d.ts +3 -0
  7. package/dist/cli/index.d.ts.map +1 -0
  8. package/dist/cli/index.js +43 -0
  9. package/dist/cli/index.js.map +1 -0
  10. package/dist/cli/init.d.ts +2 -0
  11. package/dist/cli/init.d.ts.map +1 -0
  12. package/dist/cli/init.js +81 -0
  13. package/dist/cli/init.js.map +1 -0
  14. package/dist/cli/report.d.ts +2 -0
  15. package/dist/cli/report.d.ts.map +1 -0
  16. package/dist/cli/report.js +137 -0
  17. package/dist/cli/report.js.map +1 -0
  18. package/dist/cli/scan.d.ts +2 -0
  19. package/dist/cli/scan.d.ts.map +1 -0
  20. package/dist/cli/scan.js +62 -0
  21. package/dist/cli/scan.js.map +1 -0
  22. package/dist/cli/watch-i18n.d.ts +2 -0
  23. package/dist/cli/watch-i18n.d.ts.map +1 -0
  24. package/dist/cli/watch-i18n.js +73 -0
  25. package/dist/cli/watch-i18n.js.map +1 -0
  26. package/dist/cli/watch.d.ts +2 -0
  27. package/dist/cli/watch.d.ts.map +1 -0
  28. package/dist/cli/watch.js +147 -0
  29. package/dist/cli/watch.js.map +1 -0
  30. package/dist/core/i18nGenerator.d.ts +16 -0
  31. package/dist/core/i18nGenerator.d.ts.map +1 -0
  32. package/dist/core/i18nGenerator.js +139 -0
  33. package/dist/core/i18nGenerator.js.map +1 -0
  34. package/dist/core/projectScanner.d.ts +12 -0
  35. package/dist/core/projectScanner.d.ts.map +1 -0
  36. package/dist/core/projectScanner.js +53 -0
  37. package/dist/core/projectScanner.js.map +1 -0
  38. package/dist/core/stringExtractor.d.ts +21 -0
  39. package/dist/core/stringExtractor.d.ts.map +1 -0
  40. package/dist/core/stringExtractor.js +268 -0
  41. package/dist/core/stringExtractor.js.map +1 -0
  42. package/dist/index.d.ts +7 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +10 -0
  45. package/dist/index.js.map +1 -0
  46. package/package.json +44 -0
  47. package/src/cli/generate.ts +422 -0
  48. package/src/cli/index.ts +50 -0
  49. package/src/cli/init.ts +96 -0
  50. package/src/cli/report.ts +160 -0
  51. package/src/cli/scan.ts +69 -0
  52. package/src/cli/watch-i18n.ts +77 -0
  53. package/src/cli/watch.ts +129 -0
  54. package/src/core/i18nGenerator.ts +127 -0
  55. package/src/core/projectScanner.ts +62 -0
  56. package/src/core/stringExtractor.ts +276 -0
  57. package/src/index.ts +7 -0
  58. package/tsconfig.json +20 -0
package/README.md ADDED
@@ -0,0 +1,576 @@
1
+ # 🌐 Transcripto - Automated Localization CLI
2
+
3
+ **Intelligent React localization automation that scans projects, extracts UI text, and generates translations using AI.**
4
+
5
+ ## 📋 Table of Contents
6
+
7
+ - [🎯 Features](#-features)
8
+ - [🚀 Quick Start](#-quick-start)
9
+ - [📦 Installation](#-installation)
10
+ - [🔧 Commands](#-commands)
11
+ - [📁 Project Structure](#-project-structure)
12
+ - [⚡ Workflow](#-workflow)
13
+ - [🎯 Usage Examples](#-usage-examples)
14
+ - [⚙️ Configuration](#️-configuration)
15
+ - [🔍 Advanced Features](#-advanced-features)
16
+ - [🐛 Troubleshooting](#-troubleshooting)
17
+
18
+ ---
19
+
20
+ ## 🎯 Features
21
+
22
+ ### ✨ **Core Capabilities**
23
+ - **🔍 Smart String Extraction** - Automatically scans React projects for UI text
24
+ - **🧠 Technical String Filtering** - Ignores code, CSS classes, file paths
25
+ - **📝 JSON-Only Mode** - Clean translation files without constants clutter
26
+ - **🌐 AI Translation** - Integrates with lingo.dev for automatic translations
27
+ - **👁️ Real-time Watching** - Auto-translates when files change
28
+ - **📁 Root i18n Folder** - Clean project organization
29
+
30
+ ### 🚀 **Automation Features**
31
+ - **Zero Configuration** - Works out of the box
32
+ - **Non-Interactive Mode** - Perfect for CI/CD pipelines
33
+ - **Automatic Language Selection** - AI chooses optimal target languages
34
+ - **File Monitoring** - Real-time translation updates
35
+ - **Clean Output** - Professional project structure
36
+
37
+ ---
38
+
39
+ ## 🚀 Quick Start
40
+
41
+ ### ⚡ **5-Minute Setup**
42
+
43
+ ```bash
44
+ # 1. Install Transcripto
45
+ npm install -g transcripto-cli@latest
46
+
47
+ # 2. Go to your React project
48
+ cd my-react-app
49
+
50
+ # 3. Generate initial translations
51
+ transcripto generate
52
+
53
+ # 4. Start auto-watcher (optional)
54
+ transcripto watch-i18n
55
+ ```
56
+
57
+ ### 🎉 **You're done!**
58
+ - ✅ Translation files created in `i18n/` folder
59
+ - ✅ AI translations generated automatically
60
+ - ✅ Real-time updates enabled
61
+ - ✅ Ready for production
62
+
63
+ ---
64
+
65
+ ## 📦 Installation
66
+
67
+ ### 🌍 **Global Installation**
68
+ ```bash
69
+ npm install -g transcripto-cli@latest
70
+ ```
71
+
72
+ ### ✅ **Verify Installation**
73
+ ```bash
74
+ transcripto --version
75
+ # Expected: 1.1.16+
76
+ ```
77
+
78
+ ### 🔧 **System Requirements**
79
+ - **Node.js** 16.0 or higher
80
+ - **npm** 8.0 or higher
81
+ - **React** project (for extraction)
82
+ - **lingo.dev** account (for translations)
83
+
84
+ ---
85
+
86
+ ## 🔧 Commands
87
+
88
+ ### 📝 **generate** - Generate translation files
89
+ ```bash
90
+ transcripto generate
91
+ ```
92
+ **What it does:**
93
+ - 🔍 Scans project for UI text strings
94
+ - 🧠 Filters out technical strings
95
+ - 📁 Creates `i18n/en.json` with extracted text
96
+ - 🌐 Runs lingo.dev for AI translations
97
+ - ✅ Generates all language files
98
+
99
+ ### 👁️ **watch-i18n** - Monitor & auto-translate
100
+ ```bash
101
+ transcripto watch-i18n
102
+ ```
103
+ **What it does:**
104
+ - 👁️ Watches `i18n/en.json` for changes
105
+ - 🔄 Auto-runs translation when file changes
106
+ - ⚡ Real-time translation updates
107
+ - 🎨 Perfect for development workflow
108
+
109
+ ### 🔍 **scan** - Scan project only
110
+ ```bash
111
+ transcripto scan
112
+ ```
113
+ **What it does:**
114
+ - 🔍 Scans project for UI text
115
+ - 📊 Shows extraction report
116
+ - 📝 Saves to `.transcripto/extracted-strings.json`
117
+
118
+ ### 📊 **report** - Show coverage report
119
+ ```bash
120
+ transcripto report
121
+ ```
122
+ **What it does:**
123
+ - 📊 Shows localization coverage
124
+ - 📈 Lists found strings
125
+ - 🎯 Identifies missing translations
126
+
127
+ ### 🚀 **init** - Initialize project
128
+ ```bash
129
+ transcripto init
130
+ ```
131
+ **What it does:**
132
+ - 📁 Creates `.transcripto/` config folder
133
+ - ⚙️ Sets up default configuration
134
+ - 🎯 Prepares project for localization
135
+
136
+ ---
137
+
138
+ ## 📁 Project Structure
139
+
140
+ ### 📂 **After Running Transcripto**
141
+ ```
142
+ my-project/
143
+ ├── i18n/ # 🌐 Translation files
144
+ │ ├── en.json # English source
145
+ │ ├── hi.json # Hindi translations
146
+ │ ├── es.json # Spanish translations
147
+ │ └── fr.json # French translations
148
+ ├── src/
149
+ │ ├── components/
150
+ │ │ └── LanguageDropdown.tsx # Auto-generated
151
+ │ └── App.tsx
152
+ ├── .transcripto/ # 🔧 Transcripto config
153
+ │ └── extracted-strings.json
154
+ ├── .lingodev.json # 🤖 lingo.dev config
155
+ └── package.json
156
+ ```
157
+
158
+ ### 📝 **Translation File Format**
159
+ ```json
160
+ // i18n/en.json
161
+ {
162
+ "welcome_message": "Welcome to our app",
163
+ "get_started": "Get Started",
164
+ "learn_react": "Learn React",
165
+ "hello_world": "Hello world"
166
+ }
167
+
168
+ // i18n/hi.json (Auto-translated)
169
+ {
170
+ "welcome_message": "हमार ऐप में आपका स्वागत है",
171
+ "get_started": "शुरू करें",
172
+ "learn_react": "React सीखें",
173
+ "hello_world": "हैलो वर्ल्ड"
174
+ }
175
+ ```
176
+
177
+ ---
178
+
179
+ ## ⚡ Workflow
180
+
181
+ ### 🔄 **Development Workflow**
182
+
183
+ #### **Step 1: Initial Setup**
184
+ ```bash
185
+ # Navigate to React project
186
+ cd my-react-app
187
+
188
+ # Generate initial translations
189
+ transcripto generate
190
+ ```
191
+
192
+ **Output:**
193
+ ```
194
+ 🔍 Scanning project for UI text strings...
195
+ ✅ Found 8 UI text strings
196
+ ✅ Generated i18n files for 8 strings
197
+ 📁 Translations: ./i18n/
198
+ 🌍 Languages: en
199
+ 🌐 Running lingo.dev for translations...
200
+ ✅ lingo.dev translations completed successfully!
201
+ 🎨 Created LanguageDropdown.tsx component
202
+ ```
203
+
204
+ #### **Step 2: Start Auto-Watcher**
205
+ ```bash
206
+ # Start real-time monitoring
207
+ transcripto watch-i18n
208
+ ```
209
+
210
+ **Output:**
211
+ ```
212
+ 👁️ Starting i18n file watcher...
213
+ 📁 Monitoring: ./i18n/en.json
214
+ 🔄 Auto-translating on changes...
215
+ 🎉 Watcher started successfully!
216
+ 💡 Add new keys to ./i18n/en.json and they will be auto-translated
217
+ ⏹️ Press Ctrl+C to stop watching
218
+ ```
219
+
220
+ #### **Step 3: Add New Translations**
221
+ ```bash
222
+ # Edit the English source file
223
+ vim i18n/en.json
224
+
225
+ # Add new keys:
226
+ {
227
+ "new_feature": "New Feature",
228
+ "settings_page": "Settings",
229
+ "save_button": "Save Changes"
230
+ }
231
+ ```
232
+
233
+ **Auto-translation happens instantly:**
234
+ ```
235
+ 🔄 File changed: ./i18n/en.json
236
+ 🌐 Running auto-translation...
237
+ ✅ Auto-translation completed!
238
+ ```
239
+
240
+ ### 🔄 **Production Workflow**
241
+
242
+ #### **Step 1: Build Translations**
243
+ ```bash
244
+ # Generate final translations
245
+ transcripto generate
246
+
247
+ # Verify all languages
248
+ ls i18n/
249
+ # en.json hi.json es.json fr.json
250
+ ```
251
+
252
+ #### **Step 2: Integration**
253
+ ```typescript
254
+ // Import translations in React
255
+ import enTranslations from './i18n/en.json';
256
+ import hiTranslations from './i18n/hi.json';
257
+
258
+ // Create translation function
259
+ const translations = {
260
+ en: enTranslations,
261
+ hi: hiTranslations
262
+ };
263
+
264
+ function t(key: string, language: string = 'en') {
265
+ return translations[language]?.[key] || key;
266
+ }
267
+
268
+ // Use in components
269
+ function App() {
270
+ const [language, setLanguage] = useState('en');
271
+
272
+ return (
273
+ <div>
274
+ <h1>{t('welcome_message', language)}</h1>
275
+ <button onClick={() => setLanguage('hi')}>
276
+ Switch to Hindi
277
+ </button>
278
+ </div>
279
+ );
280
+ }
281
+ ```
282
+
283
+ ---
284
+
285
+ ## 🎯 Usage Examples
286
+
287
+ ### 📱 **Basic React Integration**
288
+ ```typescript
289
+ // src/i18n/index.ts
290
+ import enTranslations from './en.json';
291
+ import hiTranslations from './hi.json';
292
+ import esTranslations from './es.json';
293
+ import frTranslations from './fr.json';
294
+
295
+ export const translations = {
296
+ en: enTranslations,
297
+ hi: hiTranslations,
298
+ es: esTranslations,
299
+ fr: frTranslations
300
+ };
301
+
302
+ export type Language = keyof typeof translations;
303
+ export type TranslationKey = keyof typeof enTranslations;
304
+
305
+ export function t(key: TranslationKey, language: Language = 'en'): string {
306
+ return translations[language]?.[key] || key;
307
+ }
308
+
309
+ // Language switcher component
310
+ export function LanguageSwitcher() {
311
+ const [language, setLanguage] = useState<Language>('en');
312
+
313
+ return (
314
+ <select value={language} onChange={(e) => setLanguage(e.target.value as Language)}>
315
+ <option value="en">English</option>
316
+ <option value="hi">हिंदी</option>
317
+ <option value="es">Español</option>
318
+ <option value="fr">Français</option>
319
+ </select>
320
+ );
321
+ }
322
+ ```
323
+
324
+ ### 🎨 **Using Auto-Generated Components**
325
+ ```typescript
326
+ // Import the auto-generated language dropdown
327
+ import LanguageDropdown from './components/LanguageDropdown';
328
+
329
+ function App() {
330
+ return (
331
+ <div>
332
+ <LanguageDropdown />
333
+ <h1>Welcome to our app!</h1>
334
+ </div>
335
+ );
336
+ }
337
+ ```
338
+
339
+ ### ⚡ **Real-time Development**
340
+ ```bash
341
+ # Terminal 1: Start watcher
342
+ transcripto watch-i18n
343
+
344
+ # Terminal 2: Edit translations
345
+ echo '{"new_string": "Brand new text"}' >> i18n/en.json
346
+
347
+ # Instant auto-translation!
348
+ 🔄 File changed: ./i18n/en.json
349
+ 🌐 Running auto-translation...
350
+ ✅ Auto-translation completed!
351
+ ```
352
+
353
+ ---
354
+
355
+ ## ⚙️ Configuration
356
+
357
+ ### 📝 **Default Settings**
358
+ Transcripto works out of the box with smart defaults:
359
+
360
+ ```json
361
+ {
362
+ "outputDir": "./i18n",
363
+ "languages": ["en"],
364
+ "keyPrefix": "",
365
+ "constantsFile": ""
366
+ }
367
+ ```
368
+
369
+ ### 🤖 **lingo.dev Integration**
370
+ ```json
371
+ // .lingodev.json (auto-generated)
372
+ {
373
+ "source": "./i18n/en.json",
374
+ "output": "./i18n",
375
+ "format": "json"
376
+ }
377
+ ```
378
+
379
+ ### 🔧 **Custom Configuration**
380
+ ```typescript
381
+ // Create custom config
382
+ const config = {
383
+ outputDir: './translations', // Custom folder
384
+ languages: ['en', 'de', 'ja'], // Custom languages
385
+ keyPrefix: 'APP_' // Custom prefix
386
+ };
387
+
388
+ // Use with Transcripto API
389
+ import { I18nGenerator } from 'transcripto';
390
+
391
+ const generator = new I18nGenerator();
392
+ await generator.generateI18nFiles(strings, config);
393
+ ```
394
+
395
+ ---
396
+
397
+ ## 🔍 Advanced Features
398
+
399
+ ### 🧠 **Smart String Filtering**
400
+ Transcripto automatically excludes:
401
+
402
+ **🚫 Technical Strings:**
403
+ - CSS class names (`.app-header`, `.btn-primary`)
404
+ - File paths (`src/App.tsx`, `components/Header`)
405
+ - React component names (`App`, `Header`, `Footer`)
406
+ - DOM IDs (`main-content`, `root-element`)
407
+ - Package names (`react`, `lodash`, `axios`)
408
+
409
+ **✅ Includes Only:**
410
+ - User-facing text (`"Welcome to our app"`)
411
+ - UI labels (`"Save Changes"`, `"Cancel"`)
412
+ - Messages (`"Error occurred"`, `"Success!"`)
413
+ - Content (`"Learn React"`, `"Getting started"`)
414
+
415
+ ### 🌐 **AI Language Selection**
416
+ lingo.dev automatically chooses target languages based on:
417
+
418
+ - **Content Analysis** - Analyzes extracted text
419
+ - **User Preferences** - Your lingo.dev settings
420
+ - **Project Type** - Web app, mobile app, etc.
421
+ - **Market Context** - Target audience analysis
422
+
423
+ ### 👁️ **Real-time File Watching**
424
+ Uses chokidar for efficient file monitoring:
425
+
426
+ - **Instant Detection** - File changes detected immediately
427
+ - **Debounced Updates** - Prevents excessive API calls
428
+ - **Error Recovery** - Handles translation failures gracefully
429
+ - **Background Processing** - Non-blocking translation workflow
430
+
431
+ ---
432
+
433
+ ## 🐛 Troubleshooting
434
+
435
+ ### ❌ **Common Issues**
436
+
437
+ #### **"No strings found"**
438
+ ```bash
439
+ # Problem
440
+ transcripto generate
441
+ ⚠️ No strings found
442
+
443
+ # Solutions
444
+ # 1. Check if you're in a React project
445
+ ls src/
446
+ # Should see App.tsx, components/, etc.
447
+
448
+ # 2. Verify file extensions
449
+ # Transcripto scans: .ts, .tsx, .js, .jsx
450
+
451
+ # 3. Check for text content
452
+ # Ensure you have actual UI text strings
453
+ ```
454
+
455
+ #### **"lingo.dev failed"**
456
+ ```bash
457
+ # Problem
458
+ 🌐 Running lingo.dev for translations...
459
+ ❌ lingo.dev failed
460
+
461
+ # Solutions
462
+ # 1. Check API key
463
+ lingo.dev login
464
+
465
+ # 2. Verify internet connection
466
+ ping lingo.dev
467
+
468
+ # 3. Check lingo.dev status
469
+ curl https://api.lingo.dev/status
470
+ ```
471
+
472
+ #### **"Auto-watcher not working"**
473
+ ```bash
474
+ # Problem
475
+ transcripto watch-i18n
476
+ 📁 Monitoring: ./i18n/en.json
477
+ # No response to file changes
478
+
479
+ # Solutions
480
+ # 1. Check file permissions
481
+ ls -la i18n/en.json
482
+
483
+ # 2. Verify file path
484
+ pwd # Should be project root
485
+
486
+ # 3. Test manually
487
+ echo '{"test": "test"}' > i18n/en.json
488
+ # Should trigger auto-translation
489
+ ```
490
+
491
+ ### 🔧 **Debug Mode**
492
+ ```bash
493
+ # Enable verbose logging
494
+ DEBUG=transcripto transcripto generate
495
+
496
+ # Check extraction details
497
+ cat .transcripto/extracted-strings.json
498
+
499
+ # Verify lingo.dev config
500
+ cat .lingodev.json
501
+ ```
502
+
503
+ ---
504
+
505
+ ## 📞 **Support & Contributing**
506
+
507
+ ### 🆘 **Getting Help**
508
+ ```bash
509
+ # Show all commands
510
+ transcripto --help
511
+
512
+ # Get help for specific command
513
+ transcripto generate --help
514
+ transcripto watch-i18n --help
515
+ ```
516
+
517
+ ### 🐛 **Reporting Issues**
518
+ - **Bug Reports**: Include `transcripto --version` and error logs
519
+ - **Feature Requests**: Welcome in discussions tab
520
+
521
+ ### 🔧 **Contributing**
522
+ 1. Fork the repository
523
+ 2. Create feature branch
524
+ 3. Make changes with tests
525
+ 4. Submit pull request
526
+ 5. Follow code style guidelines
527
+
528
+ ---
529
+
530
+ ## 📄 **License & Credits**
531
+
532
+ ### 📜 **License**
533
+ MIT License - Free for commercial and personal use
534
+
535
+ ### 👥 **Credits**
536
+ - **Created by**: Transcripto Team
537
+ - **AI Translation**: lingo.dev integration
538
+ - **File Watching**: chokidar library
539
+ - **CLI Framework**: Commander.js
540
+
541
+ ---
542
+
543
+ ## 🎉 **Quick Reference
544
+
545
+ ### 🚀 **One-Command Setup**
546
+ ```bash
547
+ npm install -g transcripto-cli@latest && transcripto generate
548
+ ```
549
+
550
+ ### 🔄 **Development Loop**
551
+ ```bash
552
+ # Start watcher
553
+ transcripto watch-i18n
554
+
555
+ # Edit translations (in another terminal)
556
+ vim i18n/en.json
557
+
558
+ # Auto-translates instantly!
559
+ ```
560
+
561
+ ### 📦 **Production Build**
562
+ ```bash
563
+ # Final translations
564
+ transcripto generate
565
+
566
+ # Deploy with confidence
567
+ # All i18n/ files ready for production
568
+ ```
569
+
570
+ ---
571
+
572
+ **🌐 Transcripto - Intelligent Localization Automation**
573
+
574
+ *Transform your React app for global audiences in minutes, not hours.*
575
+
576
+ **Install today:** `npm install -g transcripto-cli@latest`
@@ -0,0 +1,2 @@
1
+ export declare function generateCommand(): Promise<void>;
2
+ //# sourceMappingURL=generate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/cli/generate.ts"],"names":[],"mappings":"AAOA,wBAAsB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CA0ErD"}