2222# --/
2323
2424
25+ from roundup import configuration
2526from roundup .cgi .TAL import talgettext
2627from roundup .i18n import _
2728from roundup .pygettext import TokenEater , make_escapes , tokenize
2829
2930try :
3031 import polib
3132except ImportError :
32- print (_ ("\n Extracting translatable strings from html templates.\n "
33+ print (_ ("\n Extracting translatable strings only from html templates.\n "
3334 "Because the 'polib' module is missing, unable to extract\n "
3435 "translations from detectors or extensions.\n "
3536 "The 'polib' module can be installed with pip.\n " ))
@@ -64,17 +65,17 @@ class Options:
6465TEMPLATE_FILE = "messages.pot"
6566
6667
67- # FIXME: html directory can be specified in config.ini. Should be
68- # a parameter, or config.ini should be loaded.
6968def run ():
7069 # return unless command line arguments contain single directory path
7170 if (len (sys .argv ) != 2 ) or (sys .argv [1 ] in ("-h" , "--help" )):
7271 print (_ ("Usage: %(program)s <tracker home>" ) %
7372 {"program" : sys .argv [0 ]})
7473 return
75- # collect file paths of html templates
74+
7675 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" ]
7879 if os .path .isdir (htmldir ):
7980 # glob is not used because i want to match file names
8081 # without case sensitivity, and that is easier done this way.
@@ -85,17 +86,21 @@ def run():
8586 htmlfiles = []
8687 # return if no html files found
8788 if not htmlfiles :
88- print (_ ("No tracker templates found in directory %s" ) % home )
89+ print (_ ("No tracker templates found in directory %s" ) % htmldir )
8990 return
9091 # change to locale dir to have relative source references
9192 locale = os .path .join (home , "locale" )
9293 if not os .path .isdir (locale ):
9394 os .mkdir (locale )
9495 os .chdir (locale )
96+
97+ # compute relative path to template directory from locale directory
98+ relpath = os .path .relpath (htmldir )
99+
95100 # tweak sys.argv as this is the only way to tell talgettext what to do
96101 # Note: unix-style paths used instead of os.path.join deliberately
97102 sys .argv [1 :] = ["-o" , TEMPLATE_FILE ] \
98- + ["../html /" + filename for filename in htmlfiles ]
103+ + [relpath + " /" + filename for filename in htmlfiles ]
99104 # run
100105 talgettext .main ()
101106
0 commit comments