Add dynamic change language.

This commit is contained in:
Jarosław Wieczorek 2021-01-04 23:48:52 +01:00
parent 649eb0eee0
commit 3ec5ec3e14
10 changed files with 27944 additions and 27917 deletions

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="pl_PL" sourcelanguage="en_GB">
<TS version="2.1" language="en_GB" sourcelanguage="pl_PL">
<context>
<name>MainWindow</name>
<message>
@ -9,108 +10,108 @@
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="295"/>
<source>Audio file 1 speaker</source>
<translation>Plik audio 1 rozmówcy</translation>
<source>Plik audio 1 rozmówcy</source>
<translation>Audio file 1 speaker</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="296"/>
<source>Name of 1 speaker</source>
<translation>Imię 1 rozmówcy</translation>
<source>Imię 1 rozmówcy</source>
<translation>Name of 1 speaker</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="297"/>
<source>Add audio 1</source>
<translation>Dodaj audio 1</translation>
<source>Dodaj audio 1</source>
<translation>Add audio 1</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="298"/>
<source>Audio file 2 speaker</source>
<translation>Plik audio 2 rozmówcy</translation>
<source>Plik audio 2 rozmówcy</source>
<translation>Audio file 2 speaker</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="299"/>
<source>Name of 2 speaker</source>
<translation>Imię 2 rozmówcy</translation>
<source>Imię 2 rozmówcy</source>
<translation>Name of 2 speaker</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="300"/>
<source>Add audio 2</source>
<translation>Dodaj audio 2</translation>
<source>Dodaj audio 2</source>
<translation>Add audio 2</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="301"/>
<source>Mark if the speaker channels are connected in one recording</source>
<translation>Zaznacz jeśli kanały rozmówców &#xa0;połączone w jednym nagraniu</translation>
<source>Zaznacz jeśli kanały rozmówców &#xa0;połączone w jednym nagraniu</source>
<translation>Mark if the speaker channels are connected in one recording</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="302"/>
<source>Preview - active speakers</source>
<translation>Podgląd - rozmówcy aktywni</translation>
<source>Podgląd - rozmówcy aktywni</source>
<translation>Preview - active speakers</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="303"/>
<source>Speakers - active</source>
<translation>Rozmówcy - aktywni</translation>
<source>Rozmówcy - aktywni</source>
<translation>Speakers - active</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="304"/>
<source>Preview - speakers inactive</source>
<translation>Podgląd - rozmówcy nieaktywni</translation>
<source>Podgląd - rozmówcy nieaktywni</source>
<translation>Preview - speakers inactive</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="305"/>
<source>Speakers - inactive</source>
<translation>Rozmówcy - nieaktywni</translation>
<source>Rozmówcy - nieaktywni</source>
<translation>Speakers - inactive</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="306"/>
<source>Preview - 1 speaker active</source>
<translation>Podgląd - 1 rozmówca aktywny</translation>
<source>Podgląd - 1 rozmówca aktywny</source>
<translation>Preview - 1 speaker active</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="307"/>
<source>First speaker - active</source>
<translation>Pierwszy rozmówca - aktywny</translation>
<source>Pierwszy rozmówca - aktywny</source>
<translation>First speaker - active</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="308"/>
<source>Preview - 2 speaker active</source>
<translation>Podgląd - 2 rozmówca aktywny</translation>
<source>Podgląd - 2 rozmówca aktywny</source>
<translation>Preview - 2 speaker active</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="309"/>
<source>Second speaker - active</source>
<translation>Drugi rozmówca - aktywny</translation>
<source>Drugi rozmówca - aktywny</source>
<translation>Second speaker - active</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="310"/>
<source>Voice detection level:</source>
<translation>Poziom wykrywania głosu:</translation>
<source>Poziom wykrywania głosu:</source>
<translation>Voice detection level:</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="311"/>
<source>Preview</source>
<translation>Podgląd</translation>
<source>Podgląd</source>
<translation>Preview</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="312"/>
<source>Generate a podcast</source>
<translation>Wygeneruj podcast</translation>
<source>Wygeneruj podcast</source>
<translation>Generate a podcast</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="313"/>
<source>Project</source>
<translation>Projekt</translation>
<source>Projekt</source>
<translation>Project</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="314"/>
<source>New project</source>
<translation>Nowy projekt</translation>
<source>Nowy projekt</source>
<translation>New project</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="315"/>
<source>Click to create a new project</source>
<translation>Kliknij, aby utwórzyć nowy projekt</translation>
<source>Kliknij, aby utwórzyć nowy projekt</source>
<translation>Click to create a new project</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="316"/>
@ -119,13 +120,13 @@
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="317"/>
<source>Open a project</source>
<translation>Otwórz projekt</translation>
<source>Otwórz projekt</source>
<translation>Open a project</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="318"/>
<source>Click to open an existing project</source>
<translation>Kliknij, aby otworzyć istniejący projekt</translation>
<source>Kliknij, aby otworzyć istniejący projekt</source>
<translation>Click to open an existing project</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="319"/>
@ -134,13 +135,13 @@
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="320"/>
<source>Save the project</source>
<translation>Zapisz projekt</translation>
<source>Zapisz projekt</source>
<translation>Save the project</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="321"/>
<source>Click to save the current project</source>
<translation>Kliknij, aby zapisać aktualny projekt</translation>
<source>Kliknij, aby zapisać aktualny projekt</source>
<translation>Click to save the current project</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="322"/>
@ -149,13 +150,13 @@
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="323"/>
<source>Save the project as</source>
<translation>Zapisz projekt jako</translation>
<source>Zapisz projekt jako</source>
<translation>Save the project as</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="324"/>
<source>Click to save the project as</source>
<translation>Kliknij, aby zapisać projekt jako</translation>
<source>Kliknij, aby zapisać projekt jako</source>
<translation>Click to save the project as</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="325"/>
@ -164,13 +165,13 @@
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="326"/>
<source>Close the program</source>
<translation>Zamknij program</translation>
<source>Zamknij program</source>
<translation>Close the program</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="327"/>
<source>Click to end the program</source>
<translation>Kliknij, aby zakończyć działanie programu</translation>
<source>Kliknij, aby zakończyć działanie programu</source>
<translation>Click to end the program</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="328"/>
@ -179,13 +180,13 @@
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="329"/>
<source>Settings</source>
<translation>Ustawienia</translation>
<source>Ustawienia</source>
<translation>Settings</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="330"/>
<source>Click to go to program settings</source>
<translation>Kliknij, aby przejść do ustawień programu</translation>
<source>Kliknij, aby przejść do ustawień programu</source>
<translation>Click to go to program settings</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="331"/>
@ -194,13 +195,13 @@
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="332"/>
<source>About the MagicPodcast program</source>
<translation>O programie MagicPodcast</translation>
<source>O programie MagicPodcast</source>
<translation>About the MagicPodcast program</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="333"/>
<source>Click to view MagicPodcast information</source>
<translation>Kliknij, aby wyświetlić informacje dotyczące programu MagicPodcast</translation>
<source>Kliknij, aby wyświetlić informacje dotyczące programu MagicPodcast</source>
<translation>Click to view MagicPodcast information</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="334"/>

Binary file not shown.

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="en_GB" sourcelanguage="pl_PL">
<TS version="2.1" language="pl_PL" sourcelanguage="en_GB">
<context>
<name>MainWindow</name>
<message>
@ -10,108 +9,108 @@
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="295"/>
<source>Plik audio 1 rozmówcy</source>
<translation>Audio file 1 speaker</translation>
<source>Audio file 1 speaker</source>
<translation>Plik audio 1 rozmówcy</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="296"/>
<source>Imię 1 rozmówcy</source>
<translation>Name of 1 speaker</translation>
<source>Name of 1 speaker</source>
<translation>Imię 1 rozmówcy</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="297"/>
<source>Dodaj audio 1</source>
<translation>Add audio 1</translation>
<source>Add audio 1</source>
<translation>Dodaj audio 1</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="298"/>
<source>Plik audio 2 rozmówcy</source>
<translation>Audio file 2 speaker</translation>
<source>Audio file 2 speaker</source>
<translation>Plik audio 2 rozmówcy</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="299"/>
<source>Imię 2 rozmówcy</source>
<translation>Name of 2 speaker</translation>
<source>Name of 2 speaker</source>
<translation>Imię 2 rozmówcy</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="300"/>
<source>Dodaj audio 2</source>
<translation>Add audio 2</translation>
<source>Add audio 2</source>
<translation>Dodaj audio 2</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="301"/>
<source>Zaznacz jeśli kanały rozmówców &#xa0;połączone w jednym nagraniu</source>
<translation>Mark if the speaker channels are connected in one recording</translation>
<source>Mark if the speaker channels are connected in one recording</source>
<translation>Zaznacz jeśli kanały rozmówców &#xa0;połączone w jednym nagraniu</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="302"/>
<source>Podgląd - rozmówcy aktywni</source>
<translation>Preview - active speakers</translation>
<source>Preview - active speakers</source>
<translation>Podgląd - rozmówcy aktywni</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="303"/>
<source>Rozmówcy - aktywni</source>
<translation>Speakers - active</translation>
<source>Speakers - active</source>
<translation>Rozmówcy - aktywni</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="304"/>
<source>Podgląd - rozmówcy nieaktywni</source>
<translation>Preview - speakers inactive</translation>
<source>Preview - speakers inactive</source>
<translation>Podgląd - rozmówcy nieaktywni</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="305"/>
<source>Rozmówcy - nieaktywni</source>
<translation>Speakers - inactive</translation>
<source>Speakers - inactive</source>
<translation>Rozmówcy - nieaktywni</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="306"/>
<source>Podgląd - 1 rozmówca aktywny</source>
<translation>Preview - 1 speaker active</translation>
<source>Preview - 1 speaker active</source>
<translation>Podgląd - 1 rozmówca aktywny</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="307"/>
<source>Pierwszy rozmówca - aktywny</source>
<translation>First speaker - active</translation>
<source>First speaker - active</source>
<translation>Pierwszy rozmówca - aktywny</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="308"/>
<source>Podgląd - 2 rozmówca aktywny</source>
<translation>Preview - 2 speaker active</translation>
<source>Preview - 2 speaker active</source>
<translation>Podgląd - 2 rozmówca aktywny</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="309"/>
<source>Drugi rozmówca - aktywny</source>
<translation>Second speaker - active</translation>
<source>Second speaker - active</source>
<translation>Drugi rozmówca - aktywny</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="310"/>
<source>Poziom wykrywania głosu:</source>
<translation>Voice detection level:</translation>
<source>Voice detection level:</source>
<translation>Poziom wykrywania głosu:</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="311"/>
<source>Podgląd</source>
<translation>Preview</translation>
<source>Preview</source>
<translation>Podgląd</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="312"/>
<source>Wygeneruj podcast</source>
<translation>Generate a podcast</translation>
<source>Generate a podcast</source>
<translation>Wygeneruj podcast</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="313"/>
<source>Projekt</source>
<translation>Project</translation>
<source>Project</source>
<translation>Projekt</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="314"/>
<source>Nowy projekt</source>
<translation>New project</translation>
<source>New project</source>
<translation>Nowy projekt</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="315"/>
<source>Kliknij, aby utwórzyć nowy projekt</source>
<translation>Click to create a new project</translation>
<source>Click to create a new project</source>
<translation>Kliknij, aby utwórzyć nowy projekt</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="316"/>
@ -120,13 +119,13 @@
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="317"/>
<source>Otwórz projekt</source>
<translation>Open a project</translation>
<source>Open a project</source>
<translation>Otwórz projekt</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="318"/>
<source>Kliknij, aby otworzyć istniejący projekt</source>
<translation>Click to open an existing project</translation>
<source>Click to open an existing project</source>
<translation>Kliknij, aby otworzyć istniejący projekt</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="319"/>
@ -135,13 +134,13 @@
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="320"/>
<source>Zapisz projekt</source>
<translation>Save the project</translation>
<source>Save the project</source>
<translation>Zapisz projekt</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="321"/>
<source>Kliknij, aby zapisać aktualny projekt</source>
<translation>Click to save the current project</translation>
<source>Click to save the current project</source>
<translation>Kliknij, aby zapisać aktualny projekt</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="322"/>
@ -150,13 +149,13 @@
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="323"/>
<source>Zapisz projekt jako</source>
<translation>Save the project as</translation>
<source>Save the project as</source>
<translation>Zapisz projekt jako</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="324"/>
<source>Kliknij, aby zapisać projekt jako</source>
<translation>Click to save the project as</translation>
<source>Click to save the project as</source>
<translation>Kliknij, aby zapisać projekt jako</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="325"/>
@ -165,13 +164,13 @@
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="326"/>
<source>Zamknij program</source>
<translation>Close the program</translation>
<source>Close the program</source>
<translation>Zamknij program</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="327"/>
<source>Kliknij, aby zakończyć działanie programu</source>
<translation>Click to end the program</translation>
<source>Click to end the program</source>
<translation>Kliknij, aby zakończyć działanie programu</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="328"/>
@ -180,13 +179,13 @@
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="329"/>
<source>Ustawienia</source>
<translation>Settings</translation>
<source>Settings</source>
<translation>Ustawienia</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="330"/>
<source>Kliknij, aby przejść do ustawień programu</source>
<translation>Click to go to program settings</translation>
<source>Click to go to program settings</source>
<translation>Kliknij, aby przejść do ustawień programu</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="331"/>
@ -195,13 +194,13 @@
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="332"/>
<source>O programie MagicPodcast</source>
<translation>About the MagicPodcast program</translation>
<source>About the MagicPodcast program</source>
<translation>O programie MagicPodcast</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="333"/>
<source>Kliknij, aby wyświetlić informacje dotyczące programu MagicPodcast</source>
<translation>Click to view MagicPodcast information</translation>
<source>Click to view MagicPodcast information</source>
<translation>Kliknij, aby wyświetlić informacje dotyczące programu MagicPodcast</translation>
</message>
<message>
<location filename="../../python/ui/mainwindow_ui.py" line="334"/>

View File

@ -36,12 +36,12 @@
<widget class="QComboBox" name="combo_box_language">
<item>
<property name="text">
<string>Angielski/English</string>
<string>en</string>
</property>
</item>
<item>
<property name="text">
<string>Polski/Polish</string>
<string>pl</string>
</property>
</item>
</widget>

View File

@ -2,48 +2,54 @@ import os
import shutil
import subprocess
import tempfile
from PyQt5.QtCore import Qt, QLocale, QLibraryInfo, QTranslator
import resources_rc
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QMainWindow, QLabel, QFileDialog, QDialog, QDialogButtonBox, QVBoxLayout, QApplication
from src.python.classes.settings_dialog import SettingsDialog
from src.python.ui.mainwindow_ui import Ui_MainWindow
from src.python.classes.translate import Translator
class MainWindow(QMainWindow, Ui_MainWindow):
class MainWindow(QMainWindow, QApplication, Ui_MainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent=parent)
self.translator = QTranslator()
self.translator.load("qt_" + QLocale.system().name(), QLibraryInfo.location(QLibraryInfo.TranslationsPath))
print("qt_" + QLocale.system().name(), QLibraryInfo.location(QLibraryInfo.TranslationsPath))
app = QApplication.instance()
app.installTranslator(self.translator)
self.translator = Translator()
self.installTranslator(self.translator)
self.lang = 'pl'
self.translator.load_lang(self.lang)
self.setupUi(self)
self.setup_logic()
self.setup_detail()
self.retranslateUi(self.window())
self.aresample = 8000
self.test_data()
def setup_logic(self):
self.action_settings.triggered.connect(self.open_setting_dialog)
self.button_generate.clicked.connect(self.generate_video_podcast)
self.button_audio_1.clicked.connect(lambda: self.open_audio_import(audio_number=1))
self.button_audio_2.clicked.connect(lambda: self.open_audio_import(audio_number=2))
self.check_box_connected_channels.stateChanged.connect(self.channels_connected)
self.button_select_avatar_1.clicked.connect(lambda: self.open_image_import(image_number=1))
self.button_select_avatar_2.clicked.connect(lambda: self.open_image_import(image_number=2))
self.button_select_avatar_3.clicked.connect(lambda: self.open_image_import(image_number=3))
self.button_select_avatar_4.clicked.connect(lambda: self.open_image_import(image_number=4))
self.button_generate.clicked.connect(self.generate_video_podcast)
self.check_box_connected_channels.setChecked(True)
self.action_settings.triggered.connect(self.open_setting_dialog)
self.check_box_connected_channels.stateChanged.connect(self.channels_connected)
def change_language(self):
self.translator.load_lang(self.lang)
self.retranslateUi(self.window())
# After change language need setup preview for test data once again
self.test_data()
def setup_detail(self):
self.line_edit_name_1.setDisabled(True)
self.line_edit_name_2.setDisabled(True)
def create_custom_dialog(self, title: str, msg: str):
@staticmethod
def create_custom_dialog(title: str, msg: str):
dialog = QDialog()
label = QLabel()
label.setText(msg)
@ -80,10 +86,12 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.preview_label_avatar_4.setProperty('path', './src/gui/images/right.png')
def open_setting_dialog(self):
settings = SettingsDialog()
settings.exec()
language = settings.language
print(language)
old_lang = self.lang
settings = SettingsDialog(parent=self)
settings.exec_()
if old_lang != self.lang:
print(old_lang, self.lang)
self.change_language()
def open_image_import(self, image_number: int):
dialog = QFileDialog()
@ -201,4 +209,3 @@ class MainWindow(QMainWindow, Ui_MainWindow):
print(echo_temp_dir_name)
print(ech)
pass

View File

@ -6,8 +6,13 @@ class SettingsDialog(QDialog, Ui_SettingsDialog):
def __init__(self, parent=None):
super(SettingsDialog, self).__init__(parent=parent)
self.setupUi(self)
self.language = self.combo_box_language.currentText()
self.combo_box_language.currentTextChanged.connect(self.change_language)
self.language = self.combo_box_language.currentText() if parent is None else self.parent().lang
self.setup_logic()
def change_language(self):
print(F"[*] Zmiana języka na: {self.combo_box_language.currentText()}")
def setup_logic(self):
self.combo_box_language.setCurrentText(self.language)
self.button_box.accepted.connect(self.set_lang)
def set_lang(self):
"""Set new lang in mainwindow"""
self.parent().lang = self.combo_box_language.currentText()

View File

@ -0,0 +1,15 @@
from PyQt5.QtCore import QTranslator
# import locale
# import resources_rc
# import sys
class Translator(QTranslator):
def __init__(self):
QTranslator.__init__(self)
def load_lang(self, lang):
print(f"Get this lang: {lang}")
print(":/language/src/gui/dicts/magicpodcast" + "." + lang)
self.load(":/language/src/gui/dicts/magicpodcast" + "." + lang)

View File

@ -45,8 +45,8 @@ class Ui_SettingsDialog(object):
_translate = QtCore.QCoreApplication.translate
SettingsDialog.setWindowTitle(_translate("SettingsDialog", "Ustawienia"))
self.label_language.setText(_translate("SettingsDialog", "Język programu:"))
self.combo_box_language.setItemText(0, _translate("SettingsDialog", "Angielski/English"))
self.combo_box_language.setItemText(1, _translate("SettingsDialog", "Polski/Polish"))
self.combo_box_language.setItemText(0, _translate("SettingsDialog", "en"))
self.combo_box_language.setItemText(1, _translate("SettingsDialog", "pl"))
if __name__ == "__main__":