Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/SConstruct
blob: 118c1301c696fd1f339d24faaab20b592493b272 (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
# Copyright (C) 2009, 2010, 2011  Rickard Lindberg, Roger Lindberg
#
# This file is part of Timeline.
#
# Timeline 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 3 of the License, or
# (at your option) any later version.
#
# Timeline 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 Timeline.  If not, see <http://www.gnu.org/licenses/>.

import os

env = Environment()

# Help

env.Help("""
Targets:

  mo      - compiled translations
  pot     - translation template
""")

# Import environment variables

for env_var in ["PYTHONPATH"]:
    if os.environ.has_key(env_var):
        env["ENV"][env_var] = os.environ[env_var]

# Find paths to programs and print warning messages if not found

env["MSGFMT"] = WhereIs("msgfmt")
env["XGETTEXT"] = WhereIs("xgettext")

if not env["MSGFMT"]:
    print "Warning: msgfmt not found, can't generate mo files"

if not env["XGETTEXT"]:
    print "Warning: xgettext not found, can't generate pot file"

# Import modules that we need

import os
import os.path

# Helper functions

def find_py_files_in(path):
    py_files = []
    for root, dirs, files in os.walk(path):
        py_files += [os.path.join(root, f) for f in files if f.endswith(".py")]
    return py_files

# Gather a list with all source files

sources = find_py_files_in("timelinelib")

# Target: mo

languages = [os.path.basename(x)[:-3] for x in env.Glob("po/*.po", strings=True)]
for language in languages:
    target = "po/%s/LC_MESSAGES/timeline.mo" % language
    env.Alias("mo", env.Command(target, "po/%s.po" % language,
                                '"$MSGFMT" -o $TARGET $SOURCE'))
    env.Clean(target, "po/"+language) # Removed the folder

# Target: pot

env["XGETTEXTFLAGS"] = " --copyright-holder=\"Rickard Lindberg\"" \
                       " --package-name=Timeline" \
                       " --add-comments=TRANSLATORS"
pot = env.Command("po/timeline.pot", sources,
                  '"$XGETTEXT" -o $TARGET $XGETTEXTFLAGS $SOURCES')
env.Alias("pot", pot)

# vim: syntax=python