Skip to content

Instantly share code, notes, and snippets.

@federicobond
Last active August 29, 2015 14:04
Show Gist options
  • Save federicobond/741d5c7df61191e13408 to your computer and use it in GitHub Desktop.
Save federicobond/741d5c7df61191e13408 to your computer and use it in GitHub Desktop.
Small script to find missing translation strings in Processing
#!/bin/bash
# Small script to find missing translation strings in Processing
#
# Use with no arguments to find strings that are in the codebase but have not
# been added to the default language file.
#
# Use with a language code as first argument to find strings that are in the
# default properties file but have not yet been translated to the given
# language.
set -e
function language_file() {
local base="build/shared/lib/languages"
echo "$base/PDE${1:+_$1}.properties"
}
function code_keys() {
egrep -Roh 'Language\.(text|interpolate|pluralize)\("[a-z0-9_.]+"' --include=*.java . |
awk -F '"' '{ print $2 }' |
sort |
uniq
}
function properties_keys_depluralize() {
properties_keys |
grep -v '\.[0-9]$' |
sed 's/\.n$//'
}
function properties_keys() {
awk '/^[a-z0-9_.]+ = / { print $1 }' < "$(language_file $1)" |
sort
}
function help() {
echo "usage: ./missing.sh [language_code]"
}
function main() {
if [ "$1" = "--help" ]; then
help
exit 1
fi
if [ -z $1 ]; then
comm -3 <(code_keys) <(properties_keys_depluralize)
return
fi
if [ ! -f "$(language_file $1)" ]; then
echo "No language file for $1."
return
fi
comm -3 <(properties_keys) <(properties_keys $1)
}
main $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment