Reputation: 187
I've been looking on Internet for this but didn't find any article/blog (probably I have been looking poorly) so I'd decided to ask question here: is it possible to use same strings.xml
(translations) from one language folder for another language, which is very similar? To be more specific, I'd like to use translations from values-sk
also for values-cz
language.
I was thinking about writing a Gradle script which would make a copy of strings.xml
file in values-sk
folder and copy it into values-cz
folder on build, but I'd like to know if there's an easier/out of the box solution.
Upvotes: 3
Views: 191
Reputation: 187
Well, I solved it using Gradle script before build. In case someone's interested, I added new task in app.gradle
(at the end of the file, but that shouldn't matter):
gradle.projectsEvaluated {
preBuild.dependsOn(copySkStringsFileToCsFolder)
}
task copySkStringsFileToCsFolder(type: Copy) {
description = 'Copies strings.xml from values-sk to values-cs'
from 'src/main/res/values-sk/strings.xml'
into 'src/main/res/values-cs'
}
From what I overview, it copies the file on every Sync/Build operation - works pretty neatly for me, but I am still interested in other possibilities (if there are any).
Also I would like to apologize to Czech people that I misinterpreted the code for values folder (using -cz
instead of -cs
) - sorry 'bout that, I didn't know I was supposed to use the other one. :)
Upvotes: 2
Reputation: 16976
Create both values-sk
& values-cz
folder in your /res
directory of your project and then copy-paste the strings.xml
to each. As you can see, those will be different directories but with the same strings.xml
so, it probably should work.
After that, Android will detect that you have two different directory-strings for two different localization then, you can change, modify each one of them (If needed).
Upvotes: 0