Localizations

If you are using the flutter_localizations package, you will need access to the generated localization files inside your Widgetbook app. Here's how you can do it:

  1. Change the l10n.yaml file by setting the synthetic-package option to false:

    arb-dir: lib/l10n
    template-arb-file: app_en.arb
    output-localization-file: app_localizations.dart
    synthetic-package: false
    
  2. Update your .gitignore file to include the generated localization files:

    # Generated localization files
    lib/l10n/*.dart
    
  3. Generate the localization files by running the following command:

    flutter gen-l10n
    
  4. Add the generated localization files to your Widgetbook app via the LocalizationAddon:

    import 'package:your_app/l10n/app_localizations.dart';
    
    // ...
    
    @App()
    class WidgetbookApp extends StatelessWidget {
      const WidgetbookApp({super.key});
    
      @override
      Widget build(BuildContext context) {
        return Widgetbook(
          // ...
          addons: [
            LocalizationAddon(
              locales: AppLocalizations.supportedLocales,
              localizationsDelegates: AppLocalizations.localizationsDelegates,
              initialLocale: AppLocalizations.supportedLocales.last,
            ),
          ],
        );
      }
    }