[Pkg-anonymity-tools] [onionshare] 103/140: encode one way for CLI, encode another for GUI (#141)
Ulrike Uhlig
u-guest at moszumanska.debian.org
Mon Sep 29 20:33:52 UTC 2014
This is an automated email from the git hooks/post-receive script.
u-guest pushed a commit to branch master
in repository onionshare.
commit 89581b0a03cce79bdb21f1efea7e3f40a70dfe45
Author: Micah Lee <micah at micahflee.com>
Date: Tue Sep 16 02:09:37 2014 +0000
encode one way for CLI, encode another for GUI (#141)
---
onionshare/strings.py | 7 +++++--
onionshare_gui/downloads.py | 2 +-
onionshare_gui/file_selection.py | 12 ++++++------
onionshare_gui/onionshare_gui.py | 10 +++++-----
onionshare_gui/options.py | 2 +-
onionshare_gui/server_status.py | 6 +++---
6 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/onionshare/strings.py b/onionshare/strings.py
index a8561a8..0b21822 100644
--- a/onionshare/strings.py
+++ b/onionshare/strings.py
@@ -35,7 +35,10 @@ def load_strings(default="en"):
if key in translated[lang]:
strings[key] = translated[lang][key]
-def translated(k):
- return strings[k].encode("utf-8").decode('utf-8', 'replace')
+def translated(k, gui=False):
+ if gui:
+ return strings[k].encode("utf-8").decode('utf-8', 'replace')
+ else:
+ return strings[k].encode("utf-8")
_ = translated
diff --git a/onionshare_gui/downloads.py b/onionshare_gui/downloads.py
index 5580feb..18b9415 100644
--- a/onionshare_gui/downloads.py
+++ b/onionshare_gui/downloads.py
@@ -30,7 +30,7 @@ class Downloads(QtGui.QVBoxLayout):
self.progress_bars = {}
# downloads label
- self.downloads_label = QtGui.QLabel(strings._('gui_downloads'))
+ self.downloads_label = QtGui.QLabel(strings._('gui_downloads', True))
self.downloads_label.hide()
# add the widgets
diff --git a/onionshare_gui/file_selection.py b/onionshare_gui/file_selection.py
index 19fb3f8..a5a7b70 100644
--- a/onionshare_gui/file_selection.py
+++ b/onionshare_gui/file_selection.py
@@ -34,7 +34,7 @@ class FileList(QtGui.QListWidget):
self.setSortingEnabled(True)
# drag and drop label
- self.drop_label = QtGui.QLabel(QtCore.QString(strings._('gui_drag_and_drop')), parent=self)
+ self.drop_label = QtGui.QLabel(QtCore.QString(strings._('gui_drag_and_drop', True)), parent=self)
self.drop_label.setAlignment(QtCore.Qt.AlignCenter)
self.drop_label.setStyleSheet('background: url({0}) no-repeat center center; color: #999999;'.format(common.get_image_path('drop_files.png')))
self.drop_label.hide()
@@ -124,11 +124,11 @@ class FileSelection(QtGui.QVBoxLayout):
self.file_list.files_dropped.connect(self.update)
# buttons
- self.add_files_button = QtGui.QPushButton(strings._('gui_add_files'))
+ self.add_files_button = QtGui.QPushButton(strings._('gui_add_files', True))
self.add_files_button.clicked.connect(self.add_files)
- self.add_dir_button = QtGui.QPushButton(strings._('gui_add_folder'))
+ self.add_dir_button = QtGui.QPushButton(strings._('gui_add_folder', True))
self.add_dir_button.clicked.connect(self.add_dir)
- self.delete_button = QtGui.QPushButton(strings._('gui_delete'))
+ self.delete_button = QtGui.QPushButton(strings._('gui_delete', True))
self.delete_button.clicked.connect(self.delete_file)
button_layout = QtGui.QHBoxLayout()
button_layout.addWidget(self.add_files_button)
@@ -162,14 +162,14 @@ class FileSelection(QtGui.QVBoxLayout):
self.file_list.update()
def add_files(self):
- filenames = QtGui.QFileDialog.getOpenFileNames(caption=strings._('gui_choose_files'), options=QtGui.QFileDialog.ReadOnly)
+ filenames = QtGui.QFileDialog.getOpenFileNames(caption=strings._('gui_choose_files', True), options=QtGui.QFileDialog.ReadOnly)
if filenames:
for filename in filenames:
self.file_list.add_file(str(filename))
self.update()
def add_dir(self):
- filename = QtGui.QFileDialog.getExistingDirectory(caption=strings._('gui_choose_folder'), options=QtGui.QFileDialog.ReadOnly)
+ filename = QtGui.QFileDialog.getExistingDirectory(caption=strings._('gui_choose_folder', True), options=QtGui.QFileDialog.ReadOnly)
if filename:
self.file_list.add_file(str(filename))
self.update()
diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py
index e0fa319..33a40b3 100644
--- a/onionshare_gui/onionshare_gui.py
+++ b/onionshare_gui/onionshare_gui.py
@@ -100,7 +100,7 @@ class OnionShareGui(QtGui.QWidget):
def start_server(self):
# start the hidden service
- self.status_bar.showMessage(strings._('gui_starting_server').format(self.app.port))
+ self.status_bar.showMessage(strings._('gui_starting_server', True).format(self.app.port))
try:
self.app.choose_port()
print strings._("connecting_ctrlport").format(self.app.port)
@@ -161,7 +161,7 @@ class OnionShareGui(QtGui.QWidget):
for event in events:
if event["type"] == web.REQUEST_LOAD:
- self.status_bar.showMessage(strings._('download_page_loaded'))
+ self.status_bar.showMessage(strings._('download_page_loaded', True))
elif event["type"] == web.REQUEST_DOWNLOAD:
self.downloads.add_download(event["data"]["id"], web.zip_filesize)
@@ -176,10 +176,10 @@ class OnionShareGui(QtGui.QWidget):
self.server_status.stop_server()
elif event["path"] != '/favicon.ico':
- self.status_bar.showMessage('{0}: {1}'.format(strings._('other_page_loaded'), event["path"]))
+ self.status_bar.showMessage('{0}: {1}'.format(strings._('other_page_loaded', True), event["path"]))
def copy_url(self):
- self.status_bar.showMessage(strings._('gui_copied_url'), 2000)
+ self.status_bar.showMessage(strings._('gui_copied_url', True), 2000)
def clear_message(self):
self.status_bar.clearMessage()
@@ -221,7 +221,7 @@ def main():
valid = True
for filename in filenames:
if not os.path.exists(filename):
- alert(strings._("not_a_file").format(filename))
+ alert(strings._("not_a_file", True).format(filename))
valid = False
if not valid:
sys.exit()
diff --git a/onionshare_gui/options.py b/onionshare_gui/options.py
index 83306c4..7aefca4 100644
--- a/onionshare_gui/options.py
+++ b/onionshare_gui/options.py
@@ -35,7 +35,7 @@ class Options(QtGui.QHBoxLayout):
self.close_automatically.setCheckState(QtCore.Qt.Unchecked)
else:
self.close_automatically.setCheckState(QtCore.Qt.Checked)
- self.close_automatically.setText(strings._("close_on_finish"))
+ self.close_automatically.setText(strings._("close_on_finish", True))
self.connect(self.close_automatically, QtCore.SIGNAL('stateChanged(int)'), self.stay_open_changed)
# add the widgets
diff --git a/onionshare_gui/server_status.py b/onionshare_gui/server_status.py
index d82fce0..4de3ade 100644
--- a/onionshare_gui/server_status.py
+++ b/onionshare_gui/server_status.py
@@ -48,9 +48,9 @@ class ServerStatus(QtGui.QVBoxLayout):
self.status_image_started = QtGui.QImage(common.get_image_path('server_started.png'))
self.status_image_label = QtGui.QLabel()
self.status_image_label.setFixedWidth(30)
- self.start_server_button = QtGui.QPushButton(strings._('gui_start_server'))
+ self.start_server_button = QtGui.QPushButton(strings._('gui_start_server', True))
self.start_server_button.clicked.connect(self.start_server)
- self.stop_server_button = QtGui.QPushButton(strings._('gui_stop_server'))
+ self.stop_server_button = QtGui.QPushButton(strings._('gui_stop_server', True))
self.stop_server_button.clicked.connect(self.stop_server)
server_layout = QtGui.QHBoxLayout()
server_layout.addWidget(self.status_image_label)
@@ -64,7 +64,7 @@ class ServerStatus(QtGui.QVBoxLayout):
self.url_label.setFont(url_font)
self.url_label.setWordWrap(True)
self.url_label.setAlignment(QtCore.Qt.AlignCenter)
- self.copy_url_button = QtGui.QPushButton(strings._('gui_copy_url'))
+ self.copy_url_button = QtGui.QPushButton(strings._('gui_copy_url', True))
self.copy_url_button.clicked.connect(self.copy_url)
url_layout = QtGui.QHBoxLayout()
url_layout.addWidget(self.url_label)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/onionshare.git
More information about the Pkg-anonymity-tools
mailing list