From 91e44b668b55107d0d2b3280be9f256c2f700e28 Mon Sep 17 00:00:00 2001 From: Tim Su Date: Tue, 1 Jun 2010 03:30:50 -0700 Subject: [PATCH] Updated translation scripts, we're going in with guns blazing... --- astrid/res/values/arrays.xml | 19 +++++++++---------- astrid/res/values/strings.xml | 4 ++-- bin/androidxml2po.bash | 21 +++++++++++++++++++-- bin/xml2po.py | 26 +++++++++++++++++--------- 4 files changed, 47 insertions(+), 23 deletions(-) diff --git a/astrid/res/values/arrays.xml b/astrid/res/values/arrays.xml index 8d0f8f85d..5507afe12 100644 --- a/astrid/res/values/arrays.xml +++ b/astrid/res/values/arrays.xml @@ -14,19 +14,18 @@ limitations under the License. --> - - + - - Hi there! Have a sec? diff --git a/astrid/res/values/strings.xml b/astrid/res/values/strings.xml index 40fede4b4..aefc1ade2 100644 --- a/astrid/res/values/strings.xml +++ b/astrid/res/values/strings.xml @@ -194,7 +194,7 @@ Select an Action: Times You\'ve Postponed: %d Postpone for how long? - "Delete completed tasks older than # days:" + Delete completed tasks older than # days: @@ -246,7 +246,7 @@ To use repeats, set at least one of the deadlines above. When you complete this task, the deadline will be automatically advanced. \n\n -If you don\'t want to see the new task right after you complete the old one, you should use the "Hide Until" field, which will also be advanced automatically. +If you don\'t want to see the new task right after you complete the old one, you should use the \"Hide Until\" field, which will also be advanced automatically. \n Don\'t Show Help Anymore diff --git a/bin/androidxml2po.bash b/bin/androidxml2po.bash index 9c72f17f8..07b853f80 100755 --- a/bin/androidxml2po.bash +++ b/bin/androidxml2po.bash @@ -36,8 +36,8 @@ if [ ! -e /usr/bin/gettext ]; then fi # Set the languages here (po -> name of .po file. res -> name of res folder) -po_lang=( "ca" "cs" "de" "es" "fr" "id" "it" "ja" "ko" "nb" "nl" "pl" "pt" "ru" "sv" "tr" "zh_CN" "zh_TW") -res_lang=("ca" "cs" "de" "es" "fr" "id" "it" "ja" "ko" "nb" "nl" "pl" "pt" "ru" "sv" "tr" "zh-rCN" "zh-rTW") +po_lang=( "ca" "cs" ) # "de" "es" "fr" "id" "it" "ja" "ko" "nb" "nl" "pl" "pt" "ru" "sv" "tr" "zh_CN" "zh_TW") +res_lang=("ca" "cs" ) # "de" "es" "fr" "id" "it" "ja" "ko" "nb" "nl" "pl" "pt" "ru" "sv" "tr" "zh-rCN" "zh-rTW") #Change the dirs where the files are located. launchpad_po_files_dir="translations" @@ -68,7 +68,24 @@ function export_xml2po ${xml2po} -a -l "${po_lang[i]}" -o \ "${launchpad_pot_file_dir}"/"${resource_file}".pot \ "${android_xml_files_res_dir}"/"${resource_file}".xml + + for (( i=0 ; i<${#po_lang[*]} ; i=i+1 )); do + if [ -e "${launchpad_po_files_dir}"/"${resource_file}"-"${po_lang[i]}".po ] ; then + echo "Exporting .xml to updated .po for "${po_lang[i]}"" + if [ -e "${android_xml_files_res_dir}"-"${res_lang[i]}"/"${resource_file}".xml ] ; then + ${xml2po} -a \ + -r "${android_xml_files_res_dir}"-"${res_lang[i]}"/"${resource_file}".xml \ + -u "${launchpad_po_files_dir}"/"${resource_file}"-"${po_lang[i]}".po \ + "${android_xml_files_res_dir}"/"${resource_file}".xml + else + ${xml2po} -a \ + -u "${launchpad_po_files_dir}"/"${resource_file}"-"${po_lang[i]}".po \ + "${android_xml_files_res_dir}"/"${resource_file}".xml + fi + fi + done done + } function usage diff --git a/bin/xml2po.py b/bin/xml2po.py index 4897c76e5..94456f268 100755 --- a/bin/xml2po.py +++ b/bin/xml2po.py @@ -228,12 +228,17 @@ def stringForEntity(node): return result - +# for writing in a po file def escapePoString(text): - return text.replace('\\','\\\\').replace('"', "\\\"").replace("'","\\'").replace("\n","\\n").replace("\t","\\t") + return text.replace("\\'","'").replace('\\','\\\\').replace('\\\\"', '\\"').replace("\n","\\n").replace("\t","\\t") + +# for turning xml into raw resource +def unEscapeXmlString(text): + return text.replace('\\"','"').replace("\\'","'") -def unEscapePoString(text): - return text.replace('\\"', '"').replace("\\'","'").replace('\\\\','\\') +# for writing in an xml file +def escapeXmlString(text): + return text.replace('"','\\"').replace("'","\\'") def getTranslation(text, spacepreserve = 0): """Returns a translation via gettext for specified snippet. @@ -241,7 +246,8 @@ def getTranslation(text, spacepreserve = 0): text should be a string to look for, spacepreserve set to 1 when spaces should be preserved. """ - #print >>sys.stderr,"getTranslation('%s')" % (text.encode('utf-8')) + text = unEscapeXmlString(text) + # print >>sys.stderr,"getTranslation('%s')" % (text.encode('utf-8')) text = normalizeString(text, not spacepreserve) if (text.strip() == ''): return text @@ -249,7 +255,6 @@ def getTranslation(text, spacepreserve = 0): if gt: res = gt.ugettext(text.decode('utf-8')) return res - return text def myAttributeSerialize(node): @@ -516,7 +521,8 @@ def processElementTag(node, replacements, restart = 0): if not translation: translation = outtxt.decode('utf-8') if worth and mark_untranslated: node.setLang('C') - + translation = escapeXmlString(translation) + if restart or worth: i = 0 while i < len(myrepl): @@ -624,9 +630,9 @@ def tryToUpdate(allargs, lang): print >>sys.stderr, "OVDI!" command = allargs[0] args = allargs[1:] - opts, args = getopt.getopt(args, 'avhm:ket:o:p:u:', + opts, args = getopt.getopt(args, 'avhm:ket:o:p:u:r:', ['automatic-tags','version', 'help', 'keep-entities', 'extract-all-entities', 'merge', 'translation=', - 'output=', 'po-file=', 'update-translation=' ]) + 'output=', 'po-file=', 'update-translation=', "reuse=" ]) for opt, arg in opts: if opt in ('-a', '--automatic-tags'): command += " -a" @@ -634,6 +640,8 @@ def tryToUpdate(allargs, lang): command += " -k" elif opt in ('-e', '--extract-all-entities'): command += " -e" + elif opt in ('-r', '--reuse'): + origxml = arg elif opt in ('-m', '--mode'): command += " -m %s" % arg elif opt in ('-o', '--output'):