fr:develop:collaboration:dev:translation

Traduction du logiciel

self.tr(‘string to translate’)

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’)
  • 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
  • fr/develop/collaboration/dev/translation.txt
  • 2021/09/28 16:17
  • qroyer