/lib/gettext-real.sh

http://github.com/sukria/Backup-Manager · Shell · 41 lines · 17 code · 3 blank · 21 comment · 1 complexity · 9640d2ebb4ba39be8e89f13ccc8adf87 MD5 · raw file

  1. # Copyright © 2005-2016 The Backup Manager Authors
  2. #
  3. # See the AUTHORS file for details.
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version 2
  8. # of the License, or (at your option) 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. # Real gettext library.
  16. # Initialize the gettext stuff
  17. . /usr/bin/gettext.sh
  18. TEXTDOMAIN=backup-manager
  19. export TEXTDOMAIN
  20. # This is the wrapper to the gettext function
  21. # We use eval_gettext in order to substitue every
  22. # variable prensent in the string.
  23. function translate()
  24. {
  25. eval_gettext "$1"; echo
  26. }
  27. # This can do an echo with -n or not, and after
  28. # having gettextized the string.
  29. function echo_translated()
  30. {
  31. if [[ "$1" = "-n" ]]; then
  32. message=$(translate "$2")
  33. echo -n "$message"
  34. else
  35. message=$(translate "$1")
  36. echo "$message"
  37. fi
  38. }