smart_arb_translator 1.3.6
smart_arb_translator: ^1.3.6 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.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.dev 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.dev Score: Meets pub.dev 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:generate
with 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_source
instead oflib/l10n
to avoid confusion with output directory
Technical Details #
- Fixed type casting issue in
_updateMergedResult
method 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_method
now 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_loading
parameter for Flutter Web optimization - ๐ฑ Flutter Web Performance: Enable deferred loading to reduce initial bundle size for web applications
- โ๏ธ Full Configuration Support:
use_deferred_loading
parameter available in both CLI and pubspec.yaml configuration - ๐ง Dual Generator Support: Works with both
gen-l10n
andintl_utils
localization 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_loading
flag - pubspec.yaml:
use_deferred_loading: true/false
- CLI:
- Generator Integration:
- gen-l10n: Adds
use-deferred-loading: true
tol10n.yaml
- intl_utils: Adds
use_deferred_loading: true
toflutter_intl
section 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.yaml
file under thesmart_arb_translator
section - ๐ 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_translator
command 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-l10n
orintl_utils
package - ๐ค Intelligent Auto-Detection: Automatically detects existing localization setup and chooses the appropriate method
- ๐ Auto-Configuration: Automatically creates
l10n.yaml
or configurespubspec.yaml
based on chosen method - ๐ง Method Selection: New
--l10n_method
parameter to explicitly choose betweengen-l10n
andintl_utils
- ๐พ Preference Persistence: Saves user's localization method choice in
pubspec.yaml
for future runs - โ
Auto-Approve Option: New
--auto_approve
flag to automatically approve configuration changes
Enhanced #
- ๐ง Smart Method Detection: Automatically detects:
- Existing
l10n.yaml
file โ Usesgen-l10n
- Existing
intl_utils
dependency orflutter_intl
config โ Usesintl_utils
- Saved preference in
pubspec.yaml
โ Uses saved method - No setup found โ Prompts user to choose (or defaults to
intl_utils
with--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-l10n
orintl_utils
--auto_approve
: Automatically approve configuration changes
- Auto-Configuration Features:
- Creates
l10n.yaml
with proper paths and class names forgen-l10n
- Adds
intl_utils
dependency andflutter_intl
config 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-translations
metadata - ๐ ๏ธ 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_translator
tosmart_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.