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

Default value if not found #27

Closed
porfirioribeiro opened this issue Jan 24, 2020 · 2 comments
Closed

Default value if not found #27

porfirioribeiro opened this issue Jan 24, 2020 · 2 comments

Comments

@porfirioribeiro
Copy link

porfirioribeiro commented Jan 24, 2020

First of all, thanks for this nice project :)

Currently translate('key') returns the key is it didn't find a translation, but would be nice to be able to specify a default value like

translate('my.key', def: 'Something');

Or have a function that returns null so we can do:

translate('my.key') ?? 'Something';
@bratan
Copy link
Member

bratan commented Jan 28, 2020

Thanks for the suggestion.

I don't think I will implement this behavior since it will have to be added as an option and it will just bloat the configuration, considering that generally there should be no missing translations.

In the next couple of days I`m going to implement https://github.com/bratan/flutter_translate_gen/issues/1 which will make sure there are no missing translation keys.

@porfirioribeiro
Copy link
Author

porfirioribeiro commented Jan 28, 2020

Ok, i understand, for my use case i was dealing with the possibility of having a missing key and wanted to actually specify a default value.
But i made a workaround in my code that fits my needs, you can close this if you feel it's the best for the project ;)

Thanks!

@bratan bratan closed this as completed Jan 29, 2020
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

No branches or pull requests

2 participants