fr:develop:collaboration:dev:translation

This is an old revision of the document!


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’)

Attention : ne pas traduire ‘Warning :’ dans les champs de log car utilisé pour le code couleur.

  • Vérifier que le fichier ‘habby_trans.pro’ contient bien les fichier.py contenant les champs à traduire
  • Lancer dans l’environnement virtuel et dans ‘habby’ et pour mettre à jour les fichiers, 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.1615496216.txt.gz
  • 2021/03/11 21:56
  • qroyer