po-fromTransifex.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. stripLocation() {
  30. work_dir=$1; shift
  31. for i in $(find "${work_dir}" -name '*.po' -print); do
  32. sed -i '/^#:/d' "${i}"
  33. done
  34. }
  35. # ----------------------------------------------------------------------
  36. copyFilesToSourceDir() {
  37. work_dir=$1; shift
  38. source_dir=$1; shift
  39. exclude_list_file=$(getConfigFile "po" "po-ignore.list")
  40. for i in $(find "${work_dir}" -name '*.po' -print | sort); do
  41. [ $(grep -c "^\s*$(basename ${i})" "${exclude_list_file}") -ne 1 ] && {
  42. cp -f "${i}" "${source_dir}"
  43. }
  44. done
  45. }
  46. #*** main code *********************************************************
  47. WORK_DIR=$(initSyncDirIfNeeded "po")
  48. receiveTranslationsFromTransifex "${WORK_DIR}"
  49. stripLocation "${WORK_DIR}"
  50. copyFilesToSourceDir "${WORK_DIR}" "${MC_SOURCE_ROOT_DIR}/po"