Last Updated: February 25, 2016
·
730
· rhdunn

Removing a string from all translations.

The following is a helper script remove_string.sh to remove all references of a string id from the translated resources:

#!/bin/bash
#
# Copyright (C) 2013 Reece H. Dunn
# License: GPLv3+
#
# Helper utility for removing a string/string-list item in all string resources.

ls res/values*/strings.xml | while read STRINGS ; do
    xmlstarlet ed -d "/resources/*[@name='${1}']" ${STRINGS} > /tmp/strings.xml
    mv /tmp/strings.xml ${STRINGS}
done

The latest version of this file can be found at https://raw.github.com/rhdunn/espeak/android/android/remove_string.sh.

This will reformat the strings.xml files, so it is recommended to run the script initially with a bogus name, e.g.:

./remove_string.sh zzzzzzzzzz

This change can be checked in to make future changes minimal. The above can also be run after translations or the main strings.xml file has been edited to keep it in a uniform format.

To delete a string id, you can run:

./remove_string.sh <string_id>