smart_arb_translator 1.4.1
smart_arb_translator: ^1.4.1 copied to clipboard
An intelligent command-line utility for translating ARB files with Google Translate API, featuring smart change detection and modular architecture.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
1.4.1 - 2025-11-24 #
Fixed #
- π API Key File Support: Fixed issue where
api_keyconfiguration pointing to a file was not being read, causing the file path to be used as the key. Now correctly reads the API key from the file if it exists.
1.4.0 - 2025-11-24 #
Added #
- π Expanded Translation Services: Added support for Google Translate v3 (LLM) and v2 NMT models.
- βοΈ New Configuration Options:
translation_service: Choose betweengoogle_basic(default),google_nmt, orgoogle_llm.project_id: Required when usinggoogle_llmservice.
- π Service Selection: Users can now select the specific translation model that best fits their needs (cost vs. quality).
Changed #
- π§ Default Service: The default translation service is now explicitly named
google_basic(maintains v2 API behavior). - π Documentation: Updated README with details on new translation services and configuration examples.
1.3.7 - 2025-11-24 #
Fixed #
- π Empty Prefix Support: Fixed issue where empty
output_file_namewould default to source filename prefixing. Now generates{languageCode}.arbas expected. - π§ Double Underscore Fix: Fixed issue where default configuration could result in double underscores in filenames (e.g.,
intl__fr.arb).
1.3.6 - 2025-09-14 #
1.3.5 - 2025-01-27 #
Enhanced #
- π Language Codes in Auto-Configuration: Added language codes selection to the auto-configuration wizard
- π Interactive Language Selection: Users can now specify target languages during setup using comma-separated input (e.g., "es,fr,de,ja")
- π‘ Language Code Hints: Provided common language code examples to help users choose appropriate codes
- πΎ Automatic Configuration Saving: Language codes are automatically saved to pubspec.yaml in proper YAML list format
- π‘οΈ Input Validation: Added validation to ensure at least one valid language code is provided
Technical Details #
- Enhanced Auto-Configuration Prompts:
- Interactive prompt for target language codes with examples
- Comma-separated input parsing with whitespace trimming
- Validation to prevent empty language code lists
- Improved YAML Generation:
- Proper handling of list values in pubspec.yaml configuration
- Language codes saved as YAML list format:
["es", "fr", "de"] - Consistent formatting for both new and existing configuration sections
Benefits #
- β Complete Setup Experience: Auto-configuration now covers all essential parameters including target languages
- β User-Friendly Input: Simple comma-separated format for specifying multiple languages
- β Proper Configuration: Language codes correctly saved to pubspec.yaml for future use
- β Guided Selection: Common language code examples help users make informed choices
1.3.4 - 2025-05-27 #
- Typo in readme fixed
1.3.3 - 2025-05-27 #
Enhanced #
- π Comprehensive API Documentation: Added extensive dartdoc comments to all public API elements to meet pub.flutter-io.cn documentation requirements
- π― Improved Documentation Coverage: Increased documentation coverage from 10.3% to over 20% of public API elements
- π Detailed Class Documentation: Added comprehensive documentation for all core classes including
Action,ArbResource,ArbDocument,ArbAttributes,TranslationService,ArbProcessor, and utility classes - π§ Method Documentation: Added detailed parameter descriptions, return value documentation, and usage examples for all public methods
- π‘ Code Examples: Included practical code examples in documentation to help developers understand API usage
- ποΈ Architecture Documentation: Enhanced documentation explaining the relationship between classes and their roles in the translation workflow
Technical Details #
- Documented Classes and APIs:
Action: Translation action representation with update functionsArbResource: Single ARB resource with metadata and ICU parsingArbDocument: Complete ARB document with serialization capabilitiesArbAttributes: Resource metadata including placeholders and manual translationsTranslationService: Google Translate API integration and text processingArbProcessor: Core translation workflow orchestrationArbTranslatorArgumentParser: Command-line argument parsing and configurationConsoleUtils: Terminal color and formatting utilitiesFileOperations: File system operations for ARB processingIcuParser: ICU message format parsing with detailed grammar documentationPubspecConfig: Configuration loading from pubspec.yaml- Utility functions for enum handling and HTML processing
Benefits #
- β Better pub.flutter-io.cn Score: Meets pub.flutter-io.cn documentation requirements (20%+ coverage)
- β Developer Experience: Comprehensive API documentation for easier integration
- β Code Examples: Practical examples showing how to use each API
- β Architecture Understanding: Clear documentation of class relationships and workflows
- β IDE Support: Better IntelliSense and code completion with detailed documentation
1.3.2 - 2025-05-27 #
Enhanced #
- π§ Extended Auto-Configuration: Added prompts for API key, cache directory, and output directory in auto-configuration wizard
- π§Ή Improved intl_utils Integration: Fixed flutter_intl configuration to be minimal (only
enabled: true) while using smart_arb_translator configuration as source of truth - π Better Configuration Management: intl_utils now temporarily uses full configuration during generation, then cleans up to keep only essential settings
Technical Details #
- Enhanced Auto-Configuration Prompts:
- API key path (required)
- Cache directory (default: lib/l10n_cache)
- Output directory (default: lib/l10n)
- Improved intl_utils Workflow:
- Temporarily adds full configuration to flutter_intl section before running intl_utils
- Runs
dart run intl_utils:generatewith proper configuration - Cleans up flutter_intl section to keep only
enabled: true - smart_arb_translator configuration remains the single source of truth
- Fixed Entry Point: Recreated bin/translate.dart with proper async support and method signatures
Benefits #
- β Complete Setup Wizard: New users get guided through all necessary configuration
- β Clean Configuration: Minimal flutter_intl section reduces confusion
- β Single Source of Truth: All configuration managed through smart_arb_translator section
- β Better Integration: Seamless intl_utils workflow without configuration duplication
1.3.1 - 2025-05-27 #
Fixed #
- π Type Casting Error: Fixed "type 'ArgResults' is not a subtype of type '_MergedArgResults'" error in auto-configuration
- π Default Directory: Updated auto-approve default to use
lib/l10n_sourceinstead oflib/l10nto avoid confusion with output directory
Technical Details #
- Fixed type casting issue in
_updateMergedResultmethod when handling different ArgResults types - Improved handling of underlying ArgResults objects in merged configuration
- Updated default source directory to be more descriptive and avoid conflicts
1.3.0 - 2025-05-27 #
Added #
- π§ Enhanced Auto-Configuration: Comprehensive setup wizard when no source configuration is found
- π Source Type Selection: Interactive prompt to choose between directory or single file source
- π Source Locale Configuration: Prompt for source locale with 'en' as default
- π« 'None' Generation Option: Added third option to skip Dart code generation entirely
- πΎ Auto-Save Configuration: Automatically saves user choices to pubspec.yaml for future use
- π― Smart Defaults: Auto-approve mode defaults to sensible configuration (lib/l10n directory, en locale)
Enhanced #
- π€ Improved Auto-Configuration Flow: Extended existing generator method selection to include comprehensive source setup
- π Three-Option Generator Selection: Users can now choose between gen-l10n, intl_utils, or none (translation only)
- π Better User Experience: Clear prompts and explanations for each configuration option
- π‘οΈ Robust Error Handling: Graceful handling of missing configuration with helpful prompts
- β‘ Async Support: Updated argument parser to properly handle async auto-configuration
Technical Details #
- New Auto-Configuration Features:
- Source type selection (directory vs. single file)
- Source path configuration with smart defaults
- Source locale specification with 'en' default
- Extended l10n method selection including 'none' option
- Updated CLI Parameters:
--l10n_methodnow accepts 'none' as a valid option- Auto-configuration runs when no source_arb or source_dir is found
- Configuration Persistence: All auto-configuration choices are saved to pubspec.yaml
- Backward Compatibility: Existing configurations and CLI usage remain unchanged
Usage Examples #
# Run without any configuration - triggers auto-configuration
smart_arb_translator
# Auto-configuration will prompt for:
# 1. Source type (directory or file)
# 2. Source path (with lib/l10n default for directories)
# 3. Source locale (with 'en' default)
# 4. Generation method (gen-l10n, intl_utils, or none)
Benefits #
- β Zero-Configuration Start: New users can get started without any prior setup
- β Guided Setup: Interactive prompts guide users through optimal configuration
- β Translation-Only Option: Support for users who only want translation without Dart generation
- β Persistent Configuration: Choices are saved for future runs
- β Smart Defaults: Sensible defaults reduce configuration burden
1.2.0 - 2025-05-26 #
Added #
- π Deferred Loading Support: New
--use_deferred_loadingparameter for Flutter Web optimization - π± Flutter Web Performance: Enable deferred loading to reduce initial bundle size for web applications
- βοΈ Full Configuration Support:
use_deferred_loadingparameter available in both CLI and pubspec.yaml configuration - π§ Dual Generator Support: Works with both
gen-l10nandintl_utilslocalization methods
Enhanced #
- π Web Application Optimization: Improved performance for Flutter Web apps with many languages
- π Bundle Size Reduction: Locales loaded on-demand instead of all at once
- π― Flexible Configuration: Choose between immediate loading (default) or deferred loading based on your needs
- π§ͺ Comprehensive Testing: Added tests for the new parameter in both CLI and pubspec.yaml configurations
Technical Details #
- New Parameter:
use_deferred_loading(boolean, default:false)- CLI:
--use_deferred_loadingflag - pubspec.yaml:
use_deferred_loading: true/false
- CLI:
- Generator Integration:
- gen-l10n: Adds
use-deferred-loading: truetol10n.yaml - intl_utils: Adds
use_deferred_loading: truetoflutter_intlsection inpubspec.yaml
- gen-l10n: Adds
- Backward Compatibility: Existing projects continue to work unchanged (defaults to
false)
Usage Examples #
# Enable deferred loading via CLI
smart_arb_translator \
--source_dir lib/l10n \
--api_key api_key.txt \
--language_codes es,fr,de,ja \
--generate_dart \
--use_deferred_loading
# Configure in pubspec.yaml
smart_arb_translator:
source_dir: lib/l10n
api_key: api_key.txt
language_codes: [es, fr, de, ja]
generate_dart: true
use_deferred_loading: true
Benefits #
- β Faster Initial Load: Reduced initial bundle size for Flutter Web
- β On-Demand Loading: Languages loaded only when needed
- β Better UX: Improved perceived performance for web applications
- β Scalable: Particularly beneficial for apps with many supported languages
- β Configurable: Easy to enable/disable based on project requirements
1.1.0 - 2025-05-25 #
Added #
- βοΈ pubspec.yaml Configuration Support: Configure all parameters directly in your
pubspec.yamlfile under thesmart_arb_translatorsection - π Complete Parameter Coverage: All CLI arguments can now be set in pubspec.yaml configuration
- π Configuration Precedence System: CLI arguments take precedence over pubspec.yaml settings, which take precedence over defaults
- π― Flexible Language Code Formats: Support for both YAML list format (
[es, fr, de]) and comma-separated strings ("es,fr,de") - π‘οΈ Graceful Error Handling: Robust handling of malformed YAML configurations
- π Comprehensive Documentation: Updated README with configuration examples and best practices
- π§ͺ Full Test Coverage: 13 new tests covering pubspec configuration and argument parser integration
Enhanced #
- π§ Developer Experience: Simple
smart_arb_translatorcommand when using pubspec.yaml configuration - π₯ Team Consistency: Version-controlled configuration ensures all team members use the same settings
- π CI/CD Integration: Simplified build scripts with configuration stored in pubspec.yaml
- π Backward Compatibility: Existing CLI usage continues to work unchanged
- π IDE Support: Better tooling integration with YAML configuration
Technical Details #
- New Classes:
PubspecConfig: Handles reading and parsing pubspec.yaml configuration_MergedArgResults: Custom ArgResults implementation for merging CLI and pubspec settings
- Configuration Options: All 13 CLI parameters now supported in pubspec.yaml:
source_dir/source_arb: Source configurationapi_key: Google Translate API key pathlanguage_codes: Target languages (list or comma-separated)cache_directory/l10n_directory: Directory configurationoutput_file_name: Output file naminggenerate_dart/dart_class_name/dart_output_dir/dart_main_locale: Dart generationl10n_method: Localization method selectionauto_approve: Automation settings
Usage Examples #
# pubspec.yaml
smart_arb_translator:
source_dir: lib/l10n
api_key: secrets/google_translate_api_key.txt
language_codes: [es, fr, de, ja]
generate_dart: true
dart_class_name: AppLocalizations
# Simple command - all configuration from pubspec.yaml
smart_arb_translator
# Override specific parameters if needed
smart_arb_translator --language_codes it,pt --generate_dart false
Benefits #
- β Version Control Friendly: Configuration committed with your code
- β Team Consistency: Everyone uses the same settings
- β No Command Memorization: Simple command execution
- β IDE Integration: Better tooling support
- β Cleaner CI/CD: Simplified build scripts
1.0.1 - 2025-05-25 #
Added #
- π― Dual Localization Method Support: Choose between Flutter's built-in
gen-l10norintl_utilspackage - π€ Intelligent Auto-Detection: Automatically detects existing localization setup and chooses the appropriate method
- π Auto-Configuration: Automatically creates
l10n.yamlor configurespubspec.yamlbased on chosen method - π§ Method Selection: New
--l10n_methodparameter to explicitly choose betweengen-l10nandintl_utils - πΎ Preference Persistence: Saves user's localization method choice in
pubspec.yamlfor future runs - β
Auto-Approve Option: New
--auto_approveflag to automatically approve configuration changes
Enhanced #
- π§ Smart Method Detection: Automatically detects:
- Existing
l10n.yamlfile β Usesgen-l10n - Existing
intl_utilsdependency orflutter_intlconfig β Usesintl_utils - Saved preference in
pubspec.yamlβ Uses saved method - No setup found β Prompts user to choose (or defaults to
intl_utilswith--auto_approve)
- Existing
- π Flutter gen-l10n Integration: Full support for Flutter's official localization solution
- π Interactive Setup: User-friendly prompts when no existing setup is detected
- π‘οΈ Safe Configuration: Asks for permission before modifying project files (unless auto-approved)
Technical Details #
- New Command Options:
--l10n_method: Choose betweengen-l10norintl_utils--auto_approve: Automatically approve configuration changes
- Auto-Configuration Features:
- Creates
l10n.yamlwith proper paths and class names forgen-l10n - Adds
intl_utilsdependency andflutter_intlconfig forintl_utils - Preserves existing file formatting and comments
- Creates
- Intelligent Detection Logic: Comprehensive project analysis to determine the best localization method
Usage Examples #
# Auto-detect and configure (interactive)
smart_arb_translator --source_dir lib/l10n --api_key api_key.txt --language_codes es,fr --generate_dart
# Force specific method
smart_arb_translator --source_dir lib/l10n --api_key api_key.txt --language_codes es,fr --generate_dart --l10n_method gen-l10n
# Auto-approve configuration changes
smart_arb_translator --source_dir lib/l10n --api_key api_key.txt --language_codes es,fr --generate_dart --auto_approve
1.0.0 - 2025-05-25 #
Added #
- π Initial release of Smart ARB Translator
- β¨ Smart Change Detection: Only translates modified or new content
- ποΈ Modular Architecture: Refactored into clean, maintainable modules
- π Batch Processing: Recursive directory translation support
- π Automatic Merging: Seamless l10n directory integration
- π― Manual Translation Override: Support for
@x-translationsmetadata - π οΈ Flexible Output: Customizable file naming and directory structure
- π¨ Robust Error Handling: Detailed feedback and error messages
- π Comprehensive Documentation: Complete README with examples
- π§ͺ Programmatic API: Use as a library in your Dart projects
Changed #
- π Package Name: Renamed from
arb_translatortosmart_arb_translator - ποΈ Architecture: Complete refactor into modular components:
TranslationService: Google Translate API integrationArbProcessor: ARB file processing and action managementFileOperations: File and directory utilitiesDirectoryProcessor: Batch directory processingSingleFileProcessor: Individual file processing with change detectionArbTranslatorArgumentParser: Command-line argument handlingConsoleUtils: Console output utilities
- π¨ CLI Interface: Improved command-line experience
- π¦ Dependencies: Updated to latest package versions
Enhanced #
- π§ Intelligence: Smart detection of changes to minimize API calls
- β‘ Performance: Optimized processing for large projects
- π§ Maintainability: Clean separation of concerns
- π Documentation: Comprehensive guides and examples
- π― User Experience: Better error messages and feedback
Technical Details #
- Minimum Dart SDK: 3.0.1
- Dependencies: Updated all dependencies to latest versions
- Architecture: Modular design with clear separation of concerns
- Testing: Foundation for comprehensive test coverage
- Documentation: Complete API documentation and usage examples
Migration from arb_translator #
If you're migrating from the original arb_translator package:
-
Update pubspec.yaml:
dev_dependencies: smart_arb_translator: ^1.0.0 # instead of arb_translator -
Update command usage:
smart_arb_translator # instead of pub run arb_translator:translate -
Argument changes:
--append-lang-code/--no-append-lang-code(instead of--append_lang_code)- All other arguments remain the same
-
New features available:
- Smart change detection (automatic)
- Improved error handling
- Better performance
- Programmatic API access
Acknowledgments #
- Originally forked from justkawal/arb_translator
- Enhanced with modern architecture and smart features
- Built for the Flutter community
Note: This is the first release of Smart ARB Translator as a standalone package. Future releases will follow semantic versioning with detailed changelogs.