Mercurial > trustbridge
comparison packaging/getxt-gen-l10n-array.sh @ 795:3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Tue, 15 Jul 2014 13:24:26 +0200 |
parents | |
children | 6e300f749a6d |
comparison
equal
deleted
inserted
replaced
794:fdc15f0cfdd8 | 795:3a9b0c75f5a6 |
---|---|
1 # ------------------------------------------------------------------- | |
2 # Copyright (C) 2014 by Intevation GmbH | |
3 # Author(s): | |
4 # Sascha Wilde <wilde@intevation.de> | |
5 | |
6 # This program is free software under the GNU GPL (>=v2) | |
7 # Read the file COPYING coming with the software for details. | |
8 # ------------------------------------------------------------------- | |
9 | |
10 # Extract getxt strings from source and generate an array for usage in | |
11 # the script using our getxt function. | |
12 | |
13 # USAGE: getxt-gen-l10n-array.sh SRC ARRAYNAME ARRAYFILE | |
14 # | |
15 # Where SRC is the shell script using getxt and ARRAYFILE is | |
16 # the file to which the generated array is to be saved. | |
17 # | |
18 # ARRAYNAME is the name of the associative bash array to generate. | |
19 # | |
20 # If ARRAYFILE exists, values already defined will be preserved, | |
21 # if the MSGID still exists. | |
22 | |
23 # FIXME: we can't handle quoted quotes: "\"" -- don't use them for | |
24 # now... | |
25 | |
26 declare -a MSGIDS | |
27 declare -A L10N | |
28 | |
29 get_msgids() | |
30 { | |
31 while read -r id ; do | |
32 MSGIDS+=("$id") | |
33 done < <( sed -n 's/.*\(getxt\|fatal\) [^"]*\("[^"]*"\).*/\2/p' "$1" | sort | uniq ) | |
34 } | |
35 | |
36 merge_l10n() | |
37 { | |
38 for msgid in "${MSGIDS[@]}" ; do | |
39 msg=`grep -F "[${msgid}]" "$1" | sed -n 's/.*="\(.*\)"/\1/p'` | |
40 if [ "$msg" ] ; then | |
41 L10N["$msgid"]="$msg" | |
42 fi | |
43 done | |
44 } | |
45 | |
46 write_l10n_array() | |
47 { | |
48 echo "$1=(" | |
49 for msgid in "${MSGIDS[@]}" ; do | |
50 echo " [${msgid}]=\"${L10N[$msgid]}\"" | |
51 done | |
52 echo ")" | |
53 } | |
54 | |
55 get_msgids "$1" | |
56 merge_l10n "$3" | |
57 write_l10n_array "$2" >"$3" |