@@ -337,6 +337,21 @@ def run(cmd, *args, **kwargs):
337
337
kwargs ['shell' ] = (sys .platform == 'win32' )
338
338
return check_call (cmd , * args , ** kwargs )
339
339
340
+ class CompileBackendTranslation (Command ):
341
+ description = "compile the .po files into .mo files, that contain the translations."
342
+
343
+ def run (self ):
344
+ paths = glob ('notebook/i18n/??_??' )
345
+ for p in paths :
346
+ LANG = p .split ('/' )[- 1 ]
347
+ for component in ['notebook' , 'nbui' ]:
348
+ run (['pybabel' , 'compile' ,
349
+ '-D' , component ,
350
+ '-f' ,
351
+ '-l' , LANG ,
352
+ '-i' , pjoin ('notebook' , 'i18n' , LANG , 'LC_MESSAGES' , 'notebook.po' ),
353
+ '-o' , pjoin ('notebook' , 'i18n' , LANG , 'LC_MESSAGES' , 'notebook.mo' )
354
+ ])
340
355
341
356
class Bower (Command ):
342
357
description = "fetch static client-side components with bower"
@@ -467,7 +482,7 @@ def run(self):
467
482
468
483
469
484
class CompileJS (Command ):
470
- """Rebuild Notebook Javascript main.min.js files
485
+ """Rebuild Notebook Javascript main.min.js files and translation files.
471
486
472
487
Calls require via build-main.js
473
488
"""
@@ -526,12 +541,16 @@ def build_main(self, name):
526
541
log .info ("Rebuilding %s" % target )
527
542
run (['node' , 'tools/build-main.js' , name ])
528
543
544
+ def build_jstranslation (self , trd ):
545
+ run (['po2json' , '-p' , '-F' , '-f' , 'jed1.x' , '-d' , 'nbjs' , trd + '/LC_MESSAGES/nbjs.po' , trd + '/LC_MESSAGES/nbjs.json' ])
546
+
529
547
def run (self ):
530
548
self .run_command ('jsdeps' )
531
549
env = os .environ .copy ()
532
550
env ['PATH' ] = npm_path
533
551
pool = ThreadPool ()
534
552
pool .map (self .build_main , self .apps )
553
+ pool .map (self .build_jstranslation , glob ('notebook/i18n/??_??' ))
535
554
# update package data in case this created new files
536
555
update_package_data (self .distribution )
537
556
@@ -586,6 +605,7 @@ def run(self):
586
605
try :
587
606
self .distribution .run_command ('js' )
588
607
self .distribution .run_command ('css' )
608
+ self .distribution .run_command ('backendtranslations' )
589
609
except Exception as e :
590
610
# refresh missing
591
611
missing = [ t for t in targets if not os .path .exists (t ) ]
0 commit comments