From b2870388332675fc2c0b0e96bbf3976ad6d0a461 Mon Sep 17 00:00:00 2001 From: James Teh Date: Wed, 18 Jan 2012 17:38:36 +1000 Subject: [PATCH] sconstruct: Build pot file using xgettext instead of pygettext, as it can retrieve translator comments and message contexts. --- readme.txt | 8 ++++++++ sconstruct | 25 +++++++++++++------------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/readme.txt b/readme.txt index e60c5a50f..64dbab4cf 100644 --- a/readme.txt +++ b/readme.txt @@ -89,6 +89,11 @@ To build an installer: To generate developer documentation: * Doxygen Windows installer (1.7.3 or above): http://www.stack.nl/~dimitri/doxygen/download.html +To generate a gettext translation template: + * xgettext from GNU gettext: + * A Windows build is available at http://sourceforge.net/projects/cppcms/files/boost_locale/gettext_for_windows/ + * Copy xgettext.exe into the tools directory. + == Preparing the Source Tree == Before you can run the NVDA source code, you must prepare the source tree. You do this by opening a command prompt, changing to the root of the NVDA source distribution and typing: @@ -135,6 +140,9 @@ To generate an archive of debug symbols for the various dll/exe binaries, type: scons symbolsArchive The archive will be placed in the output directory. +To generate a gettext translation template (for translators), type: +scons pot + Optionally, the build can be customised by providing variables on the command line: * version: The version of this build. * release: Whether this is a release version. diff --git a/sconstruct b/sconstruct index 7298d3439..9f7ec106a 100755 --- a/sconstruct +++ b/sconstruct @@ -52,8 +52,8 @@ try: except WindowsError: makensis = "makensis" -# Get the path to pygettext. -pygettext = os.path.join(sys.exec_prefix, "Tools", "i18n", "pygettext.py") +# Get the path to xgettext. +XGETTEXT = os.path.abspath(os.path.join("tools", "xgettext.exe")) # Get the path to epydoc. EPYDOC = os.path.join(sys.exec_prefix, "scripts", "epydoc.py") @@ -262,9 +262,15 @@ env.Alias('changes',changesFile) def makePot(target, source, env): # Generate the pot. if env.Execute([["cd", sourceDir, "&&", - sys.executable, pygettext, - "-o", target[0].abspath, "*.py", r"*\*.py", r"*\*\*.py"]]) != 0: - raise RuntimeError("pygettext failed") + XGETTEXT, + "-o", target[0].abspath, + "--package-name", versionInfo.name, "--package-version", version, + "--foreign-user", + "--add-comments=Translators:", + "--keyword=pgettext:1c,2", + ] + [os.path.relpath(str(f), str(sourceDir)) for f in source] + ]) != 0: + raise RuntimeError("xgettext failed") # Tweak the headers. potFn = str(target[0]) @@ -272,16 +278,12 @@ def makePot(target, source, env): with file(potFn, "rt") as inp, file(tmpFn, "wt") as out: for lineNum, line in enumerate(inp): if lineNum == 1: - line = line.replace("YEAR ORGANIZATION", "2006-2010 NVDA Contributors") + line = "# %s\n" % versionInfo.copyright elif lineNum == 2: # Delete line. continue - elif lineNum == 6: - line = line.replace("PACKAGE VERSION", version) - elif lineNum == 12: + elif lineNum == 15: line = line.replace("CHARSET", "UTF-8") - elif lineNum == 13: - line = line.replace("ENCODING", "8bit") out.write(line) os.remove(potFn) os.rename(tmpFn, potFn) @@ -318,4 +320,3 @@ symbolsArchive = env.SzArchive(outputDir.File("%s_debugSymbols.zip" % outFilePre env.Alias("symbolsArchive", symbolsArchive) env.Default(portableDist) - -- 2.11.0