Issue
I am introducing a second language (French) into my App. I have had the strings.xml resource file translated and created a new folder called values-fr, etc... The French strings are coming through fine in the UI apart from one part of the app. There's a help section which is currently stored in the SQLite db and the DatabaseHelper code reads from Strings.xml by referencing string resources, e.g.
context.getString(R.string.tip1title);
One option I'm considering is adding a "LANGUAGE" column to the database and then modifying the query that pulls out the help text based on the locale of the device, so I'm trying to read the French strings.xml file in to the database during install/update. Is there any way I can point the code at "values-fr/strings.xml" rather than the default "values/strings.xml" - without changing the locale during the process? I don't want to mess with locale, just in case something outside of my control occurs and the users device language get set to French...
If not then another option I'm considering is to not store the strings in the DB and instead create a raw file for each language and then use the locale of the device to read from a different resource.
Solution
Thanks to fgeorgiew for your input.
There should be no need to do what I discussed above. It's very unlikely that a user would switch the language on their phone. Even if they did the locale is likely to be set to their first language, so if the text from the DB is presented in their default locale then there should be no impact.
I have tested with my locale set to French and the App pulls out the strings as expected and populates the database. No further input required.
Answered By - Darnst
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.