renelikestacos
renelikestacos

Reputation: 288

How to make a PYQT Graphical User Interface in two different languages?

I am having a GUI created with pyqt and now i would like to provide the user the possibility of two different languages, english and spanish.

I guess to change the ui into a different language will be easy, but there are a lot of "QMessagebox" which are written manually in english.

Anyone has an idea how to do that?

Upvotes: 2

Views: 518

Answers (1)

Dedi
Dedi

Reputation: 35

Well, I think the easiest way for a small program is storing everything in a text file looking like that :

firstmessage=message
secondemessage=message

Then creating a reader fonction like :

def read (text):
 f=open(text,'r')
 h=f.readlines()
 H={}
 for i in range (0,len(f)) :
  h[i]=h[i].split('=')
  h[i]=h[i][1]
  h[i]=h[i].split('\n')
  h[i]=h[i][0]
return H

This will return a dictionary looking like associating "firstmessage" with "message" and the rest... Then you create a parameter window where you can choose your language and the program will reload the dictionary containing the words.

Upvotes: 1

Related Questions