Mercurial > trustbridge
annotate packaging/getxt-gen-l10n-array.sh @ 1255:2a1aa9df8f11
(issue133) Improve API documentation
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Thu, 25 Sep 2014 17:58:12 +0200 |
parents | 96ecd345c961 |
children |
rev | line source |
---|---|
1039
069f5e5344f6
packaging/getxt-gen-l10n-array.sh: Copyright header changes to standard.
Bernhard Reiter <bernhard@intevation.de>
parents:
821
diff
changeset
|
1 # Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik |
069f5e5344f6
packaging/getxt-gen-l10n-array.sh: Copyright header changes to standard.
Bernhard Reiter <bernhard@intevation.de>
parents:
821
diff
changeset
|
2 # Software engineering by Intevation GmbH |
069f5e5344f6
packaging/getxt-gen-l10n-array.sh: Copyright header changes to standard.
Bernhard Reiter <bernhard@intevation.de>
parents:
821
diff
changeset
|
3 # |
069f5e5344f6
packaging/getxt-gen-l10n-array.sh: Copyright header changes to standard.
Bernhard Reiter <bernhard@intevation.de>
parents:
821
diff
changeset
|
4 # This file is Free Software under the GNU GPL (v>=2) |
069f5e5344f6
packaging/getxt-gen-l10n-array.sh: Copyright header changes to standard.
Bernhard Reiter <bernhard@intevation.de>
parents:
821
diff
changeset
|
5 # and comes with ABSOLUTELY NO WARRANTY! |
069f5e5344f6
packaging/getxt-gen-l10n-array.sh: Copyright header changes to standard.
Bernhard Reiter <bernhard@intevation.de>
parents:
821
diff
changeset
|
6 # See LICENSE.txt for details. |
069f5e5344f6
packaging/getxt-gen-l10n-array.sh: Copyright header changes to standard.
Bernhard Reiter <bernhard@intevation.de>
parents:
821
diff
changeset
|
7 # |
795
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
8 # Author(s): |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
9 # Sascha Wilde <wilde@intevation.de> |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
10 |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
11 # 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
|
12 # the script using our getxt function. |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
13 |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
14 # 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
|
15 # |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
16 # 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
|
17 # 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
|
18 # |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
19 # 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
|
20 # |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
21 # 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
|
22 # if the MSGID still exists. |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
23 |
1065
5cf648c233d2
Note that quoted quotes are unhandled instead of FIXME
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1039
diff
changeset
|
24 # NOTE: we can't handle quoted quotes: "\"" -- don't use them for |
795
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
25 # now... |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
26 |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
27 declare -a MSGIDS |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
28 declare -A L10N |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
29 |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
30 get_msgids() |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
31 { |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
32 while read -r id ; do |
821
6e300f749a6d
Ignore MSGID "$1", which is an artifact by the "fatal" function.
Sascha Wilde <wilde@intevation.de>
parents:
795
diff
changeset
|
33 if [ "$id" != '"$1"' ] ; then |
6e300f749a6d
Ignore MSGID "$1", which is an artifact by the "fatal" function.
Sascha Wilde <wilde@intevation.de>
parents:
795
diff
changeset
|
34 MSGIDS+=("$id") |
6e300f749a6d
Ignore MSGID "$1", which is an artifact by the "fatal" function.
Sascha Wilde <wilde@intevation.de>
parents:
795
diff
changeset
|
35 fi |
795
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
36 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
|
37 } |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
38 |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
39 merge_l10n() |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
40 { |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
41 for msgid in "${MSGIDS[@]}" ; do |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
42 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
|
43 if [ "$msg" ] ; then |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
44 L10N["$msgid"]="$msg" |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
45 fi |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
46 done |
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 |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
49 write_l10n_array() |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
50 { |
1149
96ecd345c961
Split up l10n matching the new split up installer files.
Sascha Wilde <wilde@intevation.de>
parents:
1065
diff
changeset
|
51 echo "$1+=(" |
795
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
52 for msgid in "${MSGIDS[@]}" ; do |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
53 echo " [${msgid}]=\"${L10N[$msgid]}\"" |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
54 done |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
55 echo ")" |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
56 } |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
57 |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
58 get_msgids "$1" |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
59 merge_l10n "$3" |
3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
60 write_l10n_array "$2" >"$3" |