mc.hint-fromTransifex.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. # Midnight Commander - fetch doc/hints/mc.hint translations from Transifex
  3. #
  4. # Copyright (C) 2013
  5. # The Free Software Foundation, Inc.
  6. #
  7. # Written by:
  8. # Slava Zanko <slavazanko@gmail.com>, 2013
  9. #
  10. # This file is part of the Midnight Commander.
  11. #
  12. # The Midnight Commander is free software: you can redistribute it
  13. # and/or modify it under the terms of the GNU General Public License as
  14. # published by the Free Software Foundation, either version 3 of the License,
  15. # or (at your option) any later version.
  16. #
  17. # The Midnight Commander is distributed in the hope that it will be useful,
  18. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. # GNU General Public License for more details.
  21. #
  22. # You should have received a copy of the GNU General Public License
  23. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. set -e
  25. MC_SOURCE_ROOT_DIR=${MC_SOURCE_ROOT_DIR:-$(dirname $(dirname $(dirname $(pwd))))}
  26. #*** include section (source functions, for example) *******************
  27. source "${MC_SOURCE_ROOT_DIR}/maint/utils/sync-transifex/functions"
  28. #*** file scope functions **********************************************
  29. processHintFiles() {
  30. # Remove extra backslash
  31. sed -i -e 's/\\-/-/g' ${MC_SOURCE_ROOT_DIR}/doc/hints/l10n/mc.hint.*
  32. # Remove extra line breaks
  33. for fn in ${MC_SOURCE_ROOT_DIR}/doc/hints/l10n/mc.hint.*; do
  34. awk '/^$/ { print "\n"; } /./ { printf("%s ", $0); } END { print; }' $fn > $fn.tmp
  35. sed -e 's/[[:space:]]*$//' < $fn.tmp > $fn
  36. perl -i -0pe 's/\n+\Z/\n/' $fn
  37. rm $fn.tmp
  38. done
  39. }
  40. #*** main code *********************************************************
  41. WORK_DIR=$(initSyncDirIfNeeded "mc.hint")
  42. receiveTranslationsFromTransifex "${WORK_DIR}"
  43. createPo4A "mc.hint"
  44. convertFromPoToText "${WORK_DIR}" "mc.hint"
  45. processHintFiles