-
Notifications
You must be signed in to change notification settings - Fork 445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/i18n #5479
Feature/i18n #5479
Conversation
Can one of the admins verify this patch? |
ok to test |
@mrcruz , welcome and thanks for contributing! 👍 |
Cool!
EDIT: Doesn't work. |
This is the cleanest I could come up with (that actually works 😃): diff --git a/src/run_tribler.py b/src/run_tribler.py
index e1ff95336..596ecab54 100644
--- a/src/run_tribler.py
+++ b/src/run_tribler.py
@@ -139,14 +139,12 @@ if __name__ == "__main__":
check_free_space()
from tribler_gui.tribler_app import TriblerApplication
+ from tribler_gui.tribler_window import TriblerWindow
app_name = os.environ.get('TRIBLER_APP_NAME', 'triblerapp')
app = TriblerApplication(app_name, sys.argv)
-
- from tribler_gui.i18n import get_default_system_translator
- translator = get_default_system_translator()
- app.installTranslator(translator)
-
+ app.installTranslator(app.translator)
+
if app.is_running():
for arg in sys.argv[1:]:
if os.path.exists(arg) and arg.endswith(".torrent"):
@@ -155,7 +153,6 @@ if __name__ == "__main__":
app.send_message(arg)
sys.exit(1)
- from tribler_gui.tribler_window import TriblerWindow
window = TriblerWindow()
window.setWindowTitle("Tribler")
app.set_activation_window(window)
diff --git a/src/tribler-gui/tribler_gui/tribler_app.py b/src/tribler-gui/tribler_gui/tribler_app.py
index 9cc12d201..b2d213b93 100644
--- a/src/tribler-gui/tribler_gui/tribler_app.py
+++ b/src/tribler-gui/tribler_gui/tribler_app.py
@@ -6,6 +6,7 @@ from PyQt5.QtCore import QCoreApplication, QEvent, Qt
from tribler_core.utilities.unicode import ensure_unicode
from tribler_gui.code_executor import CodeExecutor
+from tribler_gui.i18n import get_default_system_translator
from tribler_gui.single_application import QtSingleApplication
# Set the QT application parameters before creating any instances of the application.
@@ -23,6 +24,7 @@ class TriblerApplication(QtSingleApplication):
QtSingleApplication.__init__(self, app_name, args)
self.code_executor = None
self.messageReceived.connect(self.on_app_message)
+ self.translator = get_default_system_translator()
def on_app_message(self, msg):
if msg.startswith('file') or msg.startswith('magnet'): |
I followed the suggestion by @qstokkink and I would say the only thing missing now is some UI to select the language. I'm trusting the locale.getdefaultlocale() will be reliable even though I do not have any experience with it. |
I feel the need to create a simple README to facilitate future translations. Where should I put this? I was thinking in a README file inside de i18n folder. Do we have a standard for documentations? |
@mrcruz if you're struggling with rounding off this PR and you have |
It is enabled. Feel free to change in any way you want! |
@mrcruz alright 👍 let me polish this up for merge. |
Alright, cleaned up. All tests (should) pass now. @mrcruz your e-mail and username were the wrong way around (your username was in the e-mail field and vise versa). I corrected it for this commit, but you'll probably want to fix that locally. |
Using QT QTranslate pipeline. with auto extracting of keys and building of qm files. probably still missing many keys spread though the code. Adds initial pt_BR translation Adds README file to document how to work with translations
Thanks! |
Agreed, very cool. |
@@ -0,0 +1,19 @@ | |||
# Internationalization | |||
|
|||
This app uses QT multi language feature to provider internationalization. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
provider: A typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 indeed. This should also state "the QT multi language feature".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll make a quick PR for that, before we forget.
@mrcruz , I've recently cleaned up and wrapped all the remaining GUI strings in |
I guess you linked the wrong url in your comment. I will work on an update later on this week and create a PR. I'm glad we have more languages already! |
This a a very simple implementation of the way Qt does its translations. It has a script to both extract tagged keys automatically and a script to create a binary file with the translations.
The main problem that I really would like to improve is in file src/run_tribler.py: I had to shuffle around the imports in the middle of the file because their order does change the semantics of the program. If I import TriblerWindow before installing a translator, the window in created with the default language. That happens because a lot of things are done in constructors. Is there a way to solve this that does not required a huge change?