#!/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
#
# 2021 by Ivailo Monev <xakepa10@gmail.com>

# IMPORTANT NOTE: Do not change the output without checking if
# translations still work!

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

    if [ "$intip" = "yes" ];then
        echo "\""$(echo "$line" | sed -e 's|"|\\"|g' -e 's|\\|\\\\|g')"\\\n\""
    fi
done < tips
