How to add localization support inside Flutter packages

761

I have implemented the same by following what is done in another package - Catcher. Here is the file - https://github.com/jhomlala/catcher/blob/master/lib/model/localization_options.dart

Share:
761
Taha Ali
Author by

Taha Ali

I like giving back to community in my spare time, it gives me insight about real challenges that developers face and solving their problems heightens my sense of self-worth. Currently working in mobility services department in TPS Pakistan where I develop cross-platform mobile applications on Xamarin.Forms and Flutter. I'm a computer science graduate from FAST-NU (National University of Computer & Emerging Sciences), completed my bachelors and master degree from the same. My recent interests involve research in Blockchain technology and IoT.

Updated on December 23, 2022

Comments

  • Taha Ali
    Taha Ali over 1 year

    I am creating a Flutter package that has some text inside it. I want the consumer application of my package to pass locale to it, based on that locale my package should decide whether to show this text in 'Arabic' or 'English' (This means my package will have resource file containing strings inside it for these locales). How can I achieve this?

    The only thing I was able to achieve was that my consumer application has the resource file and both my consumer application and package have to register the same localization plugin as dependency. I do not want my consumer app to worry about localization and instead my package should handle showing of translated strings based on locale. Is there anything wrong with my approach?