Skip to content

Commit 4b604f1

Browse files
committed
Added i18n for help (Python Console)
1 parent 32deee7 commit 4b604f1

10 files changed

Lines changed: 161 additions & 27 deletions

File tree

‎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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def __init__(self):
1313
def setupUi(self):
1414
self.setMaximumSize(500, 300)
1515
self.webView = QtWebKit.QWebView()
16-
self.setWindowTitle("Help Python Console")
16+
self.setWindowTitle(QCoreApplication.translate("PythonConsole","Help Python Console"))
1717
self.verticalLayout= QtGui.QVBoxLayout()
1818
self.verticalLayout.setSpacing(2)
1919
self.verticalLayout.setMargin(0)
@@ -29,7 +29,8 @@ def setupUi(self):
2929
QObject.connect(self.closeButton, QtCore.SIGNAL("clicked()"), self.closeWindow)
3030
self.verticalLayout.addLayout(self.horizontalLayout)
3131
self.setLayout(self.verticalLayout)
32-
filename = os.path.dirname(__file__) + "/helpConsole/help.htm"
32+
localeFullName = QSettings().value( "locale/userLocale", QVariant( "" ) ).toString()
33+
filename = os.path.dirname(__file__) + "/helpConsole/help.htm?lang=" + localeFullName
3334
url = QtCore.QUrl(filename)
3435
self.webView.load(url)
3536

‎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: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
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+
<script type="text/javascript">
9+
$(document).ready(function(){
10+
var parameter = window.location.search.replace( "?", "" );
11+
var locale = parameter.split("=");
12+
var lang = locale[1]
13+
var js = document.createElement("script");
14+
js.type = "text/javascript";
15+
js.src = "i18n/" + lang + ".properties";
16+
document.body.appendChild(js);
17+
//alert(js.src);
18+
19+
var encode = document.createElement("script");
20+
encode.type = "text/javascript";
21+
encode.src = "js/encoding.js";
22+
document.body.appendChild(encode);
23+
});
24+
</script>
525
<style>
626
body{
727
font-family: verdana,arial,helvetica,sans-serif;
@@ -25,28 +45,28 @@
2545
<img src="../iconConsole/imgHelpDialog.png" />
2646
</td>
2747
<td>
28-
<h2>Python Console for QGIS</h2>
48+
<h2 id="headerTitle">Python Console for QGIS</h2>
2949
</td>
3050
</tr>
3151
</table>
3252
<p align="justify">
33-
Python Console based on pyScintilla. (Developed by Salvatore Larosa)
53+
<span id="headerSubject">Python Console based on PyQScintilla2. (Developed by Salvatore Larosa)</span>
3454
<br><br>
35-
To access Quantum GIS environment from this console
55+
<span id="headerSubjectMain">To access Quantum GIS environment from this console
3656
use qgis.utils.iface object (instance of QgisInterface class).
3757
To import the class QgisInterface can also use the dedicated
38-
button on the toolbar on the left.
58+
button on the toolbar on the left.</span>
3959
</p>
4060
<table id="header">
4161
<tr>
4262
<td>
43-
<h4>Features</h4>
63+
<h4 id="features">Features</h4>
4464
</td>
4565
</tr>
4666
</table>
4767
<p align="justify">
4868
<ul>
49-
<li>Auto-completion and highlighting syntax for the following APIs:
69+
<li><span id="featuresTitle">Auto-completion and highlighting syntax for the following APIs:</span>
5070
<ol>
5171
<li>Python</li>
5272
<li>PyQGIS-master</li>
@@ -56,75 +76,75 @@ <h4>Features</h4>
5676
</ol>
5777
</li>
5878
<br>
59-
<li>CTRL+SPACE to view the auto-completion list.</li>
79+
<li><span id="featuresA">CTRL+SPACE to view the auto-completion list.</span></li>
6080
<br>
61-
<li>CTRL+ALT+SPACE to view the command history list.</li>
81+
<li><span id="featuresB">CTRL+ALT+SPACE to view the command history list.</span></li>
6282
<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
83+
<li><span id="featuresC">Saves the command history by typing <b>_save</b> or closing the widget.<br>
84+
This command saves the history command in the file ~/.qgis/console_history.txt</span>
6585
</li>
6686
<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
87+
<li><span id="featuresD">Clears the command history by typing <b>_clear</b>.<br>
88+
This command clears the command history from file ~/.qgis/console_history.txt</span>
6989
</li>
7090
<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.
91+
<li><span id="featuresE">Clears completely command history by typing <b>_clearAll</b>.<br>
92+
This command clears completely the command history. It has an irreversible effect.</span>
7393
</li>
7494
</ul>
7595
</p>
7696
<table id="header">
7797
<tr>
7898
<td>
79-
<h4>Toolbar</h4>
99+
<h4 id="toolbar">Toolbar</h4>
80100
</td>
81101
</tr>
82102
</table>
83-
<p>The following is a description of the tools in the toolbar:</p>
103+
<p><span id="toolbarTitle">The following is a description of the tools in the toolbar:</span></p>
84104
<table width="100%" border="0" id="headerTool">
85105
<tr>
86106
<td><img src="../iconConsole/iconClearConsole.png" /></td>
87-
<td colspan="2">Tool to clear python console</td>
107+
<td colspan="2"><span id="toolbarClear">Tool to clear python console</span></td>
88108
</tr>
89109
<tr>
90110
<td><img src="../iconConsole/iconClassConsole.png" /></td>
91111
<td><img src="../iconConsole/iconIfaceConsole.png" /></td>
92-
<td>Tool to import iface class</td>
112+
<td><span id="toolbarIfaceClass">Tool to import iface class</span></td>
93113
</tr>
94114
<tr>
95115
<td></td>
96116
<td><img src="../iconConsole/iconSextanteConsole.png" /></td>
97-
<td>Tool to import Sextante class</td>
117+
<td><span id="toolbarSextClass">Tool to import Sextante class</span></td>
98118
</tr>
99119
<tr>
100120
<td><img src="../iconConsole/iconScriptConsole.png" /></td>
101121
<td><img src="../iconConsole/iconOpenConsole.png" /></td>
102-
<td>Tool to open a python script and load in console</td>
122+
<td><span id="toolbarScriptOpen">Tool to open a python script and load in console</span></td>
103123
</tr>
104124
<tr>
105125
<td></td>
106126
<td><img src="../iconConsole/iconSaveConsole.png" /></td>
107-
<td>Tool to save a python script</td>
127+
<td><span id="toolbarScriptSave">Tool to save a python script</span></td>
108128
</tr>
109129
<tr>
110130
<td><img src="../iconConsole/iconHelpConsole.png" /></td>
111-
<td colspan="2">Help</td>
131+
<td colspan="2"><span id="toolbarHelp">Help</span></td>
112132
</tr>
113133
<tr>
114134
<td><img src="../iconConsole/iconRunConsole.png" /></td>
115-
<td colspan="2">Run command (like Enter key pressed)</td>
135+
<td colspan="2"><span id="toolbarRun">Run command (like Enter key pressed)</span></td>
116136
</tr>
117137
</table>
118138
<br>
119139
<table id="header">
120140
<tr>
121141
<td>
122-
<h4>Acknowledgments</h4>
142+
<h4 id="thanks">Acknowledgments</h4>
123143
</td>
124144
</tr>
125145
</table>
126146
<p>
127-
Thanks to Larry Shaffer who provided the API files.
147+
<span id="thanksText">Thanks to Larry Shaffer who provided the API files.</span>
128148
</p>
129149
</body>
130150
</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.js".
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+
};
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);

0 commit comments

Comments
 (0)