Make android game data extraction ui translatable
This commit is contained in:
parent
6aab8857cc
commit
a3b0c4d240
@ -509,15 +509,87 @@ mkdir -p "$DIRNAME/res/drawable-hdpi/"
|
||||
mkdir -p "$DIRNAME/res/drawable-xhdpi/"
|
||||
mkdir -p "$DIRNAME/res/drawable-xxhdpi/"
|
||||
mkdir -p "$DIRNAME/res/drawable-xxxhdpi/"
|
||||
rm -rf "$DIRNAME/res/values*"
|
||||
mkdir -p "$DIRNAME/res/values/"
|
||||
|
||||
STRINGS_FILE="$DIRNAME/res/values/strings.xml"
|
||||
|
||||
# Strings used in stk android ui (when extracting game data first time)
|
||||
PO_EXTRACT_GAME_DATA="po_extract_game_data"
|
||||
PO_EXTRACT_GAME_DATA_STR="Extracting game data..."
|
||||
PO_EXTRACT_ERROR="po_extract_error"
|
||||
PO_EXTRACT_ERROR_STR="Game data extraction error"
|
||||
PO_EXTRACT_ERROR_MSG="po_extract_error_msg"
|
||||
PO_EXTRACT_ERROR_MSG_STR="Check remaining device space or reinstall SuperTuxKart."
|
||||
PO_QUIT="po_quit"
|
||||
PO_QUIT_STR="Quit"
|
||||
|
||||
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>" > "$STRINGS_FILE"
|
||||
echo "<!--Generated by make.sh-->" >> "$STRINGS_FILE"
|
||||
echo "<resources>" >> "$STRINGS_FILE"
|
||||
echo " <string name=\"app_name\">$APP_NAME</string>" >> "$STRINGS_FILE"
|
||||
echo " <string name=\"$PO_EXTRACT_GAME_DATA\">$PO_EXTRACT_GAME_DATA_STR</string>" >> "$STRINGS_FILE"
|
||||
echo " <string name=\"$PO_EXTRACT_ERROR\">$PO_EXTRACT_ERROR_STR</string>" >> "$STRINGS_FILE"
|
||||
echo " <string name=\"$PO_EXTRACT_ERROR_MSG\">$PO_EXTRACT_ERROR_MSG_STR</string>" >> "$STRINGS_FILE"
|
||||
echo " <string name=\"$PO_QUIT\">$PO_QUIT_STR</string>" >> "$STRINGS_FILE"
|
||||
echo "</resources>" >> "$STRINGS_FILE"
|
||||
|
||||
function translate_str()
|
||||
{
|
||||
echo $(grep -A 1 -e "msgid \"$1\"" "$2" \
|
||||
| sed -n 's/msgstr "\(.*\)"/\1/p' | sed "s/'/\\\'/g")
|
||||
}
|
||||
|
||||
find "$DIRNAME/assets/data/po" -type f -name '*.po' -print0 |
|
||||
while IFS= read -r -d '' PO; do
|
||||
CUR_LANG=$(basename -- "$PO" | cut -f 1 -d '.')
|
||||
# Skip english po file
|
||||
if [ "$CUR_LANG" = "en" ]; then
|
||||
continue
|
||||
fi
|
||||
# Fix some difference in language code
|
||||
if [ "$CUR_LANG" = "he" ]; then
|
||||
# Hebrew
|
||||
CUR_LANG="iw"
|
||||
fi
|
||||
if [ "$CUR_LANG" = "id" ]; then
|
||||
# Indonesian
|
||||
CUR_LANG="in"
|
||||
fi
|
||||
if [ "$CUR_LANG" = "yi" ]; then
|
||||
# Yiddish
|
||||
CUR_LANG="ji"
|
||||
fi
|
||||
CUR_LANG=$(echo "$CUR_LANG" | sed 's/_/-r/g')
|
||||
EXTRACT_GAME_DATA_STR=$(translate_str "$PO_EXTRACT_GAME_DATA_STR" "$PO")
|
||||
EXTRACT_ERROR_STR=$(translate_str "$PO_EXTRACT_ERROR_STR" "$PO")
|
||||
EXTRACT_ERROR_MSG_STR=$(translate_str "$PO_EXTRACT_ERROR_MSG_STR" "$PO")
|
||||
QUIT_STR=$(translate_str "$PO_QUIT_STR" "$PO")
|
||||
if [ -n "$EXTRACT_GAME_DATA_STR" ] \
|
||||
|| [ -n "$EXTRACT_ERROR_STR" ] \
|
||||
|| [ -n "$EXTRACT_ERROR_MSG_STR" ] \
|
||||
|| [ -n "$QUIT_STR" ]; then
|
||||
mkdir -p "$DIRNAME/res/values-$CUR_LANG"
|
||||
TRANSLATION="$DIRNAME/res/values-$CUR_LANG/strings.xml"
|
||||
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>" > "$TRANSLATION"
|
||||
echo "<!--Generated by make.sh-->" >> "$TRANSLATION"
|
||||
echo "<resources>" >> "$TRANSLATION"
|
||||
if [ -n "$EXTRACT_GAME_DATA_STR" ] ; then
|
||||
echo " <string name=\"$PO_EXTRACT_GAME_DATA\">$EXTRACT_GAME_DATA_STR</string>" >> "$TRANSLATION"
|
||||
fi
|
||||
if [ -n "$EXTRACT_ERROR_STR" ] ; then
|
||||
echo " <string name=\"$PO_EXTRACT_ERROR\">$EXTRACT_ERROR_STR</string>" >> "$TRANSLATION"
|
||||
fi
|
||||
if [ -n "$EXTRACT_ERROR_MSG_STR" ] ; then
|
||||
echo " <string name=\"$PO_EXTRACT_ERROR_MSG\">$EXTRACT_ERROR_MSG_STR</string>" >> "$TRANSLATION"
|
||||
fi
|
||||
if [ -n "$QUIT_STR" ] ; then
|
||||
echo " <string name=\"$PO_QUIT\">$QUIT_STR</string>" >> "$TRANSLATION"
|
||||
fi
|
||||
echo "</resources>" >> "$TRANSLATION"
|
||||
fi
|
||||
done
|
||||
|
||||
ADAPTIVE_ICON_FILE="$DIRNAME/res/drawable-anydpi-v26/icon.xml"
|
||||
|
||||
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>" > "$ADAPTIVE_ICON_FILE"
|
||||
|
@ -75,7 +75,8 @@ public class SuperTuxKartActivity extends SDLActivity
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
ll_param.gravity = Gravity.CENTER;
|
||||
TextView tv = new TextView(this);
|
||||
tv.setText("Extracting game data...");
|
||||
// From values strings.xml which is generated by make.sh
|
||||
tv.setText(getString(R.string.po_extract_game_data));
|
||||
tv.setLayoutParams(ll_param);
|
||||
|
||||
ll_param = new LinearLayout.LayoutParams(
|
||||
@ -343,10 +344,9 @@ public class SuperTuxKartActivity extends SDLActivity
|
||||
}
|
||||
AlertDialog.Builder error =
|
||||
new AlertDialog.Builder(SDL.getContext());
|
||||
error.setMessage("Check remaining device space or " +
|
||||
"reinstall SuperTuxKart.");
|
||||
error.setTitle("Extract game data error");
|
||||
error.setPositiveButton("Exit",
|
||||
error.setMessage(getString(R.string.po_extract_error_msg));
|
||||
error.setTitle(getString(R.string.po_extract_error));
|
||||
error.setPositiveButton(getString(R.string.po_quit),
|
||||
new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
|
@ -50,7 +50,10 @@ def traverse(file, node, isChallenge, isGP, isKart, isTrack, isAchievements, lev
|
||||
|
||||
f.write( line.encode( "utf-8" ) )
|
||||
else:
|
||||
if e.hasAttribute("text") and len(e.getAttribute("text")) > 0:
|
||||
if e.nodeName == "string" and e.hasAttribute("name") and e.getAttribute("name").startswith("po_") and e.firstChild is not None:
|
||||
line = "//I18N: In Android UI, " + e.getAttribute("name") + "\n_(\"" + e.firstChild.nodeValue + "\")\n\n"
|
||||
f.write( line.encode( "utf-8" ) )
|
||||
elif e.hasAttribute("text") and len(e.getAttribute("text")) > 0:
|
||||
# print "Label=", e.getAttribute("text"), " Comment=", comment
|
||||
line = ""
|
||||
if comment == None:
|
||||
|
@ -16,6 +16,7 @@ XML_FILE_LIST="`find ./data \
|
||||
../stk-assets/karts \
|
||||
../supertuxkart-assets/tracks \
|
||||
../supertuxkart-assets/karts \
|
||||
./android/res/values \
|
||||
-name 'achievements.xml' -or \
|
||||
-name 'tips.xml' -or \
|
||||
-name 'kart.xml' -or \
|
||||
@ -23,6 +24,7 @@ XML_FILE_LIST="`find ./data \
|
||||
-name 'scene.xml' -or \
|
||||
-name '*.challenge' -or \
|
||||
-name '*.grandprix' -or \
|
||||
-name 'strings.xml' -or \
|
||||
-name '*.stkgui' | sort -n \
|
||||
`"
|
||||
ANGELSCRIPT_FILE_LIST="`find ./data \
|
||||
|
Loading…
Reference in New Issue
Block a user