import i18n
def i18n_loading(translationPath : str, locale : str) -> None:
"""
Cette fonction charge les fichiers de traduction
:param translationPath: Le dossier des fichiers de traduction
:type translationPath: str
:param locale: La locale a utiliser
:type locale: str
"""
i18n.load_path.append(translationPath)
i18n.set('locale', locale)
i18n.set('fallback', 'en')
File fenetre_principale.py
class FenetrePrincipale(QMainWindow):
def MINIMUM_SIZE() -> QSize:
"""
Fonction permettant de simuler une variable statique pour la taille minimale
:return: La valeur statique
:rtype: int
"""
return QSize(800, 800)
def __init__(self, parent : QWidget = None, app_name : str = "Comptes",
x : int = 50, y : int = 50, width: int = 1000, height: int = 1000) -> None:
"""
Constructor
:param parent: Optional; Default : None; Le parent de cette fenetre
:type parent: QWidget
:param app_name: Optional; Default : "Comptes"; Le nom de l'application
:type app_name: str
:param x: Optional; Default : 50; Position en X du coin en haut a gauche de la fenetre sur l'ecran (en px)
:type x: int
:param y: Optional; Default : 50; Position en Y du coin en haut a gauche de la fenetre sur l'ecran (en px)
:type y: int
:param width: Optional; Default : 1000; Largeur de la fenetre (en px)
:type width: int
:param height: Optional; Default : 1000; Hauteur de la fenetre (en px)
:type height: int
"""
super().__init__(parent)
self.real_x = x
self.real_y = y
self.real_width = width
self.real_height = height
self.setMinimumSize(FenetrePrincipale.MINIMUM_SIZE())
self.setWindowTitle(app_name)
self.setGeometry(x, y, width, height)
self.show()
def resizeEvent(self, a0: QResizeEvent) -> None:
"""
Surcharge de la fonction resizeEvent du parent pour pouvoir redimensionner nos elements et ajouter des controles sur la taille min et max
:param a0: L'evenement de redimensionnement
:type a0: QResizeEvent
:override:
"""
super().resizeEvent(a0)
self.real_width = a0.size().width()
self.real_height = a0.size().height()
File main.py :
from translation import i18n_loading
from fenetre_principale import FenetrePrincipale
# Si on est dans la boucle principale
if __name__=="__main__":
# Chargement des traductions
i18n_loading("./resources/translation", 'en')
# Demarrage de l'application
app=QApplication(sys.argv)
# Creation de la fenetre principale
ex=FenetrePrincipale(app_name=i18n.t("translate.app_name"))
# Execution de l'application
sys.exit(app.exec())
There is a lot more files, especially for the tabs and their logic but I think this is enough to see the problem.
For information I am able to do it every time on one of my computers but I am unable to reproduce it on my other computer, yet the code is exactly the same (git versioned).
Versions on the working computer :
Version of python : 3.9.10
Version of python-i18n : 0.3.9
Versions on the not working computer :
Version of python : 3.9.10
Version of python-i18n : 0.3.9
Hello,
I am unable to load the translation from a file
The code loading the file :
File translation.py :
File fenetre_principale.py
File main.py :
File ./resources/translation/translate.en.yml :
There is a lot more files, especially for the tabs and their logic but I think this is enough to see the problem.
For information I am able to do it every time on one of my computers but I am unable to reproduce it on my other computer, yet the code is exactly the same (git versioned).
Versions on the working computer :
Version of python : 3.9.10 Version of python-i18n : 0.3.9
Versions on the not working computer :
Version of python : 3.9.10 Version of python-i18n : 0.3.9