mirror of
https://github.com/onionshare/onionshare.git
synced 2025-04-05 04:15:42 -04:00
encode one way for CLI, encode another for GUI (#141)
This commit is contained in:
parent
fec0c9ad65
commit
89581b0a03
@ -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
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user