-
Notifications
You must be signed in to change notification settings - Fork 167
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
no way to use widgets that require localization #53
Comments
Yes, this is currently not implemented. We'll keep you posted on this issue 👍🏻 |
Thanks @jenshor 👍🏻 , I'll keep an eye out, as currently this is a blocker for me to try using Widgetbook. |
I simply created a class TranslationsWrapper extends StatelessWidget {
final Widget child;
final String lang;
const TranslationsWrapper({Key? key, required this.child, required this.lang})
: super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
localizationsDelegates: [
Translations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
locale: Locale(lang),
supportedLocales: Translations.delegate.supportedLocales,
home: child,
);
}
} Which lets me create language specific usecases like: useCases: [
WidgetbookUseCase(
name: "Main - EN",
builder: (ctx) {
return TranslationsWrapper(
child: OnBoardingScreen(),
lang: 'en',
);
},
),
WidgetbookUseCase(
name: "Main - JP",
builder: (ctx) {
return TranslationsWrapper(
child: OnBoardingScreen(),
lang: 'ja',
);
},
)
], |
Thanks @edTheGuy00 I could have sworn I tried wrapping in a MaterialApp initially when I ran into it without sucess, but I just tried again and it does work fine! Though it would be nice to have this fixed in widgetbook so that we dont end up with nested MaterialApp widgets. |
@maks I agree. I think the best approach would be to provide the localizations to the |
@edTheGuy00 that is indeed how we plan to implement this feature, but it will probably take a while since we are currently working on other features. We'll keep you posted on the progress 👍🏻 |
Any ETA on this issue? Or is maybe a PR welcome? |
@Butzlabben we currently have no ETA on this feature but a PR is always welcome 💙 If you are planning to work on this please be aware of our CLA |
ETA just moved up to next week 🚀 |
We just fixed this (and many other issues) as a beta release on pub.dev. We are still adjusting the generator to the breaking changes, but the updated generator will likely land next week. Let us know what you think! |
Guys is there any updates on this? How do I make it work with localizations? |
@tieorange have a look at our documentation regarding localization. If you have issues, let us know within a new issue or via discord. |
I have widgets that make use of Flutters standard localisation mechanism and so require having
localizationsDelegates
andsupportedLocales
set on their containingMaterialApp
but there is currently no way to do so for theMaterialApp
widget that widgetbook uses internally.The text was updated successfully, but these errors were encountered: