esskar / vscode-flutter-i18n-json

VS Code extension to create a binding between your translations from .json files and your Flutter app.
92 stars 22 forks source link

Need to get Locale object #57

Open lakshmanaprabhu opened 4 years ago

lakshmanaprabhu commented 4 years ago

Team, Is that possible to fetch the current locale used in that app? (Particularly, while changing locale manually)

Tried to fetch the current locale,

But, both returns device locale. Actually, I want a locale from generated/I18n._locale.

is that possible?

gcemcw4 commented 4 years ago

You could use code like this:

Localizations.of<I18n>(context, WidgetsLocalizations).cancel == 'Cancel'

lakshmanaprabhu commented 4 years ago

Thanks for the reply. In my case, I have multiple languages to choose from.

Why don't we add getter method for Locale in I18n.dart ? like, static Locale get locale => _locale;

Seems, it helps me better. Thoughts?

QuentinSc commented 4 years ago

Yeah, it could simplify my life to have this getter too