Is there a way I can translate my flutter app for free?

Viewed 1321

I am making a flutter app that fetches data from a database using an API. The client wants me to add multilanguage support, so is there a way with which I can change the language of the whole app. Also the data that is being fetched from database needs to be translated. So it would be better if the data is translated before being displayed. Thank you.

1 Answers

The best approach would be to get translated data from the backend as it will be a lot faster compared to translating the text at the mobile end.

There is this translator package which you can use to convert the data fetched from the backend.

However, note that your app will become slow when you implement this because you will have to wait for two API calls:

  1. For fetching data from the backend
  2. Uploading this fetched data & then getting translations back

The translator package makes use of Google Translator to translate text into any language that you want.

void main() async {
  final translator = GoogleTranslator();

  final input = "Здравствуйте. Ты в порядке?";

  translator.translate(input, from: 'ru', to: 'en').then(print);
  // prints Hello. Are you okay?
  
  var translation = await translator.translate("Dart is very cool!", to: 'pl');
  print(translation);
  // prints Dart jest bardzo fajny!

  print(await "example".translate(to: 'pt'));
  // prints exemplo
}

The simple use case example mentioned in the package.

Related