Internationalization

If your application is internationalized (or localized), Monarch can render your stories using the locales you have declared in code. To do so, Monarch needs to know about your locales via the MonarchLocalizations annotation.

  1. Add the package:monarch_annotations to your dependencies:
dependencies:
monarch_annotations: ^0.1.0
  1. Go to the dart file where you have declared your LocalizationsDelegate variable. If you have created your localizations delegate in an in-line expressions, then you would have to refactor it into a top-level variable. Once you have identified your LocalizationsDelegate variable, add the MonarchLocalizations annotation as shown below:
import 'package:monarch_annotations/monarch_annotations.dart';
...
class MyLocalizationsDelegate extends LocalizationsDelegate<MyLocalizations> {...}
@MonarchLocalizations([MonarchLocale('en', 'US'), MonarchLocale('es')])
const myLocalizationsDelegate = MyLocalizationsDelegate();
  1. Save your changes. The Monarch app will display your locales in the Locale dropdown. When you select a locale, the selected story will render using the selected locale.
Locales in Monarch