diff options
author | jim <jim@38b22f21-9aea-0310-abfc-843a9883df58> | 2008-07-16 05:03:51 (GMT) |
---|---|---|
committer | jim <jim@38b22f21-9aea-0310-abfc-843a9883df58> | 2008-07-16 05:03:51 (GMT) |
commit | 949187b3acd0dcd9473c1b1056d98c1a7085a56f (patch) | |
tree | d51e2c9fea127bd915697329d39ae2b40bfe472a | |
parent | 0d6493cbda65205ec8f3ce18a98c7dffc92add5f (diff) |
#1250 add --new option to mki18n to generate exe.mo files for new langs
by default, only generate LC_MESSAGES/exe.mo files for languages that
already have an LC_MESSAGES directory in svn
git-svn-id: https://exe.svn.sourceforge.net/svnroot/exe/trunk@3553 38b22f21-9aea-0310-abfc-843a9883df58
-rw-r--r-- | exe/locale/messages.pot | 2 | ||||
-rwxr-xr-x | tools/cleani18n.sh | 5 | ||||
-rw-r--r-- | tools/mki18n.py | 20 |
3 files changed, 24 insertions, 3 deletions
diff --git a/exe/locale/messages.pot b/exe/locale/messages.pot index 3d0e357..8d90e81 100644 --- a/exe/locale/messages.pot +++ b/exe/locale/messages.pot @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-07-16 16:57+1200\n" +"POT-Creation-Date: 2008-07-16 16:59+1200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" diff --git a/tools/cleani18n.sh b/tools/cleani18n.sh new file mode 100755 index 0000000..f8a2e5e --- /dev/null +++ b/tools/cleani18n.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +cd exe/locale || { echo "run tools/cleani18n.sh from top level exe directory"; exit 1 ; } + +svn status | awk '/^\?/ { print $2 }' | xargs rm -r diff --git a/tools/mki18n.py b/tools/mki18n.py index 586af78..c896d28 100644 --- a/tools/mki18n.py +++ b/tools/mki18n.py @@ -82,6 +82,7 @@ import os import sys import re import shutil +from optparse import OptionParser # Try to work even with no python path try: @@ -609,7 +610,8 @@ def catPO(applicationDirectoryPath, listOf_extraPo, applicationDomain=None, targ # m a k e M O ( ) -- Compile the Portable Object files into the Machine Object stored in the right location. -- # ^^^^^^^^^^^^^^^ # -def makeMO(applicationDirectoryPath,targetDir=None,applicationDomain=None, verbose=0, forceEnglish=0) : +def makeMO(applicationDirectoryPath,targetDir=None,applicationDomain=None, verbose=0, + forceEnglish=0, keep_new=False) : """Compile the Portable Object files into the Machine Object stored in the right location. makeMO converts all translated language-specific PO files located inside @@ -644,6 +646,11 @@ def makeMO(applicationDirectoryPath,targetDir=None,applicationDomain=None, verbo for filename in targetDir.walkfiles('*_*.po'): langCode = exp.match(filename.basename()).group(1) mo_targetDir = targetDir/langCode/'LC_MESSAGES' + # if not keeping new languages, both mo_targetDir and its .svn subdir must exist + if not keep_new and (not mo_targetDir.exists() + or not (mo_targetDir/'.svn').exists()): + print "not building %s" % filename + continue if not mo_targetDir.exists(): mo_targetDir.makedirs() cmd = "msgfmt -f --statistics -c --output-file=%s.mo %s" % ( @@ -803,6 +810,13 @@ def unixpath(thePath) : # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ # if __name__ == "__main__": + usage = "usage: %prog [options]" + parser = OptionParser(usage) + parser.add_option("-n", "--new", + action="store_true", dest="preserve_new", default=False, + help="create new .mo files for languages that are not yet in SVN") + (options, args) = parser.parse_args() + # Move to the right dir curdir = Path('.').abspath() if curdir.basename() == 'exe': @@ -840,7 +854,9 @@ if __name__ == "__main__": except IOError, e: printUsage(e[1] + '\n You must write a file app.fil that contains the list of all files to parse.') # Compile the result - makeMO('.',option['moTarget'],option['domain'],option['verbose'],option['forceEnglish']) + makeMO('.',option['moTarget'],option['domain'],option['verbose'], + option['forceEnglish'], keep_new=options.preserve_new) + sys.exit(1) |