mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-19 14:54:21 +00:00
[#2837] [WebUI] Create gettext.js when building
This commit is contained in:
parent
a76fde5feb
commit
8a0b7d970a
@ -17,7 +17,7 @@ import re
|
|||||||
|
|
||||||
WEBUI_JS_DIR = 'deluge/ui/web/js/deluge-all'
|
WEBUI_JS_DIR = 'deluge/ui/web/js/deluge-all'
|
||||||
# Enabling Debug adds file and line number as comments to the gettext file.
|
# Enabling Debug adds file and line number as comments to the gettext file.
|
||||||
DEBUG = False
|
DEBUG = True
|
||||||
|
|
||||||
|
|
||||||
def check_missing_markup(js_dir):
|
def check_missing_markup(js_dir):
|
||||||
@ -71,6 +71,7 @@ GETTEXT_TPL = (
|
|||||||
'add:function(string,translation){this.maps[string]=translation},'
|
'add:function(string,translation){this.maps[string]=translation},'
|
||||||
'get:function(string){if (this.maps[string]){string=this.maps[string]} return string}};'
|
'get:function(string){if (this.maps[string]){string=this.maps[string]} return string}};'
|
||||||
'function _(string){return GetText.get(string)}')
|
'function _(string){return GetText.get(string)}')
|
||||||
|
GETTEXT_SUBST_TPL = ("GetText.add('{key}','${{escape(_(\"{key}\"))}}')\n")
|
||||||
|
|
||||||
|
|
||||||
def create_gettext_js(js_dir):
|
def create_gettext_js(js_dir):
|
||||||
@ -94,7 +95,7 @@ def create_gettext_js(js_dir):
|
|||||||
for key in sorted(strings):
|
for key in sorted(strings):
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
fp.write('\n//: %s' % '//: '.join(['%s:%s\n' % x for x in strings[key]]))
|
fp.write('\n//: %s' % '//: '.join(['%s:%s\n' % x for x in strings[key]]))
|
||||||
fp.write('''GetText.add('%(key)s','${escape(_("%(key)s"))}')\n''' % locals())
|
fp.write(GETTEXT_SUBST_TPL.format(key=key))
|
||||||
return gettext_file
|
return gettext_file
|
||||||
|
|
||||||
|
|
||||||
|
6
setup.py
6
setup.py
@ -134,6 +134,12 @@ class BuildWebUI(cmd.Command):
|
|||||||
print('Import error: %s' % import_error)
|
print('Import error: %s' % import_error)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
# Create the gettext.js file for translations.
|
||||||
|
from gen_web_gettext import create_gettext_js
|
||||||
|
deluge_all_path = os.path.join(js_basedir, self.JS_SRC_DIRS[0])
|
||||||
|
print('Creating WebUI translation file: %s/gettext.js' % deluge_all_path)
|
||||||
|
create_gettext_js(deluge_all_path)
|
||||||
|
|
||||||
|
|
||||||
class CleanWebUI(cmd.Command):
|
class CleanWebUI(cmd.Command):
|
||||||
description = 'Clean the documentation build and rst files'
|
description = 'Clean the documentation build and rst files'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user