-
-
Notifications
You must be signed in to change notification settings - Fork 336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Callback method when the translation for the key is not found. #469
Open
stha-ums
wants to merge
7
commits into
aissat:develop
Choose a base branch
from
stha-ums:no-key-callback
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cb74307
No translation for the key callback
8d9cb91
Merge branch 'develop' into no-key-callback
stha-ums ca7f430
No translation for the key callback
f3d2bd3
Merge branch 'no-key-callback' of github.com:stha-ums/easy_localizati…
stha-ums 0e45f89
added try-catch for onKeyNotFoundcallback and test
stha-ums 4f0e878
Merge branch 'develop' into no-key-callback
aissat e3af9cd
Update logger_printer.dart
stha-ums File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
2 changes: 1 addition & 1 deletion
2
example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
// Generated file. Do not edit. | ||
// | ||
|
||
// clang-format off | ||
|
||
#include "generated_plugin_registrant.h" | ||
|
||
|
||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,19 +76,23 @@ class EasyLocalization extends StatefulWidget { | |
/// @Default value `errorWidget = ErrorWidget()` | ||
final Widget Function(FlutterError? message)? errorWidget; | ||
|
||
EasyLocalization({ | ||
Key? key, | ||
required this.child, | ||
required this.supportedLocales, | ||
required this.path, | ||
this.fallbackLocale, | ||
this.startLocale, | ||
this.useOnlyLangCode = false, | ||
this.useFallbackTranslations = false, | ||
this.assetLoader = const RootBundleAssetLoader(), | ||
this.saveLocale = true, | ||
this.errorWidget, | ||
}) : assert(supportedLocales.isNotEmpty), | ||
/// callback when key is not available in translations of the locale | ||
final Function(String key, Locale locale)? onLocaleKeyNotFound; | ||
|
||
EasyLocalization( | ||
{Key? key, | ||
required this.child, | ||
required this.supportedLocales, | ||
required this.path, | ||
this.fallbackLocale, | ||
this.startLocale, | ||
this.useOnlyLangCode = false, | ||
this.useFallbackTranslations = false, | ||
this.assetLoader = const RootBundleAssetLoader(), | ||
this.saveLocale = true, | ||
this.errorWidget, | ||
this.onLocaleKeyNotFound}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. trailing comma is missing |
||
: assert(supportedLocales.isNotEmpty), | ||
assert(path.isNotEmpty), | ||
super(key: key) { | ||
EasyLocalization.logger.debug('Start'); | ||
|
@@ -162,6 +166,7 @@ class _EasyLocalizationState extends State<EasyLocalization> { | |
delegate: _EasyLocalizationDelegate( | ||
localizationController: localizationController, | ||
supportedLocales: widget.supportedLocales, | ||
onLocaleKeyNotFound: widget.onLocaleKeyNotFound, | ||
), | ||
); | ||
} | ||
|
@@ -241,12 +246,16 @@ class _EasyLocalizationProvider extends InheritedWidget { | |
class _EasyLocalizationDelegate extends LocalizationsDelegate<Localization> { | ||
final List<Locale>? supportedLocales; | ||
final EasyLocalizationController? localizationController; | ||
final Function(String key, Locale locale)? onLocaleKeyNotFound; | ||
|
||
/// * use only the lang code to generate i18n file path like en.json or ar.json | ||
// final bool useOnlyLangCode; | ||
|
||
_EasyLocalizationDelegate( | ||
{this.localizationController, this.supportedLocales}) { | ||
_EasyLocalizationDelegate({ | ||
this.localizationController, | ||
this.supportedLocales, | ||
this.onLocaleKeyNotFound, | ||
}) { | ||
EasyLocalization.logger.debug('Init Localization Delegate'); | ||
} | ||
|
||
|
@@ -262,7 +271,9 @@ class _EasyLocalizationDelegate extends LocalizationsDelegate<Localization> { | |
|
||
Localization.load(value, | ||
translations: localizationController!.translations, | ||
fallbackTranslations: localizationController!.fallbackTranslations); | ||
fallbackTranslations: localizationController!.fallbackTranslations, | ||
onLocaleKeyNotFound: onLocaleKeyNotFound); | ||
|
||
return Future.value(Localization.instance); | ||
} | ||
|
||
|
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use EasyLocalization.logger instead of print