1

Our App supports different languages, some of the translations contain mistakes. The translations on the server are correct.

What is the recommended way to update the strings.xml from the server and how it could be done? Which technologies would be involved?

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175
Amrmsmb
  • 1
  • 27
  • 104
  • 226
  • Try to use POEditor ;) – phatnhse Jun 29 '17 at 16:26
  • What you are asking is to download resources from network and replace them at runtime. Android does not allow that. Some [previous](https://stackoverflow.com/questions/2823696/download-and-replace-android-resource-files) [questions](https://stackoverflow.com/questions/9365328/can-localization-resources-be-downloaded-in-runtime) on this subject. – pellucide Jun 29 '17 at 16:30
  • The strings.xml is like constants, you cannot update in runtime, try using static string variable in case that you need change some words language. – Chefes Jun 29 '17 at 16:31
  • You need to generate a file or a sqlite database and then update that, xml's can't be updated without deployment. – Alejandro Cumpa Jun 29 '17 at 16:32
  • @Chefes would you please clarify?? do you mean that instead of declaring the strings in the xml file, they should be declared explicitly in the code such as "private static final String str_eng = "text" private static final String str_de = "text"??!! – Amrmsmb Jun 29 '17 at 16:39
  • @Letsamrit Although you can't update the strings.xml directly. If you want a very easy solution then I have answered a similar question stackoverflow.com/a/60133893/4057271 – Ravindra Barthwal Feb 09 '20 at 06:09

1 Answers1

4

You cannot update your app's resources without deploying a new APK.

If you want to continue keeping the translations in XML resources, you will need to update them appropriately then deploy a new version of your application.

If you would like those strings to come only from the server in the future, you will need to set up an API service to expose the strings, and consume that API in your app instead of loading the strings from resource files.

Bryan Herbst
  • 66,602
  • 10
  • 133
  • 120
  • thank you.please clarify to me the following: 1-deploying APK file from the server meas that, the server side has the latest and the correct version of the App, right? (2)-if we want to use API service, then what is the recommended or the best technology please – Amrmsmb Jun 29 '17 at 16:33
  • You don't typically deploy an APK from a server- you upload it to the Google Play Console. Generally Android developers who are using REST services like [Retrofit](http://square.github.io/retrofit/), but you are welcome to use any HTTP client. – Bryan Herbst Jun 29 '17 at 16:35
  • please bear with me. now in our main app we gonna correct all the strings, and create an APK out of it then upload it to google play,right?. then, we are free to connect to Google Play service through REST or HTTP to update the current version of the app, right? now, how would the user be informed that there is a new version of the APK available so the user can download it – Amrmsmb Jun 29 '17 at 16:45