Skip to content

Commit

Permalink
improvement for detection language in console_help
Browse files Browse the repository at this point in the history
  • Loading branch information
slarosa committed Oct 10, 2012
1 parent 552703a commit 3c50290
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
14 changes: 10 additions & 4 deletions python/console_help.py
Expand Up @@ -55,11 +55,17 @@ def setupUi(self):
QObject.connect(self.closeButton, QtCore.SIGNAL("clicked()"), self.closeWindow)
self.verticalLayout.addLayout(self.horizontalLayout)
self.setLayout(self.verticalLayout)
jQueryPath = QgsApplication.pkgDataPath()
qgisDataDir = QgsApplication.pkgDataPath()
listFile = os.listdir(qgisDataDir + "/python/console_help/i18n")
localeFullName = QSettings().value( "locale/userLocale", QVariant( "" ) ).toString()
filename = QgsApplication.pkgDataPath() + "/python/console_help/help.htm? \
lang=" + localeFullName \
+ "&pkgDir=" + jQueryPath
for i in listFile:
lang = i[0:5]
if localeFullName in (lang[0:2], lang):
locale = lang

filename = qgisDataDir + "/python/console_help/help.htm? \
lang=" + locale \
+ "&pkgDir=" + qgisDataDir

url = QtCore.QUrl(filename)
self.webView.load(url)
Expand Down
2 changes: 1 addition & 1 deletion python/console_help/help.htm
Expand Up @@ -147,7 +147,7 @@ <h4 id="thanks">Acknowledgments</h4>
var locale = langPathParameters[0].split("=");
var jQueryPath = langPathParameters[1].split("=");
var pathJs = jQueryPath[1];
var lang = locale[1].split("_")[0];
var lang = locale[1];
var jquery = document.createElement("script");
jquery.type = "text/javascript";
jquery.src = pathJs + "/resources/jQuery/jquery-1.8.2.min.js";
Expand Down
11 changes: 8 additions & 3 deletions python/console_help/i18n/README
@@ -1,6 +1,11 @@
You can contribute at translate this help by creating an file *.properties named like
*.ts files (only the locale suffix) which found in Quantum-GIS\i18n directory.
For example: for Italian translation copy and paste a *.properties file and rename it to "it.properties".
You can contribute at translate this help by creating an file *.properties and name it in
<your_locale_name>.properties
To get your locale name type the following lines in console:

>>> from PyQt4.QtCore import *
>>> QLocale.system().name()

For example: for Italian translation copy and paste a *.properties file and rename it to "it_IT.properties".
The only thing what you have to do is translate the values of the keys in dictionary.

i18n_dict = {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 3c50290

Please sign in to comment.