Statistics
| Revision:

root / import / ext3D / trunk / install-extension3d / launcher / izpack-launcher-1.3 / src / gettext / bin / gettext.sh @ 15280

History | View | Annotate | Download (2.65 KB)

1
#! /bin/false
2
#
3
# Copyright (C) 2003 Free Software Foundation, Inc.
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2, or (at your option)
8
# any later version.
9
#
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
#
19

    
20
# Find a way to echo strings without interpreting backslash.
21
if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then
22
  echo='echo'
23
else
24
  if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then
25
    echo='printf %s\n'
26
  else
27
    echo_func () {
28
      cat <<EOT
29
$*
30
EOT
31
    }
32
    echo='echo_func'
33
  fi
34
fi
35

    
36
# eval_gettext MSGID
37
# looks up the translation of MSGID and substitutes shell variables in the
38
# result.
39
eval_gettext () {
40
  gettext "$1" | (export PATH `envsubst --variables "$1"`; envsubst "$1")
41
}
42

    
43
# eval_ngettext MSGID MSGID-PLURAL COUNT
44
# looks up the translation of MSGID / MSGID-PLURAL for COUNT and substitutes
45
# shell variables in the result.
46
eval_ngettext () {
47
  ngettext "$1" "$2" "$3" | (export PATH `envsubst --variables "$1 $2"`; envsubst "$1 $2")
48
}
49

    
50
# Note: This use of envsubst is much safer than using the shell built-in 'eval'
51
# would be.
52
# 1) The security problem with Chinese translations that happen to use a
53
#    character such as \xe0\x60 is avoided.
54
# 2) The security problem with malevolent translators who put in command lists
55
#    like "$(...)" or "`...`" is avoided.
56
# 3) The translations can only refer to shell variables that are already
57
#    mentioned in MSGID or MSGID-PLURAL.
58
#
59
# Note: "export PATH" above is a dummy; this is for the case when
60
# `envsubst --variables ...` returns nothing.
61
#
62
# Note: In eval_ngettext above, "$1 $2" means a string whose variables set is
63
# the union of the variables set of "$1" and "$2".
64
#
65
# Note: The minimal use of backquote above ensures that trailing newlines are
66
# not dropped, not from the gettext invocation and not from the value of any
67
# shell variable.
68
#
69
# Note: Field splitting on the `envsubst --variables ...` result is desired,
70
# since envsubst outputs the variables, separated by newlines. Pathname
71
# wildcard expansion or tilde expansion has no effect here, since the words
72
# output by "envsubst --variables ..." consist solely of alphanumeric
73
# characters and underscore.