Merge pull request #691 from ysc3839/master
Translations for more plugins.
This commit is contained in:
commit
383d8a5f33
7 changed files with 61 additions and 24 deletions
|
@ -2,6 +2,7 @@ import re
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from Plugin import PluginManager
|
from Plugin import PluginManager
|
||||||
|
from Translate import Translate
|
||||||
from util import RateLimit
|
from util import RateLimit
|
||||||
from util import helper
|
from util import helper
|
||||||
try:
|
try:
|
||||||
|
@ -15,6 +16,8 @@ if "merger_db" not in locals().keys(): # To keep merger_sites between module re
|
||||||
merged_to_merger = {} # {address: [site1, site2, ...]} cache
|
merged_to_merger = {} # {address: [site1, site2, ...]} cache
|
||||||
site_manager = None # Site manager for merger sites
|
site_manager = None # Site manager for merger sites
|
||||||
|
|
||||||
|
if "_" not in locals():
|
||||||
|
_ = Translate("plugins/MergerSite/languages/")
|
||||||
|
|
||||||
# Check if the site has permission to this merger site
|
# Check if the site has permission to this merger site
|
||||||
def checkMergerPath(address, inner_path):
|
def checkMergerPath(address, inner_path):
|
||||||
|
@ -56,7 +59,7 @@ class UiWebsocketPlugin(object):
|
||||||
else:
|
else:
|
||||||
self.cmd(
|
self.cmd(
|
||||||
"confirm",
|
"confirm",
|
||||||
["Add <b>%s</b> new site?" % len(addresses), "Add"],
|
[_["Add <b>%s</b> new site?"] % len(addresses), "Add"],
|
||||||
lambda (res): self.cbMergerSiteAdd(to, addresses)
|
lambda (res): self.cbMergerSiteAdd(to, addresses)
|
||||||
)
|
)
|
||||||
self.response(to, "ok")
|
self.response(to, "ok")
|
||||||
|
@ -68,7 +71,7 @@ class UiWebsocketPlugin(object):
|
||||||
added += 1
|
added += 1
|
||||||
site_manager.need(address)
|
site_manager.need(address)
|
||||||
if added:
|
if added:
|
||||||
self.cmd("notification", ["done", "Added <b>%s</b> new site" % added, 5000])
|
self.cmd("notification", ["done", _["Added <b>%s</b> new site"] % added, 5000])
|
||||||
RateLimit.called(self.site.address + "-MergerSiteAdd")
|
RateLimit.called(self.site.address + "-MergerSiteAdd")
|
||||||
site_manager.updateMergerSites()
|
site_manager.updateMergerSites()
|
||||||
|
|
||||||
|
@ -84,7 +87,7 @@ class UiWebsocketPlugin(object):
|
||||||
if merged_db.get(address) not in merger_types:
|
if merged_db.get(address) not in merger_types:
|
||||||
return self.response(to, {"error": "Merged type (%s) not in %s" % (merged_db.get(address), merger_types)})
|
return self.response(to, {"error": "Merged type (%s) not in %s" % (merged_db.get(address), merger_types)})
|
||||||
|
|
||||||
self.cmd("notification", ["done", "Site deleted: <b>%s</b>" % address, 5000])
|
self.cmd("notification", ["done", _["Site deleted: <b>%s</b>"] % address, 5000])
|
||||||
self.response(to, "ok")
|
self.response(to, "ok")
|
||||||
|
|
||||||
# Lists merged sites
|
# Lists merged sites
|
||||||
|
|
5
plugins/MergerSite/languages/zh.json.unfinished
Normal file
5
plugins/MergerSite/languages/zh.json.unfinished
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"Add <b>%s</b> new site?": "",
|
||||||
|
"Added <b>%s</b> new site": "",
|
||||||
|
"Site deleted: <b>%s</b>": ""
|
||||||
|
}
|
|
@ -7,7 +7,10 @@ import gevent
|
||||||
from Plugin import PluginManager
|
from Plugin import PluginManager
|
||||||
from Config import config
|
from Config import config
|
||||||
from util import helper
|
from util import helper
|
||||||
|
from Translate import Translate
|
||||||
|
|
||||||
|
if "_" not in locals():
|
||||||
|
_ = Translate("plugins/OptionalManager/languages/")
|
||||||
|
|
||||||
@PluginManager.registerTo("UiWebsocket")
|
@PluginManager.registerTo("UiWebsocket")
|
||||||
class UiWebsocketPlugin(object):
|
class UiWebsocketPlugin(object):
|
||||||
|
@ -99,13 +102,13 @@ class UiWebsocketPlugin(object):
|
||||||
def actionOptionalFilePin(self, to, inner_path, address=None):
|
def actionOptionalFilePin(self, to, inner_path, address=None):
|
||||||
back = self.setPin(inner_path, 1, address)
|
back = self.setPin(inner_path, 1, address)
|
||||||
if back == "ok":
|
if back == "ok":
|
||||||
self.cmd("notification", ["done", "Pinned %s files" % len(inner_path) if type(inner_path) is list else 1, 5000])
|
self.cmd("notification", ["done", _["Pinned %s files"] % len(inner_path) if type(inner_path) is list else 1, 5000])
|
||||||
self.response(to, back)
|
self.response(to, back)
|
||||||
|
|
||||||
def actionOptionalFileUnpin(self, to, inner_path, address=None):
|
def actionOptionalFileUnpin(self, to, inner_path, address=None):
|
||||||
back = self.setPin(inner_path, 0, address)
|
back = self.setPin(inner_path, 0, address)
|
||||||
if back == "ok":
|
if back == "ok":
|
||||||
self.cmd("notification", ["done", "Removed pin from %s files" % len(inner_path) if type(inner_path) is list else 1, 5000])
|
self.cmd("notification", ["done", _["Removed pin from %s files"] % len(inner_path) if type(inner_path) is list else 1, 5000])
|
||||||
self.response(to, back)
|
self.response(to, back)
|
||||||
|
|
||||||
def actionOptionalFileDelete(self, to, inner_path, address=None):
|
def actionOptionalFileDelete(self, to, inner_path, address=None):
|
||||||
|
@ -202,7 +205,7 @@ class UiWebsocketPlugin(object):
|
||||||
|
|
||||||
self.cmd("notification", [
|
self.cmd("notification", [
|
||||||
"done",
|
"done",
|
||||||
"You started to help distribute <b>%s</b>.<br><small>Directory: %s</small>" %
|
_["You started to help distribute <b>%s</b>.<br><small>Directory: %s</small>"] %
|
||||||
(cgi.escape(title), cgi.escape(directory)),
|
(cgi.escape(title), cgi.escape(directory)),
|
||||||
10000
|
10000
|
||||||
])
|
])
|
||||||
|
@ -247,8 +250,8 @@ class UiWebsocketPlugin(object):
|
||||||
self.cmd(
|
self.cmd(
|
||||||
"confirm",
|
"confirm",
|
||||||
[
|
[
|
||||||
"Help distribute all new optional files on site <b>%s</b>" % cgi.escape(site_title),
|
_["Help distribute all new optional files on site <b>%s</b>"] % cgi.escape(site_title),
|
||||||
"Yes, I want to help!"
|
_["Yes, I want to help!"]
|
||||||
],
|
],
|
||||||
lambda (res): self.cbOptionalHelpAll(to, site, True)
|
lambda (res): self.cbOptionalHelpAll(to, site, True)
|
||||||
)
|
)
|
||||||
|
|
7
plugins/OptionalManager/languages/zh.json.unfinished
Normal file
7
plugins/OptionalManager/languages/zh.json.unfinished
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"Pinned %s files": "",
|
||||||
|
"Removed pin from %s files": "",
|
||||||
|
"You started to help distribute <b>%s</b>.<br><small>Directory: %s</small>": "",
|
||||||
|
"Help distribute all new optional files on site <b>%s</b>": "",
|
||||||
|
"Yes, I want to help!": ""
|
||||||
|
}
|
|
@ -24,7 +24,7 @@ sys.path.append(plugin_dir) # To able to load geoip lib
|
||||||
|
|
||||||
loc_cache = {}
|
loc_cache = {}
|
||||||
if "_" not in locals():
|
if "_" not in locals():
|
||||||
_ = Translate("plugins/Sidebar/languages/")
|
_ = Translate(plugin_dir + "/languages/")
|
||||||
|
|
||||||
|
|
||||||
@PluginManager.registerTo("UiRequest")
|
@PluginManager.registerTo("UiRequest")
|
||||||
|
|
|
@ -5,9 +5,12 @@ import atexit
|
||||||
|
|
||||||
from Plugin import PluginManager
|
from Plugin import PluginManager
|
||||||
from Config import config
|
from Config import config
|
||||||
|
from Translate import Translate
|
||||||
|
|
||||||
allow_reload = False # No source reload supported in this plugin
|
allow_reload = False # No source reload supported in this plugin
|
||||||
|
|
||||||
|
if "_" not in locals():
|
||||||
|
_ = Translate("plugins/Trayicon/languages/")
|
||||||
|
|
||||||
@PluginManager.registerTo("Actions")
|
@PluginManager.registerTo("Actions")
|
||||||
class ActionsPlugin(object):
|
class ActionsPlugin(object):
|
||||||
|
@ -46,14 +49,14 @@ class ActionsPlugin(object):
|
||||||
(self.titleConsole, self.toggleConsole),
|
(self.titleConsole, self.toggleConsole),
|
||||||
(self.titleAutorun, self.toggleAutorun),
|
(self.titleAutorun, self.toggleAutorun),
|
||||||
"--",
|
"--",
|
||||||
("ZeroNet Twitter", lambda: self.opensite("https://twitter.com/HelloZeroNet")),
|
(_["ZeroNet Twitter"], lambda: self.opensite("https://twitter.com/HelloZeroNet")),
|
||||||
("ZeroNet Reddit", lambda: self.opensite("http://www.reddit.com/r/zeronet/")),
|
(_["ZeroNet Reddit"], lambda: self.opensite("http://www.reddit.com/r/zeronet/")),
|
||||||
("ZeroNet Github", lambda: self.opensite("https://github.com/HelloZeroNet/ZeroNet")),
|
(_["ZeroNet Github"], lambda: self.opensite("https://github.com/HelloZeroNet/ZeroNet")),
|
||||||
("Report bug/request feature", lambda: self.opensite("https://github.com/HelloZeroNet/ZeroNet/issues")),
|
(_["Report bug/request feature"], lambda: self.opensite("https://github.com/HelloZeroNet/ZeroNet/issues")),
|
||||||
"--",
|
"--",
|
||||||
("!Open ZeroNet", lambda: self.opensite("http://%s:%s/%s" % (ui_ip, config.ui_port, config.homepage) )),
|
(_["!Open ZeroNet"], lambda: self.opensite("http://%s:%s/%s" % (ui_ip, config.ui_port, config.homepage) )),
|
||||||
"--",
|
"--",
|
||||||
("Quit", self.quit),
|
(_["Quit"], self.quit),
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -76,27 +79,28 @@ class ActionsPlugin(object):
|
||||||
def titleIp(self):
|
def titleIp(self):
|
||||||
title = "!IP: %s " % config.ip_external
|
title = "!IP: %s " % config.ip_external
|
||||||
if self.main.file_server.port_opened:
|
if self.main.file_server.port_opened:
|
||||||
title += " (active)"
|
title += _["(active)"]
|
||||||
else:
|
else:
|
||||||
title += " (passive)"
|
title += _["(passive)"]
|
||||||
return title
|
return title
|
||||||
|
|
||||||
def titleConnections(self):
|
def titleConnections(self):
|
||||||
title = "Connections: %s" % len(self.main.file_server.connections)
|
title = _["Connections: %s"] % len(self.main.file_server.connections)
|
||||||
return title
|
return title
|
||||||
|
|
||||||
def titleTransfer(self):
|
def titleTransfer(self):
|
||||||
title = "Received: %.2f MB | Sent: %.2f MB" % (
|
title = _["Received: %.2f MB | Sent: %.2f MB"] % (
|
||||||
float(self.main.file_server.bytes_recv) / 1024 / 1024,
|
float(self.main.file_server.bytes_recv) / 1024 / 1024,
|
||||||
float(self.main.file_server.bytes_sent) / 1024 / 1024
|
float(self.main.file_server.bytes_sent) / 1024 / 1024
|
||||||
)
|
)
|
||||||
return title
|
return title
|
||||||
|
|
||||||
def titleConsole(self):
|
def titleConsole(self):
|
||||||
|
translate = _["Show console window"]
|
||||||
if self.console:
|
if self.console:
|
||||||
return "+Show console window"
|
return "+" + translate
|
||||||
else:
|
else:
|
||||||
return "Show console window"
|
return translate
|
||||||
|
|
||||||
def toggleConsole(self):
|
def toggleConsole(self):
|
||||||
if self.console:
|
if self.console:
|
||||||
|
@ -126,10 +130,11 @@ class ActionsPlugin(object):
|
||||||
return os.path.isfile(path) and open(path).read() == self.formatAutorun()
|
return os.path.isfile(path) and open(path).read() == self.formatAutorun()
|
||||||
|
|
||||||
def titleAutorun(self):
|
def titleAutorun(self):
|
||||||
|
translate = _["Start ZeroNet when Windows starts"]
|
||||||
if self.isAutorunEnabled():
|
if self.isAutorunEnabled():
|
||||||
return "+Start ZeroNet when Windows starts"
|
return "+" + translate
|
||||||
else:
|
else:
|
||||||
return "Start ZeroNet when Windows starts"
|
return translate
|
||||||
|
|
||||||
def toggleAutorun(self):
|
def toggleAutorun(self):
|
||||||
if self.isAutorunEnabled():
|
if self.isAutorunEnabled():
|
||||||
|
|
14
plugins/Trayicon/languages/zh.json
Normal file
14
plugins/Trayicon/languages/zh.json
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"ZeroNet Twitter": "ZeroNet Twitter",
|
||||||
|
"ZeroNet Reddit": "ZeroNet Reddit",
|
||||||
|
"ZeroNet Github": "ZeroNet Github",
|
||||||
|
"Report bug/request feature": "反馈问题/请求功能",
|
||||||
|
"!Open ZeroNet": "!打开 ZeroNet",
|
||||||
|
"Quit": "退出",
|
||||||
|
"(active)": "(激活)",
|
||||||
|
"(passive)": "(passive)",
|
||||||
|
"Connections: %s": "连接数: %s",
|
||||||
|
"Received: %.2f MB | Sent: %.2f MB": "已收到: %.2f MB | 已发送: %.2f MB",
|
||||||
|
"Show console window": "显示控制台窗口",
|
||||||
|
"Start ZeroNet when Windows starts": "在 Windows 启动时运行 ZeroNet"
|
||||||
|
}
|
Loading…
Reference in a new issue