playx_localization 0.2.0 playx_localization: ^0.2.0 copied to clipboard
Easily manage and update app localization with a simple implementation and a lot of utilities.
Changelog #
0.2.0 #
Note: This release contains breaking changes.
- Migrated shared preferences to
SharedPreferencesAsync
for improved performance and async handling. If you're upgrading, setmigratePrefsToAsyncPrefs
totrue
inPlayxLocaleConfig
to ensure a smooth transition. - Add new
logMissingKeys
parameter toPlayxLocaleConfig
to enable or disable logging missing keys in the console. - Removed dependencies on GetX package.
- No need to call
await PlayXCore.bootCore();
before using the localization package anymore. The package will automatically initialize the core when needed.
0.1.2 #
- Fix bug causing locale to not be saved correctly.
0.1.1 #
- enhance log messages.
0.1.0 #
Note: This release contains breaking changes.
New Features #
General Updates
- Package Updates: All packages have been updated.
intl
Package: Upgraded to version 0.19.0.
PlayxLocalizationBuilder
-
Improved Locale Management: Now uses an
InheritedWidget
to provide locale to child widgets, enhancing locale management and widget rebuilds. -
Simplified Localization Access:
- Retrieve localized text using:
'text'.tr(context: context)
context.tr()
Text('text').tr(context: context)
- New
BuildContext
extensions:context.tr()
andcontext.plural
for easy access to localized text.
Providing context to the
tr
function ensures widgets are rebuilt correctly when the locale changes. - Retrieve localized text using:
-
For classes without context, you can still use the
tr
function without context, though note that widgets will not rebuild on locale changes when used this way, But there is an option to force app update on locale change.
PlayxLocalization
- Added a getter to retrieve the app's fallback locale.
- Added a function to get the current locale as a string with a custom separator.
- Added a function to determine if the current locale is right-to-left (RTL).
PlayxLocaleController
- Switched from
GetxController
toValueNotifier
, reducing reliance on theGetX
package. - Updated methods (
updateTo
,updateByIndex
,updateById
,next
,updateByLanguageCode
,updateToDeviceLocale
) now include aforceAppUpdate
parameter to allow a full app rebuild when changing the locale.
Breaking Changes #
XLocaleConfig
has been renamed toPlayxLocaleConfig
to align with the package name. -PlayxLocaleConfig
is no longer abstract and can be instantiated directly.PlayxLocaleConfig
now requires default and supported locales to be provided at instantiation.- The
tr
extension onString
has been updated to a function that accepts context and additional parameters.
0.0.5 #
- Update packages.
0.0.4 #
- Update packages.
- Bump Intl version to 0.18.1.
0.0.3 #
- Update packages.
- Bump dart version to 3.0.0.
- Add number extensions for
num
to format number to localized numbers String like arabic numbers. - Add
String
extensions to check if string is rtl or is of specifc language.
0.0.2 #
- Update packages.
0.0.1 #
- Initial release.