arb_translator_gen_z library
ARB Translator Gen Z - Modern, enterprise-grade ARB file translation tool.
A comprehensive Dart library for translating ARB (Application Resource Bundle) files with advanced features designed for production Flutter applications.
Features (v3.3.0)
- 100+ Language Support: Translate to over 100 languages with native names and regional variants
- Translation Memory: Intelligent caching system reducing API calls by up to 70%
- Incremental Translation: Smart diff detection for translating only changed strings
- Interactive & Watch Modes: Step-by-step translation and automatic file watching
- Batch Processing: Concurrent translation with enhanced performance (5 parallel requests)
- Enterprise Reliability: Retry logic, rate limiting, and comprehensive error handling
- ARB Validation: Pre and post-translation validation with specific error locations
- Flexible Configuration: YAML-based configuration with multiple named profiles
- Rich CLI Interface: Professional command-line tools with colored output and emoji indicators
- Detailed Logging: Structured logging with ETA and throughput metrics
Quick Start
Programmatic Usage
import 'package:arb_translator_gen_z/arb_translator_gen_z.dart';
Future<void> main() async {
// Load configuration
final config = await TranslatorConfig.fromFile();
// Create translator
final translator = ArbTranslator(config);
try {
// Translate to French
await translator.generateForLanguage('lib/l10n/app_en.arb', 'fr');
// Batch translate to multiple languages
await translator.generateMultipleLanguages(
'lib/l10n/app_en.arb',
['es', 'de', 'it', 'pt'],
);
} finally {
translator.dispose();
}
}
CLI Usage
# Install globally
dart pub global activate arb_translator_gen_z
# Translate to specific languages
arb_translator -s lib/l10n/app_en.arb -l "fr es de"
# Translate to all supported languages
arb_translator -s lib/l10n/app_en.arb -l all
# Validate ARB files
arb_translator -s lib/l10n/app_en.arb --validate-only
Advanced Features
Custom Configuration
final config = TranslatorConfig(
maxConcurrentTranslations: 10,
retryAttempts: 5,
logLevel: LogLevel.debug,
validateOutput: true,
);
Error Handling
try {
await translator.generateForLanguage('source.arb', 'fr');
} on ArbFileNotFoundException catch (e) {
print('Source file not found: ${e.filePath}');
} on TranslationApiException catch (e) {
print('API error ${e.statusCode}: ${e.details}');
}
Language Utilities
// Get language information
final info = getLanguageInfo('fr');
print('${info?.name}: ${info?.nativeName}'); // French: Français
// Validate and suggest languages
final validated = validateLangCode('FR'); // returns 'fr'
final suggestions = suggestLanguageCodes('fren'); // ['fr']
Enterprise Integration
This library is designed for production use with features like:
- CI/CD Integration: Validation-only mode for build pipelines
- Configuration Management: Environment-specific settings
- Monitoring: Detailed logging and error reporting
- Scalability: Concurrent processing with rate limiting
- Reliability: Comprehensive error handling and retry logic
For complete documentation and examples, visit: https://github.com/sauravkhanalgit/arb_translator
Classes
- AIModelConfig
- Configuration for AI model integration.
- AIProvider
- Base class for AI-powered translation providers.
- AIProviderManager
- Manages multiple AI translation providers and provides intelligent selection.
- AnalyticsEvent
- Analytics event for tracking usage.
- AnalyticsIntegration
- Integration utilities for analytics in translation workflows.
- AnalyticsManager
- Comprehensive analytics and reporting system.
- AnalyticsPlugin
- Plugin for custom analytics and reporting.
- ArbAnalysisResult
- Result of ARB file analysis.
- ArbFileAnalysis
- Analysis result for a single ARB file.
- ArbHelper
- Enhanced ARB file operations with comprehensive validation and error handling.
- AuditEntry
- Audit log entry for compliance tracking.
- AWSProvider
- Amazon Web Services Translate provider.
- AzureProvider
- Microsoft Azure Translator provider.
- CollaborationManager
- Real-time collaboration manager for team translation workflows. Provides conflict resolution, review workflows, and live synchronization.
- ComplexString
- Represents a complex string with placeholders and special patterns.
- ComplexStringProcessor
- Processor for handling complex strings in translations.
- ComplianceIntegration
- Integration utilities for compliance in translation workflows.
- ComplianceManager
- Comprehensive compliance manager for GDPR, audit logging, and data retention.
- ConflictResolution
- Result of a conflict resolution decision.
- ConflictResolutionResult
- Result of conflict resolution.
- CustomValidationPlugin
- Example plugin: Custom Validation Rules
- DeepLProvider
- DeepL provider for high-quality neural machine translation.
- DistributedCoordinator
- Distributed processing coordinator for large-scale translation projects. Splits work across multiple workers and coordinates results.
- DistributedWorker
- Distributed worker that processes translation tasks.
- FuzzyMatch
- Fuzzy matching result.
- HookPlugin
- Interface for plugins that implement specific hooks.
- LanguageInfo
- Language information and validation for ARB translation.
- LocalizationTranslator
- Enhanced localization file translator with parallel processing and comprehensive error handling.
- OpenAIProvider
- OpenAI GPT provider for high-quality translations.
- PluginContext
- Context information passed to plugin hooks.
- PluginManager
- Plugin manager that handles loading, unloading, and executing plugins.
- PluginResult
- Result returned by plugin hook execution.
- PluralizationResult
- Result of pluralization processing.
- PrivacySettings
- Privacy settings for GDPR compliance.
- ProcessingResult
- Result of string preprocessing.
- QualityReporterPlugin
- Example plugin: Translation Quality Reporter
- QualityScorer
- Quality scorer for evaluating translation quality.
- RetentionPolicy
- Data retention policy configuration.
- TermEntry
- Represents a term in the terminology database.
- TerminologyIntegration
- Integration utilities for terminology in translation workflows.
- TerminologyLookupResult
- Result of terminology lookup.
- TerminologyManager
- Advanced terminology management with glossary synchronization.
- TranslationConflict
- Represents a conflict between two translation updates.
- TranslationEntry
- Translation memory entry with metadata.
- TranslationMemory
- Advanced translation memory with fuzzy matching and learning capabilities.
- TranslationMetrics
- Translation metrics for performance tracking.
- TranslationProviderPlugin
- Plugin for custom translation providers.
- TranslationResult
- Represents a translation result with quality scoring.
- TranslationService
- Enhanced translation service with retry logic, rate limiting, and comprehensive error handling.
- TranslationUpdate
- Represents a translation update applied to a collaborative project.
- TranslatorConfig
- Configuration settings for the ARB translator.
- TranslatorLogger
- A centralized logging service for the ARB translator.
- TranslatorPlugin
- Represents a plugin for the ARB translator.
- UserEngagementMetrics
- User engagement metrics.
- ValidationPlugin
- Plugin for custom validation rules.
- WebServer
- Web server for the ARB Translator GUI.
Enums
- ConflictResolutionStrategy
- Conflict resolution strategies.
- LogLevel
- Logging levels for console output.
- MatchType
- Types of fuzzy matches.
- PluginHook
- Hook points in the translation process where plugins can intervene.
- ReviewDecision
- Review decisions.
- ReviewStatus
- Review statuses.
- TermPriority
- Priority levels for terminology terms.
- TranslationProvider
- Available translation providers.
Extensions
-
ListExtension
on List<
T> - Extension methods for List.
- LoggerExtensions on Object
- Extension methods for easier logging.
Constants
-
supportedLanguages
→ const Map<
String, LanguageInfo> - Comprehensive list of supported languages with detailed information.
Properties
-
popularLanguageCodes
→ List<
String> -
Gets a list of popular language codes commonly used in mobile apps.
no setter
-
rightToLeftLanguages
→ List<
String> -
Gets languages that use right-to-left writing systems.
no setter
-
supportedLangCodes
→ Set<
String> -
A set of all supported ISO-639 language codes for translation.
no setter
Functions
-
formatLanguageList(
List< String> codes) → List<String> - Formats a list of language codes with their native names.
-
generateArbForLanguage(
String sourcePath, String targetLang) → Future< void> - @deprecated Use LocalizationTranslator.generateForLanguage instead.
-
getLanguageInfo(
String code) → LanguageInfo? -
Gets language information for the given
code. -
readArbFile(
String path) → Future< Map< String, dynamic> > - @deprecated Use ArbHelper.readArbFile instead.
-
suggestLanguageCodes(
String code) → List< String> -
Suggests similar language codes if the given
codeis not found. -
translateText(
String text, String targetLang) → Future< String> - @deprecated Use TranslationService.translateText instead.
-
validateLangCode(
String code) → String -
Validates the given
codeas a supported language code. -
writeArbFile(
String path, Map< String, dynamic> content) → Future<void> - @deprecated Use ArbHelper.writeArbFile instead.
Typedefs
- ArbTranslator = LocalizationTranslator
- Backward-compatible alias for LocalizationTranslator.
Exceptions / Errors
- AIProviderException
- Exception thrown when AI provider operations fail.
- ArbException
- Base exception class for all ARB-related errors.
- ArbFileFormatException
- Exception thrown when an ARB file has invalid JSON format.
- ArbFileNotFoundException
- Exception thrown when an ARB file cannot be found.
- ArbFileWriteException
- Exception thrown when an ARB file cannot be written.
- ArbValidationException
- Exception thrown when ARB file validation fails.
- ConfigurationException
- Exception thrown when configuration parsing fails.
- InvalidTranslationTextException
- Exception thrown when translation text is invalid or empty.
- TranslationApiException
- Exception thrown when a translation API call fails.
- TranslationException
- Base exception class for all translation-related errors.
- TranslationRateLimitException
- Exception thrown when translation rate limit is exceeded.
- Exception thrown when translation service is temporarily unavailable.
- UnsupportedLanguageException
- Exception thrown when a language code is not supported.