Using translations on both Flutter and native Android

Hi @here!

The latest project I’m working on is a Flutter app that works as a phone app. I mean an actual phone app. An app intended to make and receive phone calls. Supporting that requires a lot of platform code aka native Android code. That being said, now let’s share the problem: we need to manage translations on Flutter for UI, and on Android for native system notifications. A mess is incoming!

The first thought I had was to send the translations I had on Flutter to the platform via MethodChannel, and then save them on the native platform side, and use them in the native components. It was complex. So I would say don’t do that.

The second attempt and I think the best one, came to my mind when integrating the actual translations platform, in the case of this app, PhraseApp. As most translation platforms, they have an API that you can use to download the translations flawlessly, from the command line. Why is that idea so great that it deserves a post on the blog?

I download the translations in both ARB for Flutter and XML for Android. So, I have the translations ready to use from both sides of the project without the hassle of any synchronization. They are there ready to go!

If you don’t use PhraseApp (as I do in many projects), you will have to do it by yourself. But if you are lucky enough to use PhraseApp, I think you will be delighted with this .phrase.yml.

Feel free to be inspired by it!