2018-02-05 13:38:02 +01:00
|
|
|
#!/usr/bin/env perl
|
2015-07-26 03:48:27 +02:00
|
|
|
###########################################################################
|
|
|
|
# processing2cpp.pl
|
|
|
|
# ---------------------
|
|
|
|
# begin : July 2015
|
|
|
|
# copyright : (C) 2015 by Juergen E. Fischer
|
|
|
|
# email : jef at norbit dot de
|
|
|
|
###########################################################################
|
|
|
|
# #
|
|
|
|
# This program is free software; you can redistribute it and/or modify #
|
|
|
|
# it under the terms of the GNU General Public License as published by #
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or #
|
|
|
|
# (at your option) any later version. #
|
|
|
|
# #
|
|
|
|
###########################################################################
|
|
|
|
|
|
|
|
use XML::Simple;
|
2019-02-26 22:13:02 +01:00
|
|
|
use YAML::XS qw/LoadFile/;
|
2015-07-26 03:48:27 +02:00
|
|
|
use Data::Dumper;
|
|
|
|
|
2019-02-26 22:13:02 +01:00
|
|
|
sub xmlescape {
|
|
|
|
my $data = shift;
|
2015-07-26 03:48:27 +02:00
|
|
|
|
2019-02-26 22:13:02 +01:00
|
|
|
$data =~ s/&/&/sg;
|
|
|
|
$data =~ s/</</sg;
|
|
|
|
$data =~ s/>/>/sg;
|
|
|
|
$data =~ s/"/"/sg;
|
2015-07-26 03:48:27 +02:00
|
|
|
|
2019-02-26 22:13:02 +01:00
|
|
|
return $data;
|
|
|
|
}
|
2015-07-26 03:48:27 +02:00
|
|
|
|
2019-02-26 22:13:02 +01:00
|
|
|
|
|
|
|
die "usage: $0 dir\n" unless @ARGV==1;
|
|
|
|
die "directory $ARGV[0] not found" unless -d $ARGV[0];
|
2015-07-26 03:48:27 +02:00
|
|
|
|
|
|
|
my %strings;
|
|
|
|
|
|
|
|
for my $f (<python/plugins/processing/algs/otb/description/*.xml>) {
|
|
|
|
my $xml = XMLin($f, ForceArray=>1);
|
|
|
|
|
|
|
|
foreach my $k (qw/longname group description/) {
|
|
|
|
$strings{"OTBAlgorithm"}{$xml->{$k}->[0]} = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for my $f (<python/plugins/processing/algs/grass*/description/*.txt>) {
|
|
|
|
open I, $f;
|
|
|
|
my $name = scalar(<I>);
|
|
|
|
my $desc = scalar(<I>);
|
|
|
|
my $group = scalar(<I>);
|
2019-03-04 21:14:14 +01:00
|
|
|
|
|
|
|
while( my($class, $name, $description, $rest) = split /\|/, scalar(<I>) ) {
|
|
|
|
next unless defined $description;
|
|
|
|
$description =~ s/\s+$//;
|
|
|
|
$strings{"GrassAlgorithm"}{$description} = 1
|
|
|
|
}
|
|
|
|
|
2015-07-26 03:48:27 +02:00
|
|
|
close I;
|
|
|
|
|
|
|
|
chop $desc;
|
|
|
|
chop $group;
|
|
|
|
|
|
|
|
$strings{"GrassAlgorithm"}{$desc} = 1;
|
|
|
|
$strings{"GrassAlgorithm"}{$group} = 1;
|
|
|
|
}
|
|
|
|
|
2019-03-04 21:14:14 +01:00
|
|
|
for my $f (<python/plugins/processing/algs/saga/description/*/*.txt>) {
|
2015-07-26 03:48:27 +02:00
|
|
|
open I, $f;
|
|
|
|
my $desc = scalar(<I>);
|
|
|
|
|
2019-03-04 21:14:14 +01:00
|
|
|
while( my($class, $name, $description, $rest) = split /\|/, scalar(<I>) ) {
|
|
|
|
next unless defined $description;
|
|
|
|
$description =~ s/\s+$//;
|
|
|
|
$strings{"SAGAAlgorithm"}{$description} = 1
|
|
|
|
}
|
2015-07-26 03:48:27 +02:00
|
|
|
|
|
|
|
close I;
|
|
|
|
|
|
|
|
chop $desc;
|
|
|
|
|
|
|
|
$strings{"SAGAAlgorithm"}{$desc} = 1;
|
|
|
|
}
|
|
|
|
|
2019-02-26 22:13:02 +01:00
|
|
|
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") ) {
|
2015-07-26 03:48:27 +02:00
|
|
|
open I, $f;
|
|
|
|
while(<I>) {
|
|
|
|
chop;
|
|
|
|
s/^.*,//;
|
|
|
|
foreach my $v (split "/", $_) {
|
|
|
|
$strings{"AlgorithmClassification"}{$v} = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close I;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach my $k (keys %strings) {
|
2019-02-26 22:13:02 +01:00
|
|
|
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");
|
2015-07-26 03:48:27 +02:00
|
|
|
|
2019-02-26 22:13:02 +01:00
|
|
|
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";
|
2015-07-26 03:48:27 +02:00
|
|
|
}
|
|
|
|
|
2019-02-26 22:13:02 +01:00
|
|
|
print F <<EOF;
|
|
|
|
</ui>
|
|
|
|
EOF
|
|
|
|
|
|
|
|
close F;
|
|
|
|
}
|