22
22
# --/
23
23
24
24
25
+ from roundup import configuration
25
26
from roundup .cgi .TAL import talgettext
26
27
from roundup .i18n import _
27
28
from roundup .pygettext import TokenEater , make_escapes , tokenize
28
29
29
30
try :
30
31
import polib
31
32
except ImportError :
32
- print (_ ("\n Extracting translatable strings from html templates.\n "
33
+ print (_ ("\n Extracting translatable strings only from html templates.\n "
33
34
"Because the 'polib' module is missing, unable to extract\n "
34
35
"translations from detectors or extensions.\n "
35
36
"The 'polib' module can be installed with pip.\n " ))
@@ -64,17 +65,17 @@ class Options:
64
65
TEMPLATE_FILE = "messages.pot"
65
66
66
67
67
- # FIXME: html directory can be specified in config.ini. Should be
68
- # a parameter, or config.ini should be loaded.
69
68
def run ():
70
69
# return unless command line arguments contain single directory path
71
70
if (len (sys .argv ) != 2 ) or (sys .argv [1 ] in ("-h" , "--help" )):
72
71
print (_ ("Usage: %(program)s <tracker home>" ) %
73
72
{"program" : sys .argv [0 ]})
74
73
return
75
- # collect file paths of html templates
74
+
76
75
home = os .path .abspath (sys .argv [1 ])
77
- htmldir = os .path .join (home , "html" )
76
+ # collect file paths of html templates from config
77
+ config = configuration .CoreConfig (home )
78
+ htmldir = config ["TEMPLATES" ]
78
79
if os .path .isdir (htmldir ):
79
80
# glob is not used because i want to match file names
80
81
# without case sensitivity, and that is easier done this way.
@@ -85,17 +86,21 @@ def run():
85
86
htmlfiles = []
86
87
# return if no html files found
87
88
if not htmlfiles :
88
- print (_ ("No tracker templates found in directory %s" ) % home )
89
+ print (_ ("No tracker templates found in directory %s" ) % htmldir )
89
90
return
90
91
# change to locale dir to have relative source references
91
92
locale = os .path .join (home , "locale" )
92
93
if not os .path .isdir (locale ):
93
94
os .mkdir (locale )
94
95
os .chdir (locale )
96
+
97
+ # compute relative path to template directory from locale directory
98
+ relpath = os .path .relpath (htmldir )
99
+
95
100
# tweak sys.argv as this is the only way to tell talgettext what to do
96
101
# Note: unix-style paths used instead of os.path.join deliberately
97
102
sys .argv [1 :] = ["-o" , TEMPLATE_FILE ] \
98
- + ["../html /" + filename for filename in htmlfiles ]
103
+ + [relpath + " /" + filename for filename in htmlfiles ]
99
104
# run
100
105
talgettext .main ()
101
106
0 commit comments