ai_translation_generator 1.0.2
ai_translation_generator: ^1.0.2 copied to clipboard
A professional CLI tool for AI-powered translation generation using Google's Gemini AI. Generate Flutter l10n files with ease.
AI Translation Generator #
A professional CLI tool for AI-powered translation generation using Google's Gemini AI. Generate Flutter l10n files with ease and support for multiple languages.
โจ Features #
- ๐ Easy Setup: Initialize with a single command
- ๐ Multi-language Support: Translate to multiple languages simultaneously
- ๐จ Professional CLI: Beautiful terminal interface with progress indicators
- ๐ง Flutter l10n Standard: Generates files in
lib/l10n/
directory - ๐ Internet Connectivity: Automatic connection checking and error handling
- โก Fast & Efficient: Optimized for speed with parallel processing
- ๐ Secure: No hardcoded API keys, users provide their own
๐ฆ Installation #
Prerequisites #
- Dart SDK version 3.8.1 or higher
Global Installation #
dart pub global activate ai_translation_generator
Local Development #
git clone https://github.com/FUZAIL-GIT/ai_translation_generator.git
cd ai_translation_generator
dart pub get
dart compile exe bin/ai_translation_generator.dart -o aitranslation
๐ API Key Setup #
Get Your Free Gemini API Key #
- Visit Google AI Studio
- Sign in with your Google account
- Generate a free API key (no credit card required)
Configure Your API Key #
Option A: Environment Variable (Recommended)
export GEMINI_API_KEY=your_gemini_api_key_here
Option B: .env File
# Create .env file in your project root
echo "GEMINI_API_KEY=your_gemini_api_key_here" > .env
๐ Quick Start #
1. Initialize Configuration #
aitranslation init
This creates a ai_translation_generator.yaml
file:
# AI Translation Generator Configuration
# Generated by aitranslation init
languages:
- en
- ar
strings:
- settings
- home
- profile
- logout
2. Customize Your Configuration #
Edit ai_translation_generator.yaml
to add your strings and target languages:
languages:
- en
- ar
- es
- fr
- de
- ja
- ko
strings:
- settings
- home
- profile
- logout
- login
- register
- dashboard
- notifications
- search
- filter
3. Generate Translations #
aitranslation generate
4. Use in Your Flutter App #
The tool generates Flutter l10n compatible files:
lib/l10n/
โโโ en.json
โโโ ar.json
โโโ es.json
โโโ fr.json
โโโ de.json
๐ Output Format #
Generated Files #
lib/l10n/ar.json:
{
"settings": "ุฅุนุฏุงุฏุงุช",
"home": "ุงูุฑุฆูุณูุฉ",
"profile": "ุงูู
ูู ุงูุดุฎุตู",
"logout": "ุชุณุฌูู ุงูุฎุฑูุฌ"
}
lib/l10n/es.json:
{
"settings": "configuraciรณn",
"home": "inicio",
"profile": "perfil",
"logout": "cerrar sesiรณn"
}
๐ Security & Privacy #
- โ No hardcoded API keys - The package doesn't contain any API keys
- โ User-specific keys - Each user provides their own free Gemini API key
- โ Secure storage - Keys are stored in environment variables or .env files
- โ Local processing - API keys never leave your machine
- โ Open source - Full transparency in the codebase
๐ ๏ธ Commands #
Initialize #
aitranslation init
Creates the default configuration file.
Generate Translations #
aitranslation generate
Generates translations for all configured languages.
Help #
aitranslation --help
Shows available commands and usage information.
๐๏ธ Architecture #
lib/
โโโ models/
โ โโโ translation_config.dart # Configuration model
โโโ services/
โ โโโ config_service.dart # Configuration management
โ โโโ gemini_service.dart # Gemini API integration
โ โโโ translation_service.dart # Translation orchestration
โโโ commands/
โ โโโ init_command.dart # Init command
โ โโโ generate_command.dart # Generate command
โโโ utils/
โโโ cli_utils.dart # CLI utilities and formatting
๐ Configuration #
Language Codes #
Use standard ISO 639-1 language codes:
en
- Englishar
- Arabices
- Spanishfr
- Frenchde
- Germanja
- Japaneseko
- Koreanzh
- Chinesept
- Portugueseru
- Russian
Supported Languages #
The tool supports 100+ languages through Google's Gemini AI. See the full list for all supported language codes.
๐จ Error Handling #
The tool includes comprehensive error handling:
- โ Internet connectivity checks
- โ Configuration validation
- โ API error handling
- โ File system error handling
- โ Clear error messages with suggestions
Common Issues #
API Key Not Found:
GEMINI_API_KEY not found. Please set it using one of these methods:
1. Environment variable: export GEMINI_API_KEY=your_api_key_here
2. .env file: Create .env file in project root with GEMINI_API_KEY=your_api_key_here
No Internet Connection:
No internet connection. Please check your network and try again.
๐ค Contributing #
We welcome contributions! Please see our Contributing Guide for details.
Development Setup #
git clone https://github.com/FUZAIL-GIT/ai_translation_generator.git
cd ai_translation_generator
dart pub get
dart test
Running Tests #
dart test
๐ License #
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments #
- Google Gemini AI for providing the translation API
- Flutter l10n for the localization standard
- The Dart community for excellent tooling and packages
๐ Support #
- ๐ Documentation
- ๐ Report Issues
- ๐ฌ Discussions
- โญ Star the Project
๐บ๏ธ Roadmap #
- โ Support for more AI models (OpenAI, Claude)
- โ Batch processing optimization
- โ Custom prompt templates
- โ Translation quality scoring
- โ Integration with popular Flutter packages
- โ VS Code extension
- โ Web interface
Made with โค๏ธ for the Flutter community