<html style="direction: ltr;">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
</head>
<body style="direction: ltr;"
bidimailui-detected-decoding-type="UTF-8" bgcolor="#FFFFFF"
text="#000000">
<p>Hi All,</p>
<p><br>
</p>
<p>I tried to use multi-language for my application but after
loading any language the default language (English) didn't appear!?</p>
<p><br>
</p>
<p>Do I need to create en.qm/ts just like any other language or I
can load the default language by some command?<br>
</p>
<p><br>
</p>
<p>here is a snippet of my code:</p>
<pre><pre> def getLang(self):
<font class="pastecode" color="#FF0000">if</font> self.lang == 3:
<font class="pastecode" color="#FF0000">return</font> QString(<font class="pastecode" color="#008B00">"en"</font>)
elif self.lang == 31:
<font class="pastecode" color="#FF0000">return</font> QString(<font class="pastecode" color="#008B00">"ar"</font>)
elif self.lang == 32:
<font class="pastecode" color="#FF0000">return</font> QString(<font class="pastecode" color="#008B00">"tr"</font>)
<font class="pastecode" color="#FF0000">else</font>:
<font class="pastecode" color="#FF0000">return</font> QString(<font class="pastecode" color="#008B00">"en"</font>)
def languageChange(self):
translator = QTranslator(self)
currentLang = QString(<font class="pastecode" color="#008B00">":/l10n/%1.qm"</font>).arg(self.getLang())
<font class="pastecode" color="#FF0000">if</font> not translator.load(currentLang):
print QString(<font class="pastecode" color="#008B00">"Couldn't load language file"</font>)
widget = QWidget(self)
<font class="pastecode" color="#FF0000">if</font> self.lang == 31:
qApp.setLayoutDirection(Qt.RightToLeft)
QLocale.setDefault(QLocale(QLocale.Arabic, QLocale.SyrianArabRepublic))
<font class="pastecode" color="#FF0000">for</font> widget in QApplication.allWidgets():
widget.setLayoutDirection(Qt.RightToLeft)
<font class="pastecode" color="#FF0000">else</font>:
qApp.setLayoutDirection(Qt.LeftToRight)
<font class="pastecode" color="#FF0000">for</font> widget in qApp.allWidgets():
widget.setLayoutDirection(Qt.LeftToRight)
qApp.installTranslator(translator)
self.retranslateUi(self)
def on_toolButton_english_clicked(self):
self.lang = 3
self.languageChange()
self.toolButton_english.setChecked(1)
def on_toolButton_arabic_clicked(self):
self.lang = 31
self.languageChange()
self.toolButton_arabic.setChecked(1)
def on_toolButton_turkish_clicked(self):
self.lang = 32
self.languageChange()
self.toolButton_turkish.setChecked(1)</pre></pre>
<p><br>
</p>
<pre class="moz-signature" cols="72">--
Best Regards
Muhammad Bashir Al-Noimi
My Blog: <a class="moz-txt-link-freetext" href="http://mbnoimi.net">http://mbnoimi.net</a></pre>
</body>
</html>