Kiwix-android: Create script to move string resources across modules

Created on 20 Feb 2020  路  12Comments  路  Source: kiwix/kiwix-android

Is your feature request related to a problem? Please describe.
To support our translations we lint the core module as a dependent of the app module. This has a side effect of linting all of the dependencies of app and creates false positives in our lint reports that have to be baselined

Describe the solution you'd like
A script that takes 3 inputs, source module, destination module string key and uses them to move a specific string and all its translation to the destination module so our translations are preserved on translatewiki

Describe alternatives you've considered
Continue with how it is, downside is we will never get rid of the baseline

code cleanup enhancement good first issue i18n

All 12 comments

I'd like to work on this!

@Frans-Lukas You are welcome :)

@macgills @kelson42 Am I interpreting this correctly?

The user gives source module and destination module as well as string key.

The source and destination modules can for example be app and core. The script will then look for a source module/src/main/res/ directory after of which it will iterate all values* directories from there. For each iteration it will copy the string key line from the strings.xml file. (Ex. <string name="detecting_file_system">Detecting if file system can create 4GB files</string> for the key string_key = 'detecting_file_system'.)

It will then paste the string key line into the corresponding values* directory in destination module/src/main/res/values*.

One ambiguity is whether it should cut the line from the source directory or copy it? I.e. if the line should be removed from source module/src/main/res/values*/string.xml or not.

Yes this is correct, it will find a string by key and cut it out of all the values-* files it occurs in and add it to (or create) the corresponding strings file.

I think in reality what will happen is that strings will only be moved from core -> app but it is easy to give us the flexibility.

Personally if I was going to write this I would try and do it with kotlin scripting but that would mostly be to satisfy my curiosity of how capable it is . Nobody should feel an obligation to do that, bash/python whatever is convenient and easy

Personally if I was going to write this I would try and do it with kotlin scripting but that would mostly be to satisfy my curiosity of how capable it is . Nobody should feel an obligation to do that, bash/python whatever is convenient and easy

I strongly support Kotlin, as this is the language of the app. Any other solution would require additional deps to be installed and I don't like this really much.

Alright, I want to learn kotlin scripting as well, so that will be good. Do we have a directory for scripts in the repository or should the script be placed in the root dir? I noticed there are a couple of scripts in the root dir. (update-play-store.py and upload-apk.py)

Please create a scripts directory on the root of the project and move all those scripts in. I have been meaning to delete half off them as they are defunct

Great! Will do.

@macgills @Frans-Lukas Probably good to put it directly in contrib directly?!

Ah yes, I forgot that was there

@Frans-Lukas I was doing some quick reading on kotlin scripting and this article mentioned the packaging of a script as a standalone binary using kscript, I wasn't a big fan of adding kscript just to add dependencies but to me there is value in users of this script not having to install kotlinc. Consider this a bonus extra on this ticket, totally optional

@macgills kscript looks great. I'll look into it.

Was this page helpful?
0 / 5 - 0 ratings