Skip to content

Commit 8f33f8a

Browse files
committed
try rebuild translation js
1 parent bb07253 commit 8f33f8a

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"devDependencies": {
1717
"bower": "*",
1818
"less": "~2",
19-
"requirejs": "^2.1.17"
19+
"requirejs": "^2.1.17",
20+
"po2json": "^0.4.5"
2021
},
2122
"dependencies": {}
2223
}

setup.py

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
check_package_data_first,
4141
CompileCSS,
4242
CompileJS,
43+
CompileBackendTranslation,
4344
Bower,
4445
JavascriptVersion,
4546
css_js_prerelease,
@@ -131,6 +132,7 @@ def run(self):
131132
'sdist' : css_js_prerelease(sdist, strict=True),
132133
'develop': css_js_prerelease(develop),
133134
'css' : CompileCSS,
135+
'backendtranslations': CompileBackendTranslation,
134136
'js' : CompileJS,
135137
'jsdeps' : Bower,
136138
'jsversion' : JavascriptVersion,

setupbase.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,21 @@ def run(cmd, *args, **kwargs):
337337
kwargs['shell'] = (sys.platform == 'win32')
338338
return check_call(cmd, *args, **kwargs)
339339

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+
])
340355

341356
class Bower(Command):
342357
description = "fetch static client-side components with bower"
@@ -467,7 +482,7 @@ def run(self):
467482

468483

469484
class CompileJS(Command):
470-
"""Rebuild Notebook Javascript main.min.js files
485+
"""Rebuild Notebook Javascript main.min.js files and translation files.
471486
472487
Calls require via build-main.js
473488
"""
@@ -526,12 +541,16 @@ def build_main(self, name):
526541
log.info("Rebuilding %s" % target)
527542
run(['node', 'tools/build-main.js', name])
528543

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+
529547
def run(self):
530548
self.run_command('jsdeps')
531549
env = os.environ.copy()
532550
env['PATH'] = npm_path
533551
pool = ThreadPool()
534552
pool.map(self.build_main, self.apps)
553+
pool.map(self.build_jstranslation, glob('notebook/i18n/??_??'))
535554
# update package data in case this created new files
536555
update_package_data(self.distribution)
537556

@@ -586,6 +605,7 @@ def run(self):
586605
try:
587606
self.distribution.run_command('js')
588607
self.distribution.run_command('css')
608+
self.distribution.run_command('backendtranslations')
589609
except Exception as e:
590610
# refresh missing
591611
missing = [ t for t in targets if not os.path.exists(t) ]

0 commit comments

Comments
 (0)