- added option allowing skip keys of nested object
- fixed plural bug
- fixed typos
- BREAKING: Added
EasyLocalization.ensureInitialized()
, Needs to be called - BREAKING: Added support null safety
- BREAKING: removed context parameter from
plural()
andtr()
- Added Formatting linked translations more
- Updated
plural()
function, with arguments morevar money = plural('money_args', 10.23, args: ['John', '10.23']) // output: John has 10.23 dollars
- Removed preloader widget
preloaderWidget
- fixed many issues.
- customizable logger [EasyLogger]
- device locale and reset device locale
- extensions helpers
- support fallback locale keys redirection
- Updated pubspec dependencies
- Added --source-file argument in codegen
- Updates generated tool.
- Updated
plural()
function, now she is not strict. - Updates print and log messages
- Added extension methods on [BuildContext] for access to Easy Localization
🔥 It's more easiest way change locale or get parameters
context.locale = locale;
ℹ️ No breaking changes, you can use old the static method EasyLocalization.of(context)
- Added
preloaderWidget
. - Fixed many issues.
- Added
startLocale
.
-
Added support Locale scriptCode.
-
Added
EasyLocalization.of(context).delegates
forlocalizationsDelegates
supportedLocales: [ Locale('en', 'US'), Locale('ar', 'DZ'), Locale('ar','DZ'),localeFromString('ar_DZ') ]
-
Added support Custom assets loaders Easy Localization Loader.
-
Added support CSV files.
path: 'resources/langs/langs.csv', assetLoader: CsvAssetLoader(),
-
Added support Yaml files.
path: 'resources/langs', assetLoader: YamlAssetLoader(),
path: 'resources/langs/langs.yaml', assetLoader: YamlSingleAssetLoader(),
-
Added support XML files.
path: 'resources/langs', assetLoader: XmlAssetLoader(),
path: 'resources/langs/langs.xml', assetLoader: XmlSingleAssetLoader(),
-
-
Added Code generation of localization files.
$ flutter pub run easy_localization:generate -h -s, --source-dir Source folder contains all string json files (defaults to "resources/langs") -O, --output-dir Output folder stores generated file (defaults to "lib/generated") -o, --output-file Output file name (defaults to "codegen_loader.g.dart") -f, --format Support json, dart formats [json (default), keys]
-
generate the json string static keys in a dart class
{ "msg_named": "{} مكتوبة باللغة {lang}", }
flutter pub run easy_localization:generate -f keys -o locale_keys.g.dart
abstract class LocaleKeys { static const msg_named = 'msg_named'; }
Text(LocaleKeys.msg_named).tr(namedArgs: {'lang': 'Dart'}, args: ['Easy localization']),
-
generate the json Loader in a dart class
flutter pub run easy_localization:generate
-
-
fixed many issues.
-
Added named arguments.
"msg_named": "{} are written in the {lang} language",
Text(LocaleKeys.msg_named).tr(namedArgs: {'lang': 'Dart'}, args: ['Easy localization']),
- Added Error widget.
- fixed many issues.
- Based on Bloc.
- optimized and clean code more stability
- fixed many issues
- optimized and clean code more stability
- Added change locale dynamically
saveLocale
default valuetrue
- fixed many issues
this version came with many updates, here are the main ones:
-
optimized and clean code more stability
-
fixed many issues
-
added Unite test
-
Customization AssetLoader localizations
assetLoader
for more details see custom assetLoader -
added
fallbackLocale
as optional -
Hiding
EasyLocalizationProvider
-
refactor and update approach localization for more details see example:
// Now V2.0.0 runApp(EasyLocalization( child: MyApp(), ... )); // after V2.0.0 runApp(EasyLocalization( child: MyApp(), ... )); ... class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { var data = EasyLocalizationProvider.of(context).data; return EasyLocalizationProvider(...); }}
-
added Support for context
tr("key", context: context), plural("key", 1 , context: context),
-
optimized and clean code
-
fixed many issues
-
added extension for Strings
// after 1.4.1 Text('title'.tr()), Text('switch'.tr( gender: _gender ? "female" : "male")), Text('counter'.plural(counter)),
-
refactor code changed call
AppLocalizations.of(context).tr()
toAppLocalizations.of(context).plural()
tr()
andplural()
// after 1.4.0 Text( tr('switch', gender: _gender ? "female" : "male"), ),
// before 1.4.0 Text( AppLocalizations.of(context).tr('switch', gender: _gender ? "female" : "male"), ),
-
added Flutter extension for Text widget
// after 1.4.0 Text('switch').tr( gender: _gender ? "female" : "male"), Text('counter').plural(counter),
-
merge
gender()
andtr()
.{ "gender":{ "male": "Hi man ;)", "female": "Hello girl :)" } }
new Text( AppLocalizations.of(context).tr('switch', gender: _gender ? "female" : "male"), ),
-
use parameters
args
for gender.{ "gender":{ "male": "Hi man ;) {}", "female": "Hello girl :) {}" } }
new Text( AppLocalizations.of(context).tr('switch', args:["Naama"] gender: _gender ? "female" : "male"), ),
-
adeed Gender [female,male]
gender()
.{ "gender":{ "male": "Hi man ;)", "female": "Hello girl :)" } }
new Text( AppLocalizations.of(context).gender('switch', _gender ? "female" : "male"), ), `
-
updated
plural()
thanks shushper .{ "text": { "day": { "zero":"{} дней", "one": "{} день", "two": "{} дня", "few": "{} дня", "many": "{} дней", "other": "{} дней" } } }
- removed
data.savedLocale
. - optimized and clean code
- fixed many issues
-
plural()
added property resolver for nested key translations{ "text": { "day": { "zero": "day", "one": "day", "other": "days" } } }
new Text( AppLocalizations.of(context).plural("text.day", 2), ),
-
fixed many issues
- add useOnlyLangCode flag
- Load translations from remote or backend
- fixed many issues
- supported shared_preferences
- Save selected localization
- Added property resolver for nested key translations
- return translate key if the element or path not exist
{
"title": "Hello",
"msg": "Hello {} in the {} world ",
"clickMe": "Click me",
"profile": {
"reset_password": {
"label": "Reset Password",
"username": "Username",
"password": "password"
}
},
"clicked": {
"zero": "You clicked {} times!",
"one": "You clicked {} time!",
"other": "You clicked {} times!"
}
}
new Text(
AppLocalizations.of(context).tr('profile.reset_password.title'),
),
- Added Support country codes
- Updated
tr()
function added Multi Argument
- Added string pluralisation .
- Added Argument to
tr()
function.