kdeui: rewrite preparetips as shell script

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-06-22 12:40:31 +03:00
parent 853f83b52b
commit 5916fef870
3 changed files with 19 additions and 66 deletions

View file

@ -45,13 +45,6 @@ if(UNIX AND Q_WS_X11)
endif(UNIX AND Q_WS_X11)
# required features
find_package(Perl)
set_package_properties(Perl PROPERTIES
URL "http://www.perl.org"
TYPE RUNTIME
PURPOSE "Needed for KDEUI preparetips script"
)
find_package(ZLIB)
set_package_properties(ZLIB PROPERTIES
DESCRIPTION "Support for gzip compressed files and data streams"

View file

@ -20,7 +20,7 @@ build_script:
sudo apt-get install -qq cmake katie-dev libenchant-dev \
libopenexr-dev libmpv-dev libraw-dev xorg-dev mesa-common-dev \
libavahi-common-dev krb5-multidev perl-base libwebp-dev \
libavahi-common-dev krb5-multidev libwebp-dev \
libudev-dev liblzma-dev libexiv2-dev libilmbase-dev libjpeg-dev \
libbz2-dev libattr1-dev libacl1-dev libxcb-render-util0-dev \
libxcb-keysyms1-dev libxcb-image0-dev libcdio-dev strigi \

View file

@ -1,66 +1,26 @@
#! /usr/bin/perl
#!/bin/sh
# little script to extract the text from the tips file
# and output it, so xgettext can add the tips to the po file
#
# 2000 by Matthias Kiefer <matthias.kiefer@gmx.de>
# 2021 by Ivailo Monev <xakepa10@gmail.com>
# IMPORTANT NOTE: Do not change the output without checking if
# translations still work!
sub printText
{
my $text = $_[0];
if ( $text cmp "" )
{
intip="no"
while read line;do
if echo "$line" | grep -q '<html>';then
intip="yes"
echo "// i18n: ectx: @info:tipoftheday";
printf "i18n(";
continue
elif echo "$line" | grep -q '</html>';then
intip="no"
echo ");";
fi
# replace \ with \\
$text =~ s/\\/\\\\/g;
# replace " with \"
$text =~ s/"/\\"/g;
print "\"$text\\n\"\n";
}
}
open(FILE,"<","tips") or die "unable to open tips file";
if ( $^V ge v5.8.0 )
{
binmode(FILE,":utf8");
binmode(STDOUT,":utf8");
}
$inTip=0;
while(<FILE>)
{
chomp;
# tip starts with <html>
if(/^\s*<html>(.*)/io)
{
$inTip=1;
print "// i18n: file: tips:$.\n// i18n: ectx: \@info:tipoftheday\n";
print "i18n(";
printText($1);
next;
}
if($inTip!=0)
{
# tip ends with </html>
if(/^(.*)\s*<\/html>/io)
{
printText($1);
print ");\n\n";
$inTip=0;
}
else
{
printText($_);
}
}
}
close(FILE);
if [ "$intip" = "yes" ];then
echo "\""$(echo "$line" | sed -e 's|"|\\"|g' -e 's|\\|\\\\|g')"\\\n\""
fi
done < tips