tst-gettext2.sh 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/bin/sh
  2. # Test of gettext functions.
  3. # Copyright (C) 2000-2019 Free Software Foundation, Inc.
  4. # This file is part of the GNU C Library.
  5. # The GNU C Library is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU Lesser General Public
  7. # License as published by the Free Software Foundation; either
  8. # version 2.1 of the License, or (at your option) any later version.
  9. # The GNU C Library is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. # Lesser General Public License for more details.
  13. # You should have received a copy of the GNU Lesser General Public
  14. # License along with the GNU C Library; if not, see
  15. # <http://www.gnu.org/licenses/>.
  16. set -e
  17. common_objpfx=$1
  18. test_program_prefix_before_env=$2
  19. run_program_env=$3
  20. test_program_prefix_after_env=$4
  21. objpfx=$5
  22. # Generate the test data.
  23. mkdir -p ${objpfx}domaindir
  24. # Create the locale directories.
  25. mkdir -p \
  26. ${objpfx}domaindir/lang1/LC_MESSAGES \
  27. ${objpfx}domaindir/lang2/LC_MESSAGES
  28. for f in ADDRESS COLLATE CTYPE IDENTIFICATION MEASUREMENT MONETARY NAME NUMERIC PAPER TELEPHONE TIME; do
  29. [ -e ${objpfx}domaindir/lang1/LC_$f ] ||
  30. cp ${common_objpfx}localedata/de_DE.ISO-8859-1/LC_$f \
  31. ${objpfx}domaindir/lang1
  32. [ -e ${objpfx}domaindir/lang2/LC_$f ] ||
  33. cp ${common_objpfx}localedata/de_DE.ISO-8859-1/LC_$f \
  34. ${objpfx}domaindir/lang2
  35. done
  36. test -e ${objpfx}domaindir/lang1/LC_MESSAGES/SYS_LC_MESSAGES || {
  37. cp ${common_objpfx}localedata/de_DE.ISO-8859-1/LC_MESSAGES/SYS_LC_MESSAGES \
  38. ${objpfx}domaindir/lang1/LC_MESSAGES
  39. }
  40. test -e ${objpfx}domaindir/lang2/LC_MESSAGES/SYS_LC_MESSAGES || {
  41. cp ${common_objpfx}localedata/de_DE.ISO-8859-1/LC_MESSAGES/SYS_LC_MESSAGES \
  42. ${objpfx}domaindir/lang2/LC_MESSAGES
  43. }
  44. # Populate them.
  45. msgfmt -o ${objpfx}domaindir/lang1/LC_MESSAGES/tstlang.mo \
  46. tstlang1.po
  47. msgfmt -o ${objpfx}domaindir/lang2/LC_MESSAGES/tstlang.mo \
  48. tstlang2.po
  49. # Now run the test.
  50. ${test_program_prefix_before_env} \
  51. ${run_program_env} \
  52. LOCPATH=${objpfx}domaindir \
  53. ${test_program_prefix_after_env} \
  54. ${objpfx}tst-gettext2 > ${objpfx}tst-gettext2.out ${objpfx}domaindir &&
  55. cmp ${objpfx}tst-gettext2.out - <<EOF
  56. String1 - Lang1: 1st string
  57. String2 - Lang1: 2nd string
  58. String1 - Lang2: 1st string
  59. String2 - Lang2: 2nd string
  60. String1 - First string for testing.
  61. String2 - Another string for testing.
  62. EOF
  63. exit $?