tomb

the crypto undertaker
git clone git://parazyd.org/tomb.git
Log | Files | Refs | README | LICENSE

generate_translatable_strings.sh (1474B)


      1 #!/bin/zsh
      2 
      3 cat <<EOF
      4 # Tomb - The Crypto Undertaker.
      5 # Copyright (C) 2007-2014 Dyne.org Foundation
      6 # Denis Roio <jaromil@dyne.org>, 2013.
      7 #
      8 #, fuzzy
      9 msgid ""
     10 msgstr ""
     11 "Project-Id-Version: Tomb $VERSION\n"
     12 "PO-Revision-Date: `LANG=en date`\n"
     13 "Last-Translator: Denis Roio <jaromil@dyne.org>\n"
     14 "Language: English\n"
     15 "Language-Team: Tomb developers <crypto@lists.dyne.org>\n"
     16 "MIME-Version: 1.0\n"
     17 "Content-Type: text/plain; charset=UTF-8\n"
     18 "Content-Transfer-Encoding: 8bit\n"
     19 
     20 EOF
     21 
     22 # This is how we get the strings to be translated:
     23 #
     24 # 1. sed filters the tomb file and only shows the lines containing a print
     25 #    function, e.g. warning. It outputs two columns separated by a tab.
     26 #    The first column contains the function that is called, and the second one
     27 #    contains the message.
     28 #
     29 # 2. cat adds the line number as a new first column.
     30 #
     31 # 3. sort orders the lines using the third column and removes contiguous 
     32 #    duplicate lines. The third column is the string to be translated, removing
     33 #    duplicates even if they are printed by different functions.
     34 #
     35 # 4. sort reorders the lines numerically using the first column.
     36 #
     37 # 5. awk reads the column-formatted input and outputs valid pot lines.
     38 
     39 PRINTFUNC="_\(success\|warning\|failure\|message\|print\)"
     40 
     41 sed -n -e "s/^.*$PRINTFUNC \(\".*\"\).*$/\1\t\2/p" ../../tomb \
     42     | cat -n | sort -uk3 | sort -nk1 | cut -f2- | awk \
     43 'BEGIN { FS = "\t" }
     44 { print "#:", $1;
     45   print "msgid", $2;
     46   print "msgstr \"\"\n"
     47 }'