Skip to content
Permalink
Browse files

i18n:

* include processing algorithm descriptions from yaml (with yaml fixes)
* create ui instead of cpp where possible and use -no-ui-lines to avoid
  artificial ever changing line numbers in ts files
* drop old used scripts: create_new_ts.sh, create_new_ts.sh and
  integrate_function_help.pl, update_ts_files.sh
  • Loading branch information
jef-n committed Feb 26, 2019
1 parent 8105905 commit 2f431bc1f36f45b9bf6639691106e9975687817d
@@ -27,7 +27,7 @@
import codecs
import yaml
from qgis.core import QgsSettings, Qgis
from qgis.PyQt.QtCore import QLocale
from qgis.PyQt.QtCore import QLocale, QCoreApplication


def loadShortHelp():
@@ -37,7 +37,11 @@ def loadShortHelp():
if f.endswith("yaml"):
filename = os.path.join(path, f)
with codecs.open(filename, encoding='utf-8') as stream:
h.update(yaml.load(stream))
for k, v in yaml.load(stream).items():
if v is None:
continue
h[k] = QCoreApplication.translate("{}Algorithm".format(f[:-5].upper()), v)

version = ".".join(Qgis.QGIS_VERSION.split(".")[0:2])
overrideLocale = QgsSettings().value('locale/overrideFlag', False, bool)
if not overrideLocale:
@@ -51,7 +55,9 @@ def replace(s):
return s.replace("{qgisdocs}", "https://docs.qgis.org/%s/%s/docs" % (version, locale))
else:
return None

h = {k: replace(v) for k, v in list(h.items())}

return h


@@ -301,7 +301,7 @@ qgis:pointsalonglines: >

An optional start and end offset can be specified, which controls how far from the start and end of the geometry the points should be created.

qgis:pointsdisplacement:
qgis:pointsdisplacement: >
Offsets nearby point features by moving nearby points by a preset amount to minimize overlapping features.

qgis:pointslayerfromtable: >
@@ -311,7 +311,7 @@ qgis:pointslayerfromtable: >

The attributes table of the resulting layer will be the input table.

qgis:pointstopath:
qgis:pointstopath: >
Converts a point layer to a line layer, by joining points in a defined order.

Points can be grouped by a field to output individual line features per group.
@@ -21,6 +21,7 @@

import sys
from xml.etree import ElementTree as et
from html import escape

strings = {}

@@ -45,15 +46,18 @@

f.close()

print("""
/*
This is NOT a proper c++ source code. This file is only designed to be caught
print("""\
<?xml version="1.0" encoding="UTF-8"?>
<!--
This is NOT a proper UI code. This file is only designed to be caught
by qmake and included in lupdate. It contains all translateable strings collected
by pylupdate5.
*/
by scripts/appinfo2ui.py.
-->
<ui version="4.0">
<class>appinfo</class>;
""")

for k in strings:
k = k.replace('"', '\\"')
k = k.replace('\n', '\\n')
print("translate( \"appinfo\", \"{}\" )".format(k))
print("<property><string>{}</string></property>".format(escape(k)))

print("</ui>")

This file was deleted.

This file was deleted.

@@ -15,21 +15,23 @@
###########################################################################

use XML::Simple;
use YAML::XS qw/LoadFile/;
use Data::Dumper;

die "usage: $0 dest.cpp\n" unless @ARGV==1;
sub xmlescape {
my $data = shift;

open F, ">$ARGV[0]";
binmode(F, ":utf8");
$data =~ s/&/&amp;/sg;
$data =~ s/</&lt;/sg;
$data =~ s/>/&gt;/sg;
$data =~ s/"/&quot;/sg;

print F <<EOF;
/*
This is NOT a proper c++ source code. This file is only designed to be caught
by qmake and included in lupdate. It contains all translateable strings collected
by processing2cpp.pl.
*/
return $data;
}

EOF

die "usage: $0 dir\n" unless @ARGV==1;
die "directory $ARGV[0] not found" unless -d $ARGV[0];

my %strings;

@@ -79,7 +81,16 @@
$strings{"SAGAAlgorithm"}{$desc} = 1;
}

for my $f ( ("python/plugins/processing/gui/algclasssification.txt", "python/plugins/processing/gui/algnames.txt") ) {
for my $f (<python/plugins/processing/algs/help/*.yaml>) {
my ($base) = $f =~ /.*\/(.*)\.yaml$/;
$base = uc $base;
my $yaml = LoadFile($f);
for my $k (keys %$yaml) {
$strings{"${base}Algorithm"}{$yaml->{$k}} = 1;
}
}

for my $f ( ("python/plugins/processing/gui/algnames.txt") ) {
open I, $f;
while(<I>) {
chop;
@@ -92,13 +103,29 @@
}

foreach my $k (keys %strings) {
foreach my $v (keys %{ $strings{$k} } ) {
$v =~ s/\\/\\\\/g;
$v =~ s/"/\\"/g;
$v =~ s/\n/\\n/g;
die "$ARGV[0]/$k-i18n.ui already exists" if -f "$ARGV[0]/$k-i18n.ui";
open F, ">$ARGV[0]/$k-i18n.ui";
binmode(F, ":utf8");

print F "translate(\"$k\", \"$v\");\n";
print F <<EOF;
<?xml version="1.0" encoding="UTF-8"?>
<!--
This is NOT a proper UI code. This file is only designed to be caught
by qmake and included in lupdate. It contains all translateable strings collected
by scripts/processing2ui.pl.
-->
<ui version="4.0">
<class>$k</class>;
EOF

foreach my $v (keys %{ $strings{$k} } ) {
next if $v eq "";
print F " <property><string>" . xmlescape($v) . "</string></property>\n";
}
}

close F;
print F <<EOF;
</ui>
EOF

close F;
}
@@ -17,14 +17,14 @@
use XML::Simple;
use Data::Dumper;

print <<EOF;
/*
This is NOT a proper c++ source code. This file is only designed to be caught
by qmake and included in lupdate. It contains all translateable strings collected
by pylupdate5.
*/
EOF
sub xmlescape {
my $data = shift;
$data =~ s/&/&amp;/sg;
$data =~ s/</&lt;/sg;
$data =~ s/>/&gt;/sg;
$data =~ s/"/&quot;/sg;
return $data;
}

my %labels;
my $file;
@@ -67,9 +67,19 @@ sub parse {
}
close I;

print <<EOF;
<?xml version="1.0" encoding="UTF-8"?>
<!--
This is NOT a proper UI code. This file is only designed to be caught
by qmake and included in lupdate. It contains all translateable strings collected
by scripts/qgm2ui.pl.
-->
<ui version="4.0">
<class>grasslabels</class>;
EOF

foreach (sort keys %labels) {
s/\\/\\\\/g;
s/"/\\"/g;
s/\n/\\n/g;
print "translate( \"grasslabel\", \"$_\" );\n";
print " <property><string>" . xmlescape($_) . "</string></property>\n";
}

print "</ui>\n";

0 comments on commit 2f431bc

Please sign in to comment.
You can’t perform that action at this time.