THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Git Source Code Mirror - This is a publish-only repository and all pull requests are ignored. Please follow Documentation/SubmittingPatches procedure for any of your improvements.
git
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
2.4KB

  1. # This shell library is Git's interface to gettext.sh. See po/README
  2. # for usage instructions.
  3. #
  4. # Copyright (c) 2010 Ævar Arnfjörð Bjarmason
  5. #
  6. # Export the TEXTDOMAIN* data that we need for Git
  7. TEXTDOMAIN=git
  8. export TEXTDOMAIN
  9. if test -z "$GIT_TEXTDOMAINDIR"
  10. then
  11. TEXTDOMAINDIR="@@LOCALEDIR@@"
  12. else
  13. TEXTDOMAINDIR="$GIT_TEXTDOMAINDIR"
  14. fi
  15. export TEXTDOMAINDIR
  16. # First decide what scheme to use...
  17. GIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough
  18. if test -n "$GIT_TEST_GETTEXT_POISON" &&
  19. git env--helper --type=bool --default=0 --exit-code \
  20. GIT_TEST_GETTEXT_POISON
  21. then
  22. GIT_INTERNAL_GETTEXT_SH_SCHEME=poison
  23. elif test -n "@@USE_GETTEXT_SCHEME@@"
  24. then
  25. GIT_INTERNAL_GETTEXT_SH_SCHEME="@@USE_GETTEXT_SCHEME@@"
  26. elif test -n "$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS"
  27. then
  28. : no probing necessary
  29. elif type gettext.sh >/dev/null 2>&1
  30. then
  31. # GNU libintl's gettext.sh
  32. GIT_INTERNAL_GETTEXT_SH_SCHEME=gnu
  33. elif test "$(gettext -h 2>&1)" = "-h"
  34. then
  35. # gettext binary exists but no gettext.sh. likely to be a gettext
  36. # binary on a Solaris or something that is not GNU libintl and
  37. # lack eval_gettext.
  38. GIT_INTERNAL_GETTEXT_SH_SCHEME=gettext_without_eval_gettext
  39. fi
  40. export GIT_INTERNAL_GETTEXT_SH_SCHEME
  41. # ... and then follow that decision.
  42. case "$GIT_INTERNAL_GETTEXT_SH_SCHEME" in
  43. gnu)
  44. # Use libintl's gettext.sh, or fall back to English if we can't.
  45. . gettext.sh
  46. ;;
  47. gettext_without_eval_gettext)
  48. # Solaris has a gettext(1) but no eval_gettext(1)
  49. eval_gettext () {
  50. gettext "$1" | (
  51. export PATH $(git sh-i18n--envsubst --variables "$1");
  52. git sh-i18n--envsubst "$1"
  53. )
  54. }
  55. eval_ngettext () {
  56. ngettext "$1" "$2" "$3" | (
  57. export PATH $(git sh-i18n--envsubst --variables "$2");
  58. git sh-i18n--envsubst "$2"
  59. )
  60. }
  61. ;;
  62. poison)
  63. # Emit garbage so that tests that incorrectly rely on translatable
  64. # strings will fail.
  65. gettext () {
  66. printf "%s" "# GETTEXT POISON #"
  67. }
  68. eval_gettext () {
  69. printf "%s" "# GETTEXT POISON #"
  70. }
  71. eval_ngettext () {
  72. printf "%s" "# GETTEXT POISON #"
  73. }
  74. ;;
  75. *)
  76. gettext () {
  77. printf "%s" "$1"
  78. }
  79. eval_gettext () {
  80. printf "%s" "$1" | (
  81. export PATH $(git sh-i18n--envsubst --variables "$1");
  82. git sh-i18n--envsubst "$1"
  83. )
  84. }
  85. eval_ngettext () {
  86. (test "$3" = 1 && printf "%s" "$1" || printf "%s" "$2") | (
  87. export PATH $(git sh-i18n--envsubst --variables "$2");
  88. git sh-i18n--envsubst "$2"
  89. )
  90. }
  91. ;;
  92. esac
  93. # Git-specific wrapper functions
  94. gettextln () {
  95. gettext "$1"
  96. echo
  97. }
  98. eval_gettextln () {
  99. eval_gettext "$1"
  100. echo
  101. }