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’)
python -m PyQt5.pylupdate_main habby_trans.pro
C:\habby_dev\dependence\linguist_5.13.2\lrelease.exe translation/Zen_FR.ts