Translate support for configuration page
This commit is contained in:
parent
84ab076fe8
commit
87536619e3
2 changed files with 17 additions and 4 deletions
|
@ -1,5 +1,11 @@
|
||||||
from Plugin import PluginManager
|
from Plugin import PluginManager
|
||||||
from Config import config
|
from Config import config
|
||||||
|
from Translate import Translate
|
||||||
|
from cStringIO import StringIO
|
||||||
|
|
||||||
|
|
||||||
|
if "_" not in locals():
|
||||||
|
_ = Translate("plugins/UiConfig/languages/")
|
||||||
|
|
||||||
|
|
||||||
@PluginManager.afterLoad
|
@PluginManager.afterLoad
|
||||||
|
@ -30,7 +36,15 @@ class UiRequestPlugin(object):
|
||||||
# If debugging merge *.css to all.css and *.js to all.js
|
# If debugging merge *.css to all.css and *.js to all.js
|
||||||
from Debug import DebugMedia
|
from Debug import DebugMedia
|
||||||
DebugMedia.merge(file_path)
|
DebugMedia.merge(file_path)
|
||||||
return self.actionFile(file_path)
|
|
||||||
|
if file_path.endswith("js"):
|
||||||
|
data = _.translateData(open(file_path).read(), mode="js")
|
||||||
|
elif file_path.endswith("html"):
|
||||||
|
data = _.translateData(open(file_path).read(), mode="html")
|
||||||
|
else:
|
||||||
|
data = open(file_path).read()
|
||||||
|
|
||||||
|
return self.actionFile(file_path, file_obj=StringIO(data), file_size=len(data))
|
||||||
else:
|
else:
|
||||||
return super(UiRequestPlugin, self).actionUiMedia(path)
|
return super(UiRequestPlugin, self).actionUiMedia(path)
|
||||||
|
|
||||||
|
@ -45,7 +59,7 @@ class UiWebsocketPlugin(object):
|
||||||
if key not in config.keys_api_change_allowed:
|
if key not in config.keys_api_change_allowed:
|
||||||
continue
|
continue
|
||||||
is_pending = key in config.pending_changes
|
is_pending = key in config.pending_changes
|
||||||
if val == None and is_pending:
|
if val is None and is_pending:
|
||||||
val = config.parser.get_default(key)
|
val = config.parser.get_default(key)
|
||||||
back[key] = {
|
back[key] = {
|
||||||
"value": val,
|
"value": val,
|
||||||
|
@ -53,4 +67,3 @@ class UiWebsocketPlugin(object):
|
||||||
"pending": is_pending
|
"pending": is_pending
|
||||||
}
|
}
|
||||||
return back
|
return back
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,6 @@
|
||||||
<div class="bottom" id="bottom-save"></div>
|
<div class="bottom" id="bottom-save"></div>
|
||||||
<div class="bottom" id="bottom-restart"></div>
|
<div class="bottom" id="bottom-restart"></div>
|
||||||
|
|
||||||
<script type="text/javascript" src="js/all.js"></script>
|
<script type="text/javascript" src="js/all.js?rev={rev}&lang={lang}"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue