Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

124 lignes
4.5 KiB

  1. #! /bin/sh
  2. #
  3. # Copyright (C) 2003, 2005-2007 Free Software Foundation, Inc.
  4. #
  5. # This program is free software; you can redistribute it and/or modify it
  6. # under the terms of the GNU Library General Public License as published
  7. # by 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 Library General Public
  16. # License along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
  18. # USA.
  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. # This script is primarily a shell function library. In order for
  36. # ". gettext.sh" to find it, we install it in $PREFIX/bin (that is usually
  37. # contained in $PATH), rather than in some other location such as
  38. # $PREFIX/share/sh-scripts or $PREFIX/share/gettext. In order to not violate
  39. # the Filesystem Hierarchy Standard when doing so, this script is executable.
  40. # Therefore it needs to support the standard --help and --version.
  41. if test -z "$ZSH_VERSION"; then
  42. # zsh is not POSIX compliant: By default, while ". gettext.sh" is executed,
  43. # it sets $0 to "gettext.sh", defeating the purpose of this test. But
  44. # fortunately we know that when running under zsh, this script is always
  45. # being sourced, not executed, because hardly anyone is crazy enough to
  46. # install zsh as /bin/sh.
  47. case "$0" in
  48. gettext.sh | */gettext.sh | *\\gettext.sh)
  49. progname=$0
  50. package=gettext-runtime
  51. version=0.18.1
  52. # func_usage
  53. # outputs to stdout the --help usage message.
  54. func_usage ()
  55. {
  56. echo "GNU gettext shell script function library version $version"
  57. echo "Usage: . gettext.sh"
  58. }
  59. # func_version
  60. # outputs to stdout the --version message.
  61. func_version ()
  62. {
  63. echo "$progname (GNU $package) $version"
  64. echo "Copyright (C) 2003-2007 Free Software Foundation, Inc.
  65. License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>
  66. This is free software: you are free to change and redistribute it.
  67. There is NO WARRANTY, to the extent permitted by law."
  68. echo "Written by" "Bruno Haible"
  69. }
  70. if test $# = 1; then
  71. case "$1" in
  72. --help | --hel | --he | --h )
  73. func_usage; exit 0 ;;
  74. --version | --versio | --versi | --vers | --ver | --ve | --v )
  75. func_version; exit 0 ;;
  76. esac
  77. fi
  78. func_usage 1>&2
  79. exit 1
  80. ;;
  81. esac
  82. fi
  83. # eval_gettext MSGID
  84. # looks up the translation of MSGID and substitutes shell variables in the
  85. # result.
  86. eval_gettext () {
  87. gettext "$1" | (export PATH `envsubst --variables "$1"`; envsubst "$1")
  88. }
  89. # eval_ngettext MSGID MSGID-PLURAL COUNT
  90. # looks up the translation of MSGID / MSGID-PLURAL for COUNT and substitutes
  91. # shell variables in the result.
  92. eval_ngettext () {
  93. ngettext "$1" "$2" "$3" | (export PATH `envsubst --variables "$1 $2"`; envsubst "$1 $2")
  94. }
  95. # Note: This use of envsubst is much safer than using the shell built-in 'eval'
  96. # would be.
  97. # 1) The security problem with Chinese translations that happen to use a
  98. # character such as \xe0\x60 is avoided.
  99. # 2) The security problem with malevolent translators who put in command lists
  100. # like "$(...)" or "`...`" is avoided.
  101. # 3) The translations can only refer to shell variables that are already
  102. # mentioned in MSGID or MSGID-PLURAL.
  103. #
  104. # Note: "export PATH" above is a dummy; this is for the case when
  105. # `envsubst --variables ...` returns nothing.
  106. #
  107. # Note: In eval_ngettext above, "$1 $2" means a string whose variables set is
  108. # the union of the variables set of "$1" and "$2".
  109. #
  110. # Note: The minimal use of backquote above ensures that trailing newlines are
  111. # not dropped, not from the gettext invocation and not from the value of any
  112. # shell variable.
  113. #
  114. # Note: Field splitting on the `envsubst --variables ...` result is desired,
  115. # since envsubst outputs the variables, separated by newlines. Pathname
  116. # wildcard expansion or tilde expansion has no effect here, since the words
  117. # output by "envsubst --variables ..." consist solely of alphanumeric
  118. # characters and underscore.