[Answered ]-Changing language with React Native and django-modeltranslation

1👍

If you want to completely make your application multi-language, you need two things.

  • Translation system for your app
  • Translation system for your api.

First, use a pre-built context api or create your own to support changing language in-app. Something like this: https://medium.com/@ally_20818/multi-language-text-with-react-native-react-context-b76d5677346d

When user changes the language, store the language name or key in async-storage or some other database.

Change the texts in the react-native side based on the selected language.

When you’re making a api call, send the selected language too. Get the selected language on api side and return appropriate texts based on language.

UPDATE:

Since you’re not storing any text on react-native side, you only need to add a picker (react-native-picker/picker is a native picker) and store the selected language key (en, de, uk etc in your case) in a database like react-native-async-storage. When you’re making api requests with react-native, include an additional header or post data which includes selected language key. And you can get and use that key in your django back-end.

Leave a comment