v0.4.0#19
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
0.4.0
useFallbackTranslationsForEmptyResources,ignorePluralRules,extraAssetLoaders, anderrorWidgettoPlayxLocaleConfig.scriptCodenatively toXLocaleand updated locale matching inPlayxLocaleControllerto properly utilize it.TranslationManagernow supports combining JSON translation maps securely from multiple asset loaders.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 orstartLocale, the controller auto-routes strictly to whatever the currentdeviceLocaledictates. This allows developers to offer a persistent "system default" setting.preloadSupportedLocalestoPlayxLocaleConfig. When enabled, it caches all dictionaries during initialization, allowing developers to query translations for any loadedLocale? localeparametrically usingtr(..., locale: ...)synchronously, completely out-of-bounds, without overriding the app environment.