I have a package that uses the EasyLocalization package for localization, and I want to add localizationsDelegate of this package to my main project.
I know that I can add something like this with flutter_intl package to pubspec.yaml:
flutter_intl:
main_locale: en
enabled: true
class_name: MyPackageLocalization
And add the MyPackageLocalization.delegate to my localizationsDelegates inside the MaterialApp:
...
MaterialApp(
localizationsDelegates: [
...context.localizationDelegates,
MyPackageLocalization.delegate,
],
supportedLocales: context.supportedLocales,
...
But, how can I do it with the EasyLocalization package?
I found the solution, first of all, we need to define a
MultiTranslationAssetLoaderclass:Then we can use it as follows:
Here is a sample implementation of
TranslationsLoader:This article helped me to solve this problem:
How to localize packages with easy_localization