summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Burrows <dburrows@debian.org>2010-04-26 22:00:21 -0700
committerDaniel Burrows <dburrows@debian.org>2010-04-26 22:00:21 -0700
commiteb44c6e9eba49990460c4c0f69a8fb4e5da3e3d3 (patch)
tree3ae9da6d7c1908976357eea9c08ebb8749051703
parent50c087c2474f12c23a72b25f3ef8c31a3bcde1e4 (diff)
downloadaptitude-eb44c6e9eba49990460c4c0f69a8fb4e5da3e3d3.tar.gz
Add an SConscript file for the po/ directory.
-rw-r--r--SConstruct15
-rw-r--r--po/SConscript87
-rw-r--r--site_scons/aptitude_configure.py3
3 files changed, 105 insertions, 0 deletions
diff --git a/SConstruct b/SConstruct
index 928278c2..b409d234 100644
--- a/SConstruct
+++ b/SConstruct
@@ -102,6 +102,10 @@ for variant_env in envs.programs.AllVariantEnvs():
Exit(1)
Default(aptitude)
+# De-setify the list of sources.
+all_aptitude_srcs = list(all_aptitude_srcs)
+Export('all_aptitude_srcs')
+
# NB: I know because of how the variant directories are set up that we
# always have the same number of entries in the two lists.
for cppunit_tests_env, boost_tests_env in zip(envs.cppunit_tests.AllVariantEnvs(), envs.boost_tests.AllVariantEnvs()):
@@ -122,6 +126,13 @@ Alias('docs', 'doc-html')
Alias('docs', 'doc-text')
Alias('docs', 'doc-man')
+###### Build the gettext translation files ######
+po_env = envs.base
+Export('po_env')
+# No variant_dir because the pofile workflow requires the outputs to
+# be in the source directory and in distributed archives.
+SConscript(['po/SConscript'])
+
# Don't generate the "dist" stuff unless it's been explicitly
# requested. This allows "dist" to build all targets with '.'
@@ -131,3 +142,7 @@ if 'dist' in COMMAND_LINE_TARGETS:
scons_args = [ '--variants=all', '.',
'-j', GetOption('num_jobs') ])
Alias('dist', archives)
+
+ # Rebuild the pofiles *before* attempting to build the
+ # distribution archive.
+ po_env.Depends('dist', 'update-po')
diff --git a/po/SConscript b/po/SConscript
new file mode 100644
index 00000000..51702b76
--- /dev/null
+++ b/po/SConscript
@@ -0,0 +1,87 @@
+# Copyright (C) 2010 Daniel Burrows
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+# MA 02111-1307, USA.
+
+Import('all_aptitude_srcs', 'po_env')
+
+pofile_languages = [
+ 'ar',
+ 'ast',
+ 'bs',
+ 'ca',
+ 'cs',
+ 'da',
+ 'de',
+ 'dz',
+ 'el',
+ 'es',
+ 'eu',
+ 'fi',
+ 'fr',
+ 'gl',
+ 'hu',
+ 'it',
+ 'ja',
+ 'km',
+ 'ku',
+ 'lt',
+ 'mr',
+ 'nb',
+ 'ne',
+ 'nl',
+ 'nn',
+ 'pl',
+ 'pt',
+ 'pt_BR',
+ 'ro',
+ 'ru',
+ 'sk',
+ 'sv',
+ 'th',
+ 'tl',
+ 'tr',
+ 'uk',
+ 'vi',
+ 'zh_CN',
+ 'zh_TW',
+ ]
+
+def BuildPoFile(env, lang, potfile = 'aptitude.pot'):
+ '''Build the po file for the given language, compile it to a mo
+file, and install the compiled form. Also distribute *both* the po
+file and the mo file.'''
+ po_file = env.Msgmerge(lang, potfile)
+ # TODO: the Precious() call should be in the pofile builder, if
+ # that's even possible?
+ env.Precious(po_file)
+ mo_file = env.Msgfmt(po_file)
+ po_env.Dist(po_file, mo_file)
+ env.Install('$LOCALEDIR/$LANG/LC_MESSAGES', LANG = lang)
+ env.Alias('update-po', mo_file)
+ return mo_file
+
+aptitude_pot = po_env.Xgettext('aptitude.pot', all_aptitude_srcs)
+po_env.Dist(aptitude_pot)
+
+# I seriously considered making aptitude.pot a default target, but
+# that would pollute the version control history with a bunch of
+# relatively meaningless changes. Better to only build it on request.
+po_env.Alias('update-po', aptitude_pot)
+
+
+# Rules relating to keeping the translations up-to-date.
+for lang in pofile_languages:
+ BuildPoFile(po_env, lang, aptitude_pot)
diff --git a/site_scons/aptitude_configure.py b/site_scons/aptitude_configure.py
index d28150e2..5d633818 100644
--- a/site_scons/aptitude_configure.py
+++ b/site_scons/aptitude_configure.py
@@ -175,11 +175,14 @@ Returns an object with the following fields:
base.Tool('docbook')
base.Tool('docbook-xsl-import-scanner')
base.Tool('html2text')
+ base.Tool('msgfmt')
+ base.Tool('msgmerge')
base.Tool('pkg_config')
base.Tool('po4a')
base.Tool('rsvg')
base.Tool('test')
base.Tool('variant_builds')
+ base.Tool('xgettext')
base.Tool('xml-external-entity-scanner')
def DisableVariants(env):