annotate packaging/getxt-gen-l10n-array.sh @ 817:6de4adb32668 0.8

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

http://wald.intevation.org/projects/trustbridge/