summaryrefslogtreecommitdiff
path: root/po/SConscript
blob: a9e0d80f6d3730b646e96f7df293dd45d99fb2fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# 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',
                potfile_sig = 'aptitude.pot.sig'):
    '''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)

    # Arrange to build the pofile iff the potfile signature changes.
    env.Depends(po_file, potfile_sig)
    env.Ignore(po_file, potfile)

    return mo_file

aptitude_pot = po_env.Xgettext('aptitude.pot', all_aptitude_srcs)
po_env.Dist(aptitude_pot)

# Reuse the clunky but functional POT-Creation-Date stripping script
# from gettext.
removepotdate = po_env.Command('remove-potcdate.sed',
                               'remove-potcdate.sin',
                               ["sed -e '/^#/d' $SOURCE > ${TARGET}.new",
                                Move('${TARGET}', '${TARGET}.new')])

aptitude_pot_sig = po_env.Command('aptitude.pot.sig',
                                  aptitude_pot,
                                  ['sed -f $REMOVEPOTDATE $SOURCE | sha512sum > ${TARGET}.new',
                                   Move('${TARGET}', '${TARGET}.new')],
                                  REMOVEPOTDATE = removepotdate)

# 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, aptitude_pot_sig)