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-test.sh 10KB

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