Localization for Dart package

Problem

  • create a class with localization strings, wrapped in Intl.message();
  • extract the strings for translation from this class to arb files;
  • translate the strings and put them in separate arb files for each language;
  • generate code (messages_*.dart files) based on arb files;
  • define localization delegate (which will be registered in the application) and implement load method, which calls initializeMessages() from generated code and returns an instance of a class from the first paragraph.
  • localize a package in a familiar, standard way, as well as I do, with an application localization.
  • have the ability to load package localization while using application localization.

Solution

Implementing delegate example.
Multiple custom delegates in MaterialApp.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store