Skip to content
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
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

stha-ums
Copy link

@stha-ums stha-ums commented Apr 4, 2022

This makes us able to perform extra tasks if there is no translation available.
For example, The project I am working on uses localization from the backend. And need to tell the backend if any translation is missing. So this method allows me to achieve that.

@stha-ums stha-ums marked this pull request as draft April 5, 2022 15:37
@stha-ums stha-ums marked this pull request as ready for review April 5, 2022 15:45
@kyle-seongwoo-jun
Copy link
Collaborator

LGTM, could you write test code for onLocaleKeyNotFound?

@stha-ums
Copy link
Author

stha-ums commented May 1, 2022

@kyle-seongwoo-jun sure. I will write as soon as I am available.

@aissat aissat force-pushed the develop branch 2 times, most recently from 66adb74 to 8048ff5 Compare May 13, 2022 15:17
@nosmirck
Copy link

nosmirck commented Jun 1, 2022

omg, I need this!

@stha-ums
Copy link
Author

stha-ums commented Jun 3, 2022

@kyle-seongwoo-jun I have added a test, could you review it?

aissat and others added 2 commits June 12, 2022 20:45
@@ -18,6 +18,9 @@ void main() async {
Locale('ru', 'RU')
],
path: 'resources/langs',
onLocaleKeyNotFound: (key, locale) {
print('Locale key not found $key ${locale.languageCode}');
Copy link
Collaborator

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

this.assetLoader = const RootBundleAssetLoader(),
this.saveLocale = true,
this.errorWidget,
this.onLocaleKeyNotFound})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trailing comma is missing

}));
});

test('should call onLocaleKeyNotFound', () {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets add another test to verify that the method is NOT called when the translation exists

@bw-flagship
Copy link
Collaborator

@stha-ums Sorry that you waited so long here. Are you still willing to contribute this feature? (I submitted a review).

@stha-ums
Copy link
Author

@bw-flagship , thank you for taking the time to review, I will address these as soon as possible.

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.

5 participants