Skip to content

Commit eeefecf

Browse files
committedOct 3, 2012
Merge pull request #257 from slarosa/master
Added i18n for help (Python Console)
2 parents 5a0feb3 + 35a4f88 commit eeefecf

File tree

13 files changed

+190
-27
lines changed

13 files changed

+190
-27
lines changed
 

‎i18n/qgis_it.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6253,6 +6253,10 @@ Cambiare questa situazione prima, perché il plugin OSM non quale layer è la de
62536253
<source>Python Console</source>
62546254
<translation>Console python</translation>
62556255
</message>
6256+
<message>
6257+
<source>Help Python Console</source>
6258+
<translation>Aiuto Console Python</translation>
6259+
</message>
62566260
<message>
62576261
<source>Import Class</source>
62586262
<translation>Importa Modulo</translation>

‎python/help.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from PyQt4 import QtCore, QtGui, QtWebKit
22
from PyQt4.QtCore import *
33
from PyQt4.QtGui import *
4+
from qgis.core import *
45
import os
56

67
class HelpDialog(QtGui.QDialog):
@@ -13,7 +14,7 @@ def __init__(self):
1314
def setupUi(self):
1415
self.setMaximumSize(500, 300)
1516
self.webView = QtWebKit.QWebView()
16-
self.setWindowTitle("Help Python Console")
17+
self.setWindowTitle(QCoreApplication.translate("PythonConsole","Help Python Console"))
1718
self.verticalLayout= QtGui.QVBoxLayout()
1819
self.verticalLayout.setSpacing(2)
1920
self.verticalLayout.setMargin(0)
@@ -29,7 +30,12 @@ def setupUi(self):
2930
QObject.connect(self.closeButton, QtCore.SIGNAL("clicked()"), self.closeWindow)
3031
self.verticalLayout.addLayout(self.horizontalLayout)
3132
self.setLayout(self.verticalLayout)
32-
filename = os.path.dirname(__file__) + "/helpConsole/help.htm"
33+
jQueryPath = QgsApplication.pkgDataPath()
34+
localeFullName = QSettings().value( "locale/userLocale", QVariant( "" ) ).toString()
35+
filename = os.path.dirname(__file__) + "/helpConsole/help.htm? \
36+
lang=" + localeFullName \
37+
+ "&pkgDir=" + jQueryPath
38+
3339
url = QtCore.QUrl(filename)
3440
self.webView.load(url)
3541

‎python/helpConsole/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
FILE(GLOB HTML_FILES *.htm)
2+
FILE(GLOB I18N_FILES i18n/*.properties)
3+
FILE(GLOB JS_FILES js/*.js)
4+
25
INSTALL(FILES ${HTML_FILES} DESTINATION ${QGIS_PYTHON_DIR}/helpConsole)
6+
INSTALL(FILES ${I18N_FILES} DESTINATION ${QGIS_PYTHON_DIR}/helpConsole/i18n)
7+
INSTALL(FILES ${JS_FILES} DESTINATION ${QGIS_PYTHON_DIR}/helpConsole/js)

‎python/helpConsole/help.htm

Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
<html xmlns="http://www.w3.org/1999/xhtml">
33
<head>
44
<title>Help Python Console</title>
5+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6+
<!--<script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
7+
<script type="text/javascript" src="js/jquery.i18n.min.js"></script>-->
8+
59
<style>
610
body{
711
font-family: verdana,arial,helvetica,sans-serif;
@@ -25,28 +29,28 @@
2529
<img src="../iconConsole/imgHelpDialog.png" />
2630
</td>
2731
<td>
28-
<h2>Python Console for QGIS</h2>
32+
<h2 id="headerTitle">Python Console for QGIS</h2>
2933
</td>
3034
</tr>
3135
</table>
3236
<p align="justify">
33-
Python Console based on pyScintilla. (Developed by Salvatore Larosa)
37+
<span id="headerSubject">Python Console based on PyQScintilla2. (Developed by Salvatore Larosa)</span>
3438
<br><br>
35-
To access Quantum GIS environment from this console
39+
<span id="headerSubjectMain">To access Quantum GIS environment from this console
3640
use qgis.utils.iface object (instance of QgisInterface class).
3741
To import the class QgisInterface can also use the dedicated
38-
button on the toolbar on the left.
42+
button on the toolbar on the left.</span>
3943
</p>
4044
<table id="header">
4145
<tr>
4246
<td>
43-
<h4>Features</h4>
47+
<h4 id="features">Features</h4>
4448
</td>
4549
</tr>
4650
</table>
4751
<p align="justify">
4852
<ul>
49-
<li>Auto-completion and highlighting syntax for the following APIs:
53+
<li><span id="featuresTitle">Auto-completion and highlighting syntax for the following APIs:</span>
5054
<ol>
5155
<li>Python</li>
5256
<li>PyQGIS-master</li>
@@ -56,75 +60,99 @@ <h4>Features</h4>
5660
</ol>
5761
</li>
5862
<br>
59-
<li>CTRL+SPACE to view the auto-completion list.</li>
63+
<li><span id="featuresA">CTRL+SPACE to view the auto-completion list.</span></li>
6064
<br>
61-
<li>CTRL+ALT+SPACE to view the command history list.</li>
65+
<li><span id="featuresB">CTRL+ALT+SPACE to view the command history list.</span></li>
6266
<br>
63-
<li>Saves the command history by typing <b>_save</b> or closing the widget.<br>
64-
This command saves the history command in the file ~/.qgis/console_history.txt
67+
<li><span id="featuresC">Saves the command history by typing <b>_save</b> or closing the widget.<br>
68+
This command saves the history command in the file ~/.qgis/console_history.txt</span>
6569
</li>
6670
<br>
67-
<li>Clears the command history by typing <b>_clear</b>.<br>
68-
This command clears the command history from file ~/.qgis/console_history.txt
71+
<li><span id="featuresD">Clears the command history by typing <b>_clear</b>.<br>
72+
This command clears the command history from file ~/.qgis/console_history.txt</span>
6973
</li>
7074
<br>
71-
<li>Clears completely command history by typing <b>_clearAll</b>.<br>
72-
This command clears completely the command history. It has an irreversible effect.
75+
<li><span id="featuresE">Clears completely command history by typing <b>_clearAll</b>.<br>
76+
This command clears completely the command history. It has an irreversible effect.</span>
7377
</li>
7478
</ul>
7579
</p>
7680
<table id="header">
7781
<tr>
7882
<td>
79-
<h4>Toolbar</h4>
83+
<h4 id="toolbar">Toolbar</h4>
8084
</td>
8185
</tr>
8286
</table>
83-
<p>The following is a description of the tools in the toolbar:</p>
87+
<p><span id="toolbarTitle">The following is a description of the tools in the toolbar:</span></p>
8488
<table width="100%" border="0" id="headerTool">
8589
<tr>
8690
<td><img src="../iconConsole/iconClearConsole.png" /></td>
87-
<td colspan="2">Tool to clear python console</td>
91+
<td colspan="2"><span id="toolbarClear">Tool to clear python console</span></td>
8892
</tr>
8993
<tr>
9094
<td><img src="../iconConsole/iconClassConsole.png" /></td>
9195
<td><img src="../iconConsole/iconIfaceConsole.png" /></td>
92-
<td>Tool to import iface class</td>
96+
<td><span id="toolbarIfaceClass">Tool to import iface class</span></td>
9397
</tr>
9498
<tr>
9599
<td></td>
96100
<td><img src="../iconConsole/iconSextanteConsole.png" /></td>
97-
<td>Tool to import Sextante class</td>
101+
<td><span id="toolbarSextClass">Tool to import Sextante class</span></td>
98102
</tr>
99103
<tr>
100104
<td><img src="../iconConsole/iconScriptConsole.png" /></td>
101105
<td><img src="../iconConsole/iconOpenConsole.png" /></td>
102-
<td>Tool to open a python script and load in console</td>
106+
<td><span id="toolbarScriptOpen">Tool to open a python script and load in console</span></td>
103107
</tr>
104108
<tr>
105109
<td></td>
106110
<td><img src="../iconConsole/iconSaveConsole.png" /></td>
107-
<td>Tool to save a python script</td>
111+
<td><span id="toolbarScriptSave">Tool to save a python script</span></td>
108112
</tr>
109113
<tr>
110114
<td><img src="../iconConsole/iconHelpConsole.png" /></td>
111-
<td colspan="2">Help</td>
115+
<td colspan="2"><span id="toolbarHelp">Help</span></td>
112116
</tr>
113117
<tr>
114118
<td><img src="../iconConsole/iconRunConsole.png" /></td>
115-
<td colspan="2">Run command (like Enter key pressed)</td>
119+
<td colspan="2"><span id="toolbarRun">Run command (like Enter key pressed)</span></td>
116120
</tr>
117121
</table>
118122
<br>
119123
<table id="header">
120124
<tr>
121125
<td>
122-
<h4>Acknowledgments</h4>
126+
<h4 id="thanks">Acknowledgments</h4>
123127
</td>
124128
</tr>
125129
</table>
126130
<p>
127-
Thanks to Larry Shaffer who provided the API files.
131+
<span id="thanksText">Thanks to Larry Shaffer who provided the API files.</span>
128132
</p>
129133
</body>
134+
<script type="text/javascript">
135+
var parameter = window.location.search.replace( "?", "" );
136+
var langPathParameters = parameter.split("&");
137+
var locale = langPathParameters[0].split("=");
138+
var jQueryPath = langPathParameters[1].split("=");
139+
var pathJs = jQueryPath[1];
140+
var lang = locale[1];
141+
var jquery = document.createElement("script");
142+
jquery.type = "text/javascript";
143+
jquery.src = pathJs + "/resources/jQuery/jquery-1.8.2.min.js";
144+
document.body.appendChild(jquery);
145+
var jqueryi18n = document.createElement("script");
146+
jqueryi18n.type = "text/javascript";
147+
jqueryi18n.src = pathJs + "/resources/jQuery/jquery.i18n.min.js";
148+
document.body.appendChild(jqueryi18n);
149+
var properties = document.createElement("script");
150+
properties.type = "text/javascript";
151+
properties.src = "i18n/" + lang + ".properties";
152+
document.body.appendChild(properties);
153+
var encode = document.createElement("script");
154+
encode.type = "text/javascript";
155+
encode.src = "js/encoding.js";
156+
document.body.appendChild(encode);
157+
</script>
130158
</html>

‎python/helpConsole/i18n/README

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
You can contribute at translate this help by creating an file *.properties named like
2+
*.ts files (only the locale suffix) which found in Quantum-GIS\i18n directory.
3+
For example: for Italian translation copy and paste a *.properties file and rename it to "it.properties".
4+
The only thing what you have to do is translate the values of the keys in dictionary.
5+
6+
i18n_dict = {
7+
"key" : "value"
8+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
i18n_dict = {
2+
"header.title" : "Python Console for QGIS",
3+
"header.subject" : "Python Console based on PyQScintilla2. (Developed by Salvatore Larosa)",
4+
"header.subject.main" : "To access Quantum GIS environment from this console \
5+
use qgis.utils.iface object (instance of QgisInterface class). \
6+
To import the class QgisInterface can also use the dedicated \
7+
button on the toolbar on the left.",
8+
"features" : "Features",
9+
"features.title" : "Auto-completion and highlighting syntax for the following APIs:",
10+
"features.a" : "CTRL+SPACE to view the auto-completion list.",
11+
"features.b" : "CTRL+ALT+SPACE to view the command history list.",
12+
"features.c" : "Saves the command history by typing '_save' or closing the widget. \
13+
This command saves the history command in the file ~/.qgis/console_history.txt",
14+
"features.d" : "Clears the command history by typing '_clear'. \
15+
This command clears the command history from file ~/.qgis/console_history.txt",
16+
"features.e" : "Clears completely command history by typing '_clearAll'. \
17+
This command clears completely the command history. It has an irreversible effect.",
18+
"toolbar" : "Toolbar",
19+
"toolbar.title" : "The following is a description of the tools in the toolbar:",
20+
"toolbar.clear" : "Tool to clear python console",
21+
"toolbar.iface" : "Tool to import iface class",
22+
"toolbar.sextante" : "Tool to import Sextante class",
23+
"toolbar.script.open" : "Tool to open a python script and load in console",
24+
"toolbar.script.save" : "Tool to save a python script",
25+
"toolbar.help" : "Help",
26+
"toolbar.run" : "Run command (like Enter key pressed)",
27+
"thanks" : "Acknowledgments",
28+
"thanks.text" : "Thanks to Larry Shaffer who provided the API files."
29+
};

‎python/helpConsole/i18n/it.properties

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
i18n_dict = {
2+
"header.title" : "Console Python per QGIS",
3+
"header.subject" : "Console Python basata su PyQScintilla2. (Sviluppata da Salvatore Larosa)",
4+
"header.subject.main" : "Per accedere all'ambiente Quantum GIS da questa console \
5+
usa l'oggetto qgis.utils.iface (istanza della classe QgisInterface). \
6+
Per importare la classe QgisInterface puoi usare anche il bottone dedicato che si trova \
7+
sulla toolbar.",
8+
"features" : "Funzionalità",
9+
"features.title" : "Completamento automatico ed evidenziazione della sintassi per le seguenti APIs:",
10+
"features.a" : "CTRL+SPACE per visualizzare la lista per l'autocompletamento di classi e metodi.",
11+
"features.b" : "CTRL+ALT+SPACE per visualizzare la lista della cronologia dei comandi.",
12+
"features.c" : "Possibilità di salvare la cronologia dei comandi digitando '_save' o semplicemente chiudendo il widget. \
13+
La cronologia verrà salvata all'interno del file ~/.qgis/console_history.txt",
14+
"features.d" : "Possibilità di cancellare la storia dei comandi digitando '_clear'. \
15+
La cronologia verrà cancellata dal file ~/.qgis/console_history.txt",
16+
"features.e" : "Possibilità di cancellare completamente la cronologia dei comandi digitando '_clearAll'. \
17+
La cronologia verrà cancellata sia dal file che dalla memoria temporanea.",
18+
"toolbar" : "Toolbar",
19+
"toolbar.title" : "Di seguito la descrizione dei comandi disponibile nella toolbar:",
20+
"toolbar.clear" : "Strumento per pulire la console",
21+
"toolbar.iface" : "Strumento per importare la classe iface, per accedere all'ambiente QGIS",
22+
"toolbar.sextante" : "Strumento per importare la classe Sextante",
23+
"toolbar.script.open" : "Strumento per aprire un script python da eseguire in console",
24+
"toolbar.script.save" : "Strumento per salvare uno script python sul disco",
25+
"toolbar.help" : "Aiuto",
26+
"toolbar.run" : "Esegui comando (simile al tasto <Invio>)",
27+
"thanks" : "Ringraziamenti",
28+
"thanks.text" : "Grazie a Larry Shaffer per aver fornito i file con le API."
29+
};

‎python/helpConsole/js/encoding.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
$.i18n.setDictionary(i18n_dict);
2+
3+
$('h2#headerTitle').text($.i18n._('header.title'));
4+
$('span#headerSubject').text($.i18n._('header.subject'));
5+
$('span#headerSubjectMain').text($.i18n._('header.subject.main'));
6+
$('h4#features').text($.i18n._('features'));
7+
$('span#featuresTitle').text($.i18n._('features.title'));
8+
$('span#featuresA').text($.i18n._('features.a'));
9+
$('span#featuresB').text($.i18n._('features.b'));
10+
$('span#featuresC').text($.i18n._('features.c'));
11+
$('span#featuresD').text($.i18n._('features.d'));
12+
$('span#featuresE').text($.i18n._('features.e'));
13+
$('h4#toolbar').text($.i18n._('toolbar'));
14+
$('span#toolbarTitle').text($.i18n._('toolbar.title'));
15+
$('span#toolbarClear').text($.i18n._('toolbar.clear'));
16+
$('span#toolbarIfaceClass').text($.i18n._('toolbar.iface'));
17+
$('span#toolbarSextClass').text($.i18n._('toolbar.sextante'));
18+
$('span#toolbarScriptOpen').text($.i18n._('toolbar.script.open'));
19+
$('span#toolbarScriptSave').text($.i18n._('toolbar.script.save'));
20+
$('span#toolbarHelp').text($.i18n._('toolbar.help'));
21+
$('span#toolbarRun').text($.i18n._('toolbar.run'));
22+
$('h4#thanks').text($.i18n._('thanks'));
23+
$('span#thanksText').text($.i18n._('thanks.text'));

‎python/helpConsole/js/jquery-1.8.2.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* jQuery i18n plugin
3+
* @requires jQuery v1.1 or later
4+
*
5+
* See http://recursive-design.com/projects/jquery-i18n/
6+
*
7+
* Licensed under the MIT license:
8+
* http://www.opensource.org/licenses/mit-license.php
9+
*
10+
* Version: 0.9.2 (201204070102)
11+
*/
12+
(function(f){f.i18n={dict:null,setDictionary:function(a){this.dict=a},_:function(a,b){var d=a;if(this.dict&&this.dict[a])d=this.dict[a];return this.printf(d,b)},toEntity:function(a){for(var b="",d=0;d<a.length;d++)b+=a.charCodeAt(d)>128?"&#"+a.charCodeAt(d)+";":a.charAt(d);return b},stripStr:function(a){return a.replace(/^\s*/,"").replace(/\s*$/,"")},stripStrML:function(a){a=a.split("\n");for(var b=0;b<a.length;b++)a[b]=stripStr(a[b]);return stripStr(a.join(" "))},printf:function(a,b){if(!b)return a;
13+
for(var d="",e=/%(\d+)\$s/g;result=e.exec(a);){var c=parseInt(result[1],10)-1;a=a.replace("%"+result[1]+"$s",b[c]);b.splice(c,1)}e=a.split("%s");if(e.length>1)for(c=0;c<b.length;c++){if(e[c].lastIndexOf("%")==e[c].length-1&&c!=b.length-1)e[c]+="s"+e.splice(c+1,1)[0];d+=e[c]+b[c]}return d+e[e.length-1]}};f.fn._t=function(a,b){return f(this).text(f.i18n._(a,b))}})(jQuery);

‎resources/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
INSTALL(FILES srs.db qgis.db qgis_help.db symbology-ng-style.db spatialite.db customization.xml
22
DESTINATION ${QGIS_DATA_DIR}/resources)
33
INSTALL(DIRECTORY cpt-city-qgis-min DESTINATION ${QGIS_DATA_DIR}/resources)
4+
INSTALL(DIRECTORY jQuery DESTINATION ${QGIS_DATA_DIR}/resources)
45

56
ADD_SUBDIRECTORY(context_help)
67
ADD_SUBDIRECTORY(function_help)

‎resources/jQuery/jquery-1.8.2.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎resources/jQuery/jquery.i18n.min.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* jQuery i18n plugin
3+
* @requires jQuery v1.1 or later
4+
*
5+
* See http://recursive-design.com/projects/jquery-i18n/
6+
*
7+
* Licensed under the MIT license:
8+
* http://www.opensource.org/licenses/mit-license.php
9+
*
10+
* Version: 0.9.2 (201204070102)
11+
*/
12+
(function(f){f.i18n={dict:null,setDictionary:function(a){this.dict=a},_:function(a,b){var d=a;if(this.dict&&this.dict[a])d=this.dict[a];return this.printf(d,b)},toEntity:function(a){for(var b="",d=0;d<a.length;d++)b+=a.charCodeAt(d)>128?"&#"+a.charCodeAt(d)+";":a.charAt(d);return b},stripStr:function(a){return a.replace(/^\s*/,"").replace(/\s*$/,"")},stripStrML:function(a){a=a.split("\n");for(var b=0;b<a.length;b++)a[b]=stripStr(a[b]);return stripStr(a.join(" "))},printf:function(a,b){if(!b)return a;
13+
for(var d="",e=/%(\d+)\$s/g;result=e.exec(a);){var c=parseInt(result[1],10)-1;a=a.replace("%"+result[1]+"$s",b[c]);b.splice(c,1)}e=a.split("%s");if(e.length>1)for(c=0;c<b.length;c++){if(e[c].lastIndexOf("%")==e[c].length-1&&c!=b.length-1)e[c]+="s"+e.splice(c+1,1)[0];d+=e[c]+b[c]}return d+e[e.length-1]}};f.fn._t=function(a,b){return f(this).text(f.i18n._(a,b))}})(jQuery);

0 commit comments

Comments
 (0)
Please sign in to comment.