Skip to content

Callback method when the translation for the key is not found.#469

Open
stha-ums wants to merge 7 commits into
aissat:developfrom
stha-ums:no-key-callback
Open

Callback method when the translation for the key is not found.#469
stha-ums wants to merge 7 commits into
aissat:developfrom
stha-ums:no-key-callback

Conversation

@stha-ums

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

Copy link
Copy Markdown

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
Copy Markdown
Collaborator

LGTM, could you write test code for onLocaleKeyNotFound?

@stha-ums

stha-ums commented May 1, 2022

Copy link
Copy Markdown
Author

@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

nosmirck commented Jun 1, 2022

Copy link
Copy Markdown

omg, I need this!

@stha-ums

stha-ums commented Jun 3, 2022

Copy link
Copy Markdown
Author

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

aissat and others added 2 commits June 12, 2022 20:45
Comment thread example/lib/main.dart
],
path: 'resources/langs',
onLocaleKeyNotFound: (key, locale) {
print('Locale key not found $key ${locale.languageCode}');

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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