An open API service indexing awesome lists of open source software.

https://github.com/fuzail-git/ai_translation_generator

Professional CLI tool for AI-powered translation generation using Google's Gemini AI. Generate Flutter l10n files with ease and support for 100+ languages.
https://github.com/fuzail-git/ai_translation_generator

ai artificial-intelligence auto automation cli clitool dart dart-package flutter gemini generator il8n internationalization l10n localized open-source pub tools translation

Last synced: about 1 month ago
JSON representation

Professional CLI tool for AI-powered translation generation using Google's Gemini AI. Generate Flutter l10n files with ease and support for 100+ languages.

Awesome Lists containing this project

README

          

# AI Translation Generator

[![pub package](https://img.shields.io/pub/v/ai_translation_generator.svg)](https://pub.dev/packages/ai_translation_generator)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

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](https://dart.dev/get-dart) version 3.8.1 or higher

### Global Installation

```bash
dart pub global activate ai_translation_generator
```

### Local Development

```bash
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

1. Visit [Google AI Studio](https://makersuite.google.com/app/apikey)
2. Sign in with your Google account
3. Generate a free API key (no credit card required)

### Configure Your API Key

**Option A: Environment Variable (Recommended)**

```bash
export GEMINI_API_KEY=your_gemini_api_key_here
```

**Option B: .env File**

```bash
# Create .env file in your project root
echo "GEMINI_API_KEY=your_gemini_api_key_here" > .env
```

## ๐Ÿš€ Quick Start

### 1. Initialize Configuration

```bash
aitranslation init
```

This creates a `ai_translation_generator.yaml` file:

```yaml
# 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:

```yaml
languages:
- en
- ar
- es
- fr
- de
- ja
- ko

strings:
- settings
- home
- profile
- logout
- login
- register
- dashboard
- notifications
- search
- filter
```

### 3. Generate Translations

```bash
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:**

```json
{
"settings": "ุฅุนุฏุงุฏุงุช",
"home": "ุงู„ุฑุฆูŠุณูŠุฉ",
"profile": "ุงู„ู…ู„ู ุงู„ุดุฎุตูŠ",
"logout": "ุชุณุฌูŠู„ ุงู„ุฎุฑูˆุฌ"
}
```

**lib/l10n/es.json:**

```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

```bash
aitranslation init
```

Creates the default configuration file.

### Generate Translations

```bash
aitranslation generate
```

Generates translations for all configured languages.

### Help

```bash
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` - English
- `ar` - Arabic
- `es` - Spanish
- `fr` - French
- `de` - German
- `ja` - Japanese
- `ko` - Korean
- `zh` - Chinese
- `pt` - Portuguese
- `ru` - Russian

### Supported Languages

The tool supports 100+ languages through Google's Gemini AI. See the [full list](https://cloud.google.com/translate/docs/languages) 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](CONTRIBUTING.md) for details.

### Development Setup

```bash
git clone https://github.com/FUZAIL-GIT/ai_translation_generator.git
cd ai_translation_generator
dart pub get
dart test
```

### Running Tests

```bash
dart test
```

## ๐Ÿ“„ License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## ๐Ÿ™ Acknowledgments

- [Google Gemini AI](https://ai.google.dev/) for providing the translation API
- [Flutter l10n](https://docs.flutter.dev/development/accessibility-and-localization/internationalization) for the localization standard
- The Dart community for excellent tooling and packages

## ๐Ÿ“ž Support

- ๐Ÿ“– [Documentation](https://github.com/FUZAIL-GIT/ai_translation_generator#readme)
- ๐Ÿ› [Report Issues](https://github.com/FUZAIL-GIT/ai_translation_generator/issues)
- ๐Ÿ’ฌ [Discussions](https://github.com/FUZAIL-GIT/ai_translation_generator/discussions)
- โญ [Star the Project](https://github.com/FUZAIL-GIT/ai_translation_generator)

## ๐Ÿ—บ๏ธ 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