For most of our cross-platform code our Gettext-based KF::I18n Framework takes care of translating user-readable texts on Android as well. It doesn’t cover Android-specific files and/or Android-native code though. Fortunately it’s not hard to integrate that with KDE’s translation infrastructure as well.
Marking strings for translation
For Android’s translation system all messages needing localization have to be put into the
res/values/strings.xml file and are assigned translation ids there.
Messages can then be referenced by their translation id, both in Java code and the various XML files including the Android manifest. The latter is probably the more commonly needed case for KDE’s apps, which have typically fairly little code written in Java directly.
In XML files those strings can then referenced using the
In Java code, those messages are accessible via the
getString method in
and using the translation id constants
Translation infrastructure integration
For KDE’s translation infrastructure to pick this up, a file named
is needed in the project root directory. It’s used by the nightly translation run
to extract and merge translations that are stored in their own format rather than
the usual Gettext catalogs.
Using the following template only two paths need to be adjusted to the respective project:
See e.g. KDE Itinerary’s StaticMessages.sh for a full example.
After adding that file you should see translated
strings.xml variants starting to appear
within a few days.