Skip to content

v0.4.0#19

Merged
basemosama merged 4 commits into
mainfrom
qa
Apr 1, 2026
Merged

v0.4.0#19
basemosama merged 4 commits into
mainfrom
qa

Conversation

@basemosama

Copy link
Copy Markdown
Member

0.4.0

  • Enhanced Locale Config: Added useFallbackTranslationsForEmptyResources, ignorePluralRules, extraAssetLoaders, and errorWidget to PlayxLocaleConfig.
  • Script Code Support: Added scriptCode natively to XLocale and updated locale matching in PlayxLocaleController to properly utilize it.
  • Deep Translation Merging: TranslationManager now supports combining JSON translation maps securely from multiple asset loaders.
  • Device Sync Persistence: updateToDeviceLocale() now saves a special flag in preferences (index -1). When the application boots, instead of overriding the device's current locale with a historically cached exact locale or startLocale, the controller auto-routes strictly to whatever the current deviceLocale dictates. This allows developers to offer a persistent "system default" setting.
  • Synchronous Any-Locale Translation: Added preloadSupportedLocales to PlayxLocaleConfig. When enabled, it caches all dictionaries during initialization, allowing developers to query translations for any loaded Locale? locale parametrically using tr(..., locale: ...) synchronously, completely out-of-bounds, without overriding the app environment.

…oaders

This update introduces several enhancements to the localization system, including support for script codes, the ability to resolve linked translation files, and support for multiple asset loaders.

Key changes:
- **XLocale & Locale Extensions**: Added `scriptCode` support to `XLocale` and updated `XLocaleExtension` to handle `Locale.fromSubtags` when a script code is present.
- **Linked Files Support**: Introduced `LinkedFileResolver` and `JsonLinkedFileResolver` to allow translations to reference other JSON files using the `:/filename.json` syntax.
- **Flexible File Loading**: Added `FileLoader` interface with `RootBundleFileLoader` (for Flutter) and `IOFileLoader` (for CLI/Dart IO) implementations.
- **AssetLoader Enhancements**: `AssetLoader` now requires a `fileLoader` and `linkedFileResolver`. `RootBundleAssetLoader` includes factory methods for root bundle and IO-based loading.
- **Multiple Asset Loaders**: `PlayxLocaleConfig` now accepts `extraAssetLoaders`, and `TranslationManager` has been updated to merge translation data from all provided loaders recursively.
- **New Configuration Options**: Added `useFallbackTranslationsForEmptyResources`, `ignorePluralRules`, and a custom `errorWidget` to `PlayxLocaleConfig`.
- **Controller Improvements**:
    - Updated locale searching to use `Locale.supports` for better matching.
    - Enhanced `updateToDeviceLocale` and added `resetLocale` to better handle platform-specific locale detection.
    - Updated translation loading logic to pass new configuration flags to the underlying `Localization` instance.
feat: Update dependencies and improve cross-platform file loading

This release introduces support for conditional imports for the `IOFileLoader` to ensure compatibility with web platforms where `dart:io` is unavailable.

Other changes include:
- Bumping `playx_core` to `^1.0.0`.
- Updating `flutter_secure_storage` to `v10.0.0` and migrating macOS/iOS integration to use `flutter_secure_storage_darwin`.
- Bumping SDK constraints to Dart `^3.9.0` and Flutter `^3.35.0`.
- Updating various internal dependencies including `get_it`, `shared_preferences`, and `meta`.
- Adding new localization features: fallback translations for empty resources, `scriptCode` support in `XLocale`, deep translation merging, and device sync reset.
- Updating package version to `0.4.0`.
- **Synchronous Any-Locale Translation**: Added `preloadSupportedLocales` to `PlayxLocaleConfig`. When enabled, it caches all dictionaries during initialization, allowing developers to query translations for any loaded `Locale? locale` parametrically using `tr(..., locale: ...)` synchronously, completely out-of-bounds, without overriding the app environment.
- **Device Sync Persistence**: `updateToDeviceLocale()` now saves a special flag in preferences (index `-1`). When the application boots, instead of overriding the device's current locale with a historically cached exact locale or `startLocale`, the controller auto-routes strictly to whatever the current `deviceLocale` dictates. This allows developers to offer a persistent "system default" setting.
@basemosama basemosama merged commit d0890d8 into main Apr 1, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant