Wesnoth localization tools
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.

144 lines
3.7KB

  1. #!/bin/bash
  2. # Update translations from subversion repository and merge them
  3. # Copyright (C) 2007-2008 Andrius Štikonas <stikonas@gmail.com>
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (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. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. source variables
  18. if [ ! $SVN ]; then
  19. echo -e "\E[31mThis program needs the svn utility."; tput sgr0
  20. exit 1
  21. fi
  22. if [ ! $MSGFMT ]; then
  23. echo -e "\E[31mThis program needs the msgfmt utility."; tput sgr0
  24. exit 1
  25. fi
  26. if [ ! $MSGMERGE ]; then
  27. echo -e "\E[31mThis program needs the msgmerge utility."; tput sgr0
  28. exit 1
  29. fi
  30. if [ ! $MSGINIT ]; then
  31. echo -e "\E[31mThis program needs the msginit utility."; tput sgr0
  32. exit 1
  33. fi
  34. if [ $GIT -eq 1 ] && [ ! $GITSVN ]; then
  35. echo -e "\E[31mgit-svn is unavailable. svn will be used."; tput sgr0
  36. GIT=0
  37. fi
  38. if [ $GIT -eq 1 ] && [ $GITSVN ]; then
  39. SVN="$GITSVN clone"
  40. fi
  41. echo -e "Language: \E[31m$LCODE"; tput sgr0
  42. echo ""
  43. if [ ! -z $TRUNK ]; then
  44. if [ -e $TRUNK/.git ] || [ -e $TRUNK/.svn ]; then
  45. echo -e "Updating repository: \E[34mtrunk"
  46. cd $TRUNK
  47. if [ $GIT -eq 1 ]; then
  48. $GITSVN fetch
  49. $GITSVN rebase
  50. else
  51. $SVN update
  52. fi
  53. cd ..
  54. else
  55. echo -e "Downloading repository: \E[34mtrunk"
  56. if [ $GIT -eq 1 ]; then
  57. SVN="$GITSVN clone"
  58. else
  59. SVN="$SVN checkout"
  60. fi
  61. $SVN "$REPO/$TRUNK/po" $TRUNK
  62. fi
  63. tput sgr0
  64. if [ ! -e "$PREFIX-$TRUNK" ]; then
  65. mkdir "$PREFIX-$TRUNK"
  66. fi
  67. fi
  68. for BRANCH in $BRANCHES; do
  69. if [ -e $BRANCH/.git ] || [ -e $BRANCH/.svn ]; then
  70. echo -e "Updating repository: \E[34m$BRANCH"
  71. cd $BRANCH
  72. if [ $GIT -eq 1 ]; then
  73. $GITSVN fetch
  74. $GITSVN rebase
  75. else
  76. $SVN update
  77. fi
  78. cd ..
  79. else
  80. echo -e "Downloading repository: \E[34m$BRANCH"
  81. if [ $GIT -eq 1 ]; then
  82. SVN="$GITSVN clone"
  83. else
  84. SVN="$SVN checkout"
  85. fi
  86. $SVN "$REPO/branches/$BRANCH/po" $BRANCH
  87. fi
  88. tput sgr0
  89. if [ ! -e "$PREFIX-$BRANCH" ]; then
  90. mkdir "$PREFIX-$BRANCH"
  91. fi
  92. done
  93. for BRANCH in $TRUNK $BRANCHES; do
  94. SVNDIR=$BRANCH
  95. DIR="$PREFIX-$BRANCH"
  96. echo -e "Merging: \E[34m$BRANCH"; tput sgr0
  97. for dir in `ls $SVNDIR/wesnoth* -d`; do
  98. echo "Processing "`basename $dir`"."$LCODE".po"
  99. stat=`LC_MESSAGES=C $MSGFMT --statistics -o /dev/null $dir"/"$LCODE".po" 2>&1`
  100. u=`echo "$stat" | sed -ne 's/.* \([0-9]\+\) untranslated .*/\1/p'`; u=${u:-0}
  101. f=`echo "$stat" | sed -ne 's/.* \([0-9]\+\) fuzzy translation.*/\1/p'`; f=${f:-0}
  102. file=$DIR"/"`basename $dir`"."$LCODE".po"
  103. if [ -f $dir"/"$LCODE".po" ]; then
  104. if [ $(($u+$f)) == 0 ]; then
  105. echo -e "\E[32mFile is translated."; tput sgr0
  106. if [ -f $DIR"/"`basename $dir`"."$LCODE".po" ]; then
  107. echo -e "\E[32mRemoving from $DIR."; tput sgr0
  108. rm -f $file
  109. fi
  110. else
  111. if [ -f "$DIR/"`basename $dir`".$LCODE.po" ]; then
  112. echo -e "\E[34mMerging:"; tput sgr0
  113. $MSGMERGE -U -v $file $dir"/"`basename $dir`".pot"
  114. rm -f $file~
  115. else
  116. echo -e "\E[31mCopying:"; tput sgr0
  117. cp $dir"/"$LCODE".po" $file
  118. fi
  119. fi
  120. else
  121. if [ ! -f $file ]; then
  122. echo -e "\E[31mNo po file in repository. Running msginit."; tput sgr0
  123. echo "$dir"
  124. $MSGINIT -i "$dir/`basename $dir`.pot" -o $file
  125. else
  126. echo -e "\E[31mNo po file in repository. Found file in workspace."; tput sgr0
  127. fi
  128. fi
  129. echo ""
  130. done
  131. done
  132. echo -ne "\E[32mFinished."; tput sgr0; echo " "