Show pageOld revisionsBacklinksExport to PDFODT exportBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== Traduction du logiciel ====== ===== Prés-requis ===== * Linguist.exe : (https://github.com/thurask/Qt-Linguist/releases) * environnement Python HABBY avec PyQt5 ===== Utilisation dans le code ===== ==== Traduire des champs dans des classes Qt ==== self.tr(‘string to translate’) ==== Traduire des champs en dehors des classes Qt ==== Si pas de classe ou heritage de classe qui pose problème : from PyQt5.QtCore import QCoreApplication text = QCoreApplication.translate(‘Input’, ‘string to translate’) # ‘Input’ sera le nom de la ‘fausse’ classe dans QLinguist et ‘Neglect’ le string à traduire. Ou app = QApplication(sys.argv) languageTranslator = QTranslator(app) if language == 0: input_file_translation = 'Zen_EN' languageTranslator.load(input_file_translation, os.path.join(os.getcwd(), 'translation')) if language == 1: input_file_translation = 'Zen_FR' languageTranslator.load(input_file_translation, os.path.join(os.getcwd(), 'translation')) elif language == 2: input_file_translation = 'Zen_ES' languageTranslator.load(input_file_translation, os.path.join(os.getcwd(), 'translation')) app.installTranslator(languageTranslator) app.translate(‘Input’, ‘string to translate’) ===== Mise à jour des fichiers .ts à traduire dans HABBY ===== * Vérifier que le fichier ‘habby_trans.pro’ contient bien les fichier.py contenant les champs à traduire * Pour mettre à jour les fichiers, lancer dans l’environnement virtuel et dans le repertoire ‘habby’, lancer la commande : python -m PyQt5.pylupdate_main habby_trans.pro * Ouvrir le fichier de langue souhaité (ex :‘Zen_FR.ts’) dans le répertoire ‘translation’ avec Linguist.exe * Dans le logiciel Linguist, renseigner les champs ‘French translation’ souhaités ; * Sauvegarder le fichier ; * Lancer l’invite de commande dans ‘habby’ * Mettre à jour le fichier de langage choisi en lançant la commande (ici pour le fichier français) : C:\habby_dev\dependence\linguist_5.13.2\lrelease.exe translation/Zen_FR.ts * Relancer HABBY {{indexmenu_n>4}} fr/develop/collaboration/dev/translation.txt Last modified: 2021/09/28 16:17by qroyer