From 5916fef870f2f9c54cb488c1de3259b663ce4593 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Tue, 22 Jun 2021 12:40:31 +0300 Subject: [PATCH] kdeui: rewrite preparetips as shell script Signed-off-by: Ivailo Monev --- CMakeLists.txt | 7 ----- appveyor.yml | 2 +- kdeui/preparetips | 76 +++++++++++------------------------------------ 3 files changed, 19 insertions(+), 66 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bf8e0a76..38f0a5e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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" diff --git a/appveyor.yml b/appveyor.yml index affdead5..f084ea47 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -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 \ diff --git a/kdeui/preparetips b/kdeui/preparetips index a89d9f14..4a608757 100755 --- a/kdeui/preparetips +++ b/kdeui/preparetips @@ -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 +# 2021 by Ivailo Monev # 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 '';then + intip="yes" + echo "// i18n: ectx: @info:tipoftheday"; + printf "i18n("; + continue + elif echo "$line" | grep -q '';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() -{ - chomp; - - # tip starts with - if(/^\s*(.*)/io) - { - $inTip=1; - print "// i18n: file: tips:$.\n// i18n: ectx: \@info:tipoftheday\n"; - print "i18n("; - printText($1); - next; - } - - if($inTip!=0) - { - # tip ends with - 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