Source files of fsfe.org, pdfreaders.org, freeyourandroid.org, ilovefs.org, drm.info, and test.fsfe.org. Contribute: https://fsfe.org/contribute/web/
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.

translation-log.sh 10.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. #!/bin/bash
  2. # This script is called by build.sh to create the translation log html
  3. # files from the translations.log file created by build.pl.
  4. #
  5. # Copyright (C) 2005 Free Software Foundation Europe
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful, but
  13. # WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. # General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  20. # 02111-1307, USA.
  21. # -----------------------------------------------------------------------------
  22. # Constants
  23. # -----------------------------------------------------------------------------
  24. srcroot="http://www.fsfe.org/source"
  25. cvsroot="https://trac.fsfe.org/fsfe-web/log/trunk"
  26. # -----------------------------------------------------------------------------
  27. # Parameters
  28. # -----------------------------------------------------------------------------
  29. infile=$1
  30. outdir=$2
  31. # -----------------------------------------------------------------------------
  32. # Create a separate file per language
  33. # -----------------------------------------------------------------------------
  34. # Remove all "./" at the beginning of filenames, and create a separate file per
  35. # language. For missing translations, remove all files mentioned in
  36. # translation-ignore.txt.
  37. # Performance seems to be much better if we do it in 2 separate runs.
  38. # Otherwise, we would have to run the grep for each line of the file.
  39. # First run: missing translations
  40. sort "${infile}" \
  41. | uniq \
  42. | sed --expression='s/\.\///g' \
  43. | grep --invert-match --file="tools/translation-ignore.txt" \
  44. | while read language wantfile havefile; do
  45. if [ ! -f "${wantfile}" ]; then
  46. date="$(date --iso-8601 --reference=${havefile})"
  47. echo "missing ${date} ${wantfile} NONE ${havefile}" >> "${infile}.${language}"
  48. fi
  49. done
  50. # Second run: outdated translations
  51. sort "${infile}" \
  52. | uniq \
  53. | sed --expression='s/\.\///g' \
  54. | while read language wantfile havefile; do
  55. if [ -f "${wantfile}" ]; then
  56. date1="$(date --iso-8601 --reference=${wantfile})"
  57. date2="$(date --iso-8601 --reference=${havefile})"
  58. echo "outdated ${date2} ${wantfile} ${date1} ${havefile}" >> "${infile}.${language}"
  59. fi
  60. done
  61. # -----------------------------------------------------------------------------
  62. # Convert the ASCII files to HTML files
  63. # -----------------------------------------------------------------------------
  64. for file in ${infile}.*; do
  65. language=${file##*.}
  66. (
  67. echo "<!doctype html>"
  68. echo "<html>"
  69. echo " <head>"
  70. echo " <meta charset=\"utf-8\" />"
  71. echo " <title>Translation status for ${language}</title>"
  72. echo " </head>"
  73. echo " <body>"
  74. echo " <h1>Translation status for ${language}</h1>"
  75. echo " <p>"
  76. echo " <a href=\"translations.html\">« Back to <em>Translation status overview</em></a>"
  77. echo " </p>"
  78. lastgroup=""
  79. sort --reverse ${file} | while read group date2 wantfile date1 havefile; do
  80. if [ "${group}" != "${lastgroup}" ]; then
  81. if [ "${group}" == "outdated" ]; then
  82. echo " <h2>Outdated translations</h2>"
  83. echo " <p>"
  84. echo " The following pages are already translated. However, the"
  85. echo " original version has been changed since the translation"
  86. echo " was done, and the translation has not been updated so far"
  87. echo " to reflect these changes."
  88. echo " </p>"
  89. echo " <p>"
  90. echo " Updating these translations is generally considered more"
  91. echo " urgent than translating new pages."
  92. echo " </p>"
  93. echo " <table border=\"1\" cellspacing=\"0\" cellpadding=\"3\">"
  94. echo " <tr>"
  95. echo " <th colspan=\"3\">translated file</th>"
  96. echo " <th colspan=\"3\">original file</th>"
  97. echo " </tr>"
  98. elif [ "${group}" == "missing" ]; then
  99. if [ "${lastgroup}" == "outdated" ]; then
  100. echo " </table>"
  101. fi
  102. echo " <h2>Missing translations</h2>"
  103. echo " <p>"
  104. echo " The following pages have not yet been translated."
  105. echo " </p>"
  106. echo " <p>"
  107. echo " This list is ordered by the date of the original version,"
  108. echo " newest first. Generally, it's a good idea to translate"
  109. echo " newer texts before older ones, as people will probably be"
  110. echo " more interested in current information."
  111. echo " </p>"
  112. echo " <table border=\"1\" cellspacing=\"0\" cellpadding=\"3\">"
  113. echo " <tr>"
  114. echo " <th>translated file</th>"
  115. echo " <th>original file</th>"
  116. echo " <th align=\"center\">last change of original</th>"
  117. echo " </tr>"
  118. fi
  119. lastgroup="${group}"
  120. fi
  121. echo " <tr>"
  122. if [ "${group}" = "outdated" ]; then
  123. echo " <td>"
  124. echo " <a href=\"${srcroot}/${wantfile}\">${wantfile}</a>"
  125. echo " </td>"
  126. echo " <td align=\"center\">${date1}</td>"
  127. echo " <td>"
  128. echo " <a href=\"${cvsroot}/${wantfile}\">[changelog]</a>"
  129. echo " </td>"
  130. echo " <td>"
  131. echo " <a href=\"${srcroot}/${havefile}\">${havefile}</a>"
  132. echo " </td>"
  133. echo " <td align=\"center\">${date2}</td>"
  134. echo " <td>"
  135. echo " <a href=\"${cvsroot}/${havefile}\">[changelog]</a>"
  136. echo " </td>"
  137. else
  138. echo " <td>"
  139. echo " ${wantfile}"
  140. echo " </td>"
  141. echo " <td>"
  142. echo " <a href=\"${srcroot}/${havefile}\">${havefile}</a>"
  143. echo " </td>"
  144. echo " <td align=\"center\">${date2}</td>"
  145. fi
  146. echo " </tr>"
  147. done
  148. if [ "${lastgroup}" != "" ]; then
  149. echo " </table>"
  150. fi
  151. echo " </body>"
  152. echo "</html>"
  153. ) > $outdir/$language.html
  154. done
  155. # -----------------------------------------------------------------------------
  156. # Create hit parade of outdated translations
  157. # -----------------------------------------------------------------------------
  158. grep --no-filename "^outdated" ${infile}.* \
  159. | sort --key=2 \
  160. | (
  161. echo "<!doctype html>"
  162. echo "<html>"
  163. echo " <head>"
  164. echo " <meta charset=\"utf-8\" />"
  165. echo " <title>Hit parade of outdated translations</title>"
  166. echo " <style>"
  167. echo " table,"
  168. echo " th,"
  169. echo " td {"
  170. echo " border: 1px outset gray;"
  171. echo " }"
  172. echo " th,"
  173. echo " td {"
  174. echo " padding: 3px;"
  175. echo " }"
  176. echo " </style>"
  177. echo " </head>"
  178. echo " <body>"
  179. echo " <h1>Hit parade of outdated translations</h1>"
  180. echo " <p>"
  181. echo " <a href=\"translations.html\">« Back to <em>Translation status overview</em></a>"
  182. echo " </p>"
  183. echo " <table>"
  184. echo " <tr>"
  185. echo " <th colspan=\"3\">translated file</th>"
  186. echo " <th colspan=\"3\">original file</th>"
  187. echo " </tr>"
  188. while read group date2 wantfile date1 havefile; do
  189. echo " <tr>"
  190. echo " <td>"
  191. echo " <a href=\"${srcroot}/${wantfile}\">${wantfile}</a>"
  192. echo " </td>"
  193. echo " <td align=\"center\">${date1}</td>"
  194. echo " <td>"
  195. echo " <a href=\"${cvsroot}/${wantfile}\">[changelog]</a>"
  196. echo " </td>"
  197. echo " <td>"
  198. echo " <a href=\"${srcroot}/${havefile}\">${havefile}</a>"
  199. echo " </td>"
  200. echo " <td align=\"center\">${date2}</td>"
  201. echo " <td>"
  202. echo " <a href=\"${cvsroot}/${havefile}\">[changelog]</a>"
  203. echo " </td>"
  204. done
  205. echo " </tr>"
  206. echo " </table>"
  207. echo " </body>"
  208. echo "</html>"
  209. ) > $outdir/outdated.html
  210. # -----------------------------------------------------------------------------
  211. # Create the overview page
  212. # -----------------------------------------------------------------------------
  213. (
  214. echo "<!doctype html>"
  215. echo "<html>"
  216. echo " <head>"
  217. echo " <meta charset=\"utf-8\" />"
  218. echo " <title>Translation status overview</title>"
  219. echo " <style>"
  220. echo " table,"
  221. echo " th,"
  222. echo " td {"
  223. echo " border: 1px outset gray;"
  224. echo " }"
  225. echo " th,"
  226. echo " td {"
  227. echo " padding: 3px;"
  228. echo " text-align: center;"
  229. echo " }"
  230. echo " </style>"
  231. echo " </head>"
  232. echo " <body>"
  233. echo " <h1>Translation status overview</h1>"
  234. echo " <p>"
  235. echo " <a href=\"http://status.fsfe.org/\">« Back to <em>Web server status</em></a>"
  236. echo " </p>"
  237. echo " <table>"
  238. echo " <tr>"
  239. echo " <th>language</td>"
  240. echo " <th>outdated translations</td>"
  241. echo " <th>missing translations</td>"
  242. echo " </tr>"
  243. for file in ${infile}.*; do
  244. language=${file##*.}
  245. outdated=$(grep "^outdated" ${file} | wc --lines)
  246. missing=$(grep "^missing" ${file} | wc --lines)
  247. echo " <tr>"
  248. echo " <td><a href=\"${language}.html\">${language}</a></td>"
  249. echo " <td>${outdated}</td>"
  250. echo " <td>${missing}</td>"
  251. echo " </tr>"
  252. done
  253. echo " </table>"
  254. echo " <p>"
  255. echo " A <a href=\"outdated.html\">hit parade of outdated translations</a>"
  256. echo " for all languages is also available."
  257. echo " </p>"
  258. echo " </body>"
  259. echo "</html>"
  260. ) > $outdir/translations.html