José Matos wrote:
> On Thursday 10 August 2006 17:23, Angus Leeming wrote:
>> I'm not very good at awk

> LOL.
> After seeing your spells(*) with sed, awk and co., I think that I am
> allowed to disagree. ;-)

Flattery will get you everywhere, José ;-)

Ok, the script below works for me with

$ awk -v top_srcdir='.' -f trial.awk \
  ./src/frontends/qt3/ui/QPrefDisplayModule.ui

Angus

function fixupfilename()
{
    return substr(FILENAME, length(top_srcdir "/") + 1);
}
BEGIN {
    previousline="";
}
{
    # Filter out the captions as they just clutter the .po files.
    if (!(previousline ~ /^ *< *property  *name *= *"caption" *> *$/)) {
        if ($0 ~ /<string>/) {          
            line=$0;            
            sub(/.*<string>/, "", line);
            sub(/<\/string>.*/, "", line);
            gsub(/&amp;/, "\\&", line);
            gsub(/&lt;/, "<", line);
            gsub(/&gt;/, ">", line);
            gsub(/"/, "\\\"", line);
            if (length(line) > 0) {
                printf("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n\n",
                       fixupfilename(), FNR, line);
            }
        }
    }
    previousline=$0;
}


Reply via email to