equal
deleted
inserted
replaced
91 __author__ = "Pierre Rouleau" |
91 __author__ = "Pierre Rouleau" |
92 __version__= "$Revision: 1.5 $" |
92 __version__= "$Revision: 1.5 $" |
93 |
93 |
94 # ----------------------------------------------------------------------------- |
94 # ----------------------------------------------------------------------------- |
95 |
95 |
|
96 |
96 def getlanguageDict(): |
97 def getlanguageDict(): |
97 languageDict = {} |
98 languageDict = {} |
98 |
99 |
99 if wx.VERSION >= (3, 0, 0): |
100 if wx.VERSION >= (3, 0, 0): |
100 app = wx.App() |
101 app = wx.App() |
208 cmd = 'msgmerge -s --no-wrap "%s" %s > "%s.new"' % (langPOfileName, fileout, langPOfileName) |
209 cmd = 'msgmerge -s --no-wrap "%s" %s > "%s.new"' % (langPOfileName, fileout, langPOfileName) |
209 if verbose: print cmd |
210 if verbose: print cmd |
210 os.system(cmd) |
211 os.system(cmd) |
211 os.chdir(currentDir) |
212 os.chdir(currentDir) |
212 |
213 |
213 # ----------------------------------------------------------------------------- |
214 |
214 # c a t P O ( ) -- Concatenate one or several PO files with the application domain files. -- |
|
215 # ^^^^^^^^^^^^^ |
|
216 # |
|
217 def catPO(applicationDirectoryPath, listOf_extraPo, applicationDomain=None, targetDir=None, verbose=0) : |
215 def catPO(applicationDirectoryPath, listOf_extraPo, applicationDomain=None, targetDir=None, verbose=0) : |
218 """Concatenate one or several PO files with the application domain files. |
216 """Concatenate one or several PO files with the application domain files. |
219 """ |
217 """ |
220 |
218 |
221 if applicationDomain is None: |
219 if applicationDomain is None: |
246 cmd = "msgfmt --output-file=%s/%s.mo %s_%s.po.cat" % (mo_targetDir,applicationName,applicationName,langCode) |
244 cmd = "msgfmt --output-file=%s/%s.mo %s_%s.po.cat" % (mo_targetDir,applicationName,applicationName,langCode) |
247 if verbose: print cmd |
245 if verbose: print cmd |
248 os.system(cmd) |
246 os.system(cmd) |
249 os.chdir(currentDir) |
247 os.chdir(currentDir) |
250 |
248 |
251 # ----------------------------------------------------------------------------- |
249 |
252 # m a k e M O ( ) -- Compile the Portable Object files into the Machine Object stored in the right location. -- |
|
253 # ^^^^^^^^^^^^^^^ |
|
254 # |
|
255 def makeMO(applicationDirectoryPath,targetDir='./locale',applicationDomain=None, verbose=0, forceEnglish=0) : |
250 def makeMO(applicationDirectoryPath,targetDir='./locale',applicationDomain=None, verbose=0, forceEnglish=0) : |
256 """Compile the Portable Object files into the Machine Object stored in the right location. |
251 """Compile the Portable Object files into the Machine Object stored in the right location. |
257 |
252 |
258 makeMO converts all translated language-specific PO files located inside |
253 makeMO converts all translated language-specific PO files located inside |
259 the application directory into the binary .MO files stored inside the |
254 the application directory into the binary .MO files stored inside the |
295 cmd = 'msgfmt --output-file="%s/%s.mo" "%s_%s.po"' % (mo_targetDir,applicationName,applicationName,langCode) |
290 cmd = 'msgfmt --output-file="%s/%s.mo" "%s_%s.po"' % (mo_targetDir,applicationName,applicationName,langCode) |
296 if verbose: print cmd |
291 if verbose: print cmd |
297 os.system(cmd) |
292 os.system(cmd) |
298 os.chdir(currentDir) |
293 os.chdir(currentDir) |
299 |
294 |
300 # ----------------------------------------------------------------------------- |
295 |
301 # p r i n t U s a g e -- Displays how to use this script from the command line -- |
|
302 # ^^^^^^^^^^^^^^^^^^^ |
|
303 # |
|
304 def printUsage(errorMsg=None) : |
296 def printUsage(errorMsg=None) : |
305 """Displays how to use this script from the command line.""" |
297 """Displays how to use this script from the command line.""" |
306 print """ |
298 print """ |
307 ################################################################################## |
299 ################################################################################## |
308 # mki18n : Make internationalization files. # |
300 # mki18n : Make internationalization files. # |
335 # # |
327 # # |
336 ##################################################################################""" |
328 ##################################################################################""" |
337 if errorMsg: |
329 if errorMsg: |
338 print "\n ERROR: %s" % errorMsg |
330 print "\n ERROR: %s" % errorMsg |
339 |
331 |
340 # ----------------------------------------------------------------------------- |
332 |
341 # f i l e B a s e O f ( ) -- Return base name of filename -- |
|
342 # ^^^^^^^^^^^^^^^^^^^^^^^ |
|
343 # |
|
344 def fileBaseOf(filename,withPath=0) : |
333 def fileBaseOf(filename,withPath=0) : |
345 """fileBaseOf(filename,withPath) ---> string |
334 """fileBaseOf(filename,withPath) ---> string |
346 |
335 |
347 Return base name of filename. The returned string never includes the extension. |
336 Return base name of filename. The returned string never includes the extension. |
348 Use os.path.basename() to return the basename with the extension. The |
337 Use os.path.basename() to return the basename with the extension. The |
376 filename = filename[:pos] |
365 filename = filename[:pos] |
377 if withPath: |
366 if withPath: |
378 return filename |
367 return filename |
379 else: |
368 else: |
380 return os.path.basename(filename) |
369 return os.path.basename(filename) |
381 # ----------------------------------------------------------------------------- |
370 |
382 # m k d i r ( ) -- Create a directory (and possibly the entire tree) -- |
371 |
383 # ^^^^^^^^^^^^^ |
|
384 # |
|
385 def mkdir(directory) : |
372 def mkdir(directory) : |
386 """Create a directory (and possibly the entire tree). |
373 """Create a directory (and possibly the entire tree). |
387 |
374 |
388 The os.mkdir() will fail to create a directory if one of the |
375 The os.mkdir() will fail to create a directory if one of the |
389 directory in the specified path does not exist. mkdir() |
376 directory in the specified path does not exist. mkdir() |
418 theDir += aList[i] |
405 theDir += aList[i] |
419 if not os.path.exists(theDir): |
406 if not os.path.exists(theDir): |
420 os.mkdir(theDir) |
407 os.mkdir(theDir) |
421 theDir += '/' |
408 theDir += '/' |
422 |
409 |
423 # ----------------------------------------------------------------------------- |
410 |
424 # u n i x p a t h ( ) -- Return a path name that contains Unix separator. -- |
|
425 # ^^^^^^^^^^^^^^^^^^^ |
|
426 # |
|
427 def unixpath(thePath) : |
411 def unixpath(thePath) : |
428 r"""Return a path name that contains Unix separator. |
412 r"""Return a path name that contains Unix separator. |
429 |
413 |
430 [Example] |
414 [Example] |
431 >>> unixpath(r"d:\test") |
415 >>> unixpath(r"d:\test") |