website annotate lib/i18n-info.sh @ rev 1344

Resize balinor logo to 120px
author Christophe Lincoln <pankso@slitaz.org>
date Fri Jan 22 23:02:15 2021 +0100 (2021-01-22)
parents e1d9fe4a2b36
children
rev   line source
al@1089 1 #!/bin/sh
al@1089 2
al@1089 3 # for english po statistics using `msgfmt --statistics`
al@1089 4 LC_ALL=C; export LC_ALL
al@1089 5
al@1089 6 HG_URL="http://hg.slitaz.org"
al@1089 7 INFO_FILE="/var/cache/slitaz/website/i18n.html"
al@1089 8 mkdir -p "/var/cache/slitaz/website"
al@1089 9 touch "${INFO_FILE}.new"
al@1089 10 echo "" > "${INFO_FILE}.new"
al@1089 11
al@1089 12 # echo to file
al@1089 13 echof()
al@1089 14 {
al@1089 15 echo "$@" >> "${INFO_FILE}.new"
al@1089 16 }
al@1089 17
al@1089 18 # print table cells with 'pot' and 'po's
al@1089 19 out_pot_po()
al@1089 20 {
al@1089 21 TMP_PO="/tmp/i18n.po"
al@1089 22 # get all links to files in folder
al@1089 23 LINKS=$(wget "$HG_URL/$PROJ_BASE/$PROJ_PODIR/" -q -O - | \
al@1089 24 grep -A 1 "filename" | \
al@1089 25 grep "href" | \
al@1089 26 sed 's|.*"\([^"]*\)".*|http://hg.slitaz.org\1|g' | \
al@1089 27 sed 's|/file/[^/]*/|/raw-file/tip/|g')
al@1089 28 # get link to 'pot' and print cell
al@1089 29 LINK_POT=$(echo "$LINKS" | grep -e '\.pot$')
al@1089 30
al@1089 31 echof "
al@1089 32 <td class=\"pot\">
al@1089 33 <a href=\"$LINK_POT\">
al@1089 34 $(echo $LINK_POT | sed 's|.*/\([^/]*\.pot\)$|\1|')</a></td>
al@1089 35 <td class=\"po\">"
al@1089 36
al@1089 37 # process 'po's
al@1089 38 IFS="
al@1089 39 "
al@1089 40 for FILE in $(echo "$LINKS" | grep -e '.po$'); do
al@1089 41 # temp download
al@1089 42 wget $FILE -q -O $TMP_PO
al@1089 43 # get stats
al@1089 44 STAT=$(msgfmt --statistics $TMP_PO 2>&1 | sed 's|[^0-9 ]||g')
al@1089 45 rm $TMP_PO
al@1089 46 # language; number of translated and untranslated entries
al@1089 47 LNG=$(echo $FILE | sed 's|.*/\([^/]*\)\.po$|\1|')
al@1089 48 TRAN=$(echo $STAT | cut -d" " -f1)
al@1089 49 UNTR=$(($(echo $STAT | awk '{print $2}') + 0))
al@1089 50 # percents done
al@1089 51 PCNT=$(($TRAN * 100 / ($TRAN + $UNTR)))
al@1089 52 echof " <a href=\"$FILE\">$LNG<hr/>${PCNT}%</a>"
al@1089 53 done
al@1089 54 echof " </td>"
al@1089 55 }
al@1089 56
al@1089 57
al@1089 58 # print table cell with html documentations
al@1089 59 out_doc()
al@1089 60 {
al@1089 61 # get all links to files in folder
al@1089 62 LINKS=$(wget "$HG_URL/$PROJ_BASE/$PROJ_DOCDIR/" -q -O - | \
al@1089 63 grep -A 1 "filename" | \
al@1089 64 grep "href" | \
al@1089 65 sed 's|.*"\([^"]*\)".*|http://hg.slitaz.org\1|g' | \
al@1089 66 sed 's|/file/[^/]*/|/raw-file/tip/|g')
al@1089 67
al@1089 68 echof " <td class=\"docs\">"
al@1089 69
al@1089 70 IFS="
al@1089 71 "
al@1089 72 # get name of subproject, example: subproject 'tazusb-box' from 'tazusb'
al@1089 73 SUB_PROJ=$(echo "$PROJ_PODIR" | sed 's|.*/\(.*\)|\1|')
al@1089 74 for DOCUMENT in $(echo "$LINKS" | grep -e '.html$'); do
al@1089 75 # strip project and subproject names from doc filename
al@1089 76 NAME_DOC=$(echo $DOCUMENT | \
al@1089 77 sed 's|.*/\([^/]*\)\.html$|\1|' | \
al@1089 78 sed 's|'$PROJ_BASE'\.||; s|'$SUB_PROJ'\.||')
al@1089 79 # first part of filename, example faq.en -> faq
al@1089 80 NAME_DOC1=$(echo $NAME_DOC | cut -d"." -f1)
al@1089 81 # second part of filename, faq.en -> en
al@1089 82 NAME_DOC2=$(echo $NAME_DOC | cut -d"." -f2)
al@1089 83 # if filename have only [lang] then rename it to doc.[lang]
pascal@1330 84 if [ "$NAME_DOC1" = "$NAME_DOC2" ]; then
al@1089 85 NAME_DOC1="doc"
al@1089 86 fi
al@1089 87 # not print 'linked' common documents, only localized ones
al@1089 88 # (often link [project].html pointed to [project].en.html)
al@1089 89 if [ "$NAME_DOC" != "$SUB_PROJ" ] && [ "$NAME_DOC" != "$PROJ_BASE" ]; then
al@1089 90 echof " <a href=\"$DOCUMENT\">$NAME_DOC1<br/>$NAME_DOC2</a>"
al@1089 91 fi
al@1089 92 done
al@1089 93 echof " </td>"
al@1089 94 }
al@1089 95
al@1089 96
al@1089 97 # print table cell with link to .desktop files
al@1089 98 out_app()
al@1089 99 {
al@1089 100 APP_DIR="$HG_URL/$PROJ_BASE/file/tip/$PROJ_APPDIR"
al@1089 101 PAGE=$(wget $APP_DIR -q -O -)
al@1089 102 LINKS=$(echo "$PAGE" | grep -A 1 "filename" | grep "href" | wc -l)
al@1089 103 # plural form
pascal@1330 104 if [ "$LINKS" = "1" ]; then
al@1089 105 APP_TEXT="1<br/>item"
al@1089 106 else
al@1089 107 APP_TEXT="$LINKS<br/>items"
al@1089 108 fi
al@1089 109
al@1089 110 # rowspan: folder with desktop files is one for project
al@1089 111 # combine all subprojects
al@1089 112 echof " <td class=\"desk\"$ROWSPAN><a href=\"$APP_DIR\">$APP_TEXT</a></td>"
al@1089 113 }
al@1089 114
al@1089 115
al@1089 116
al@1089 117 # standard path to folder with 'pot' and 'po's
al@1089 118 S="file/tip/po"
al@1089 119 # standard path to doc folder
al@1089 120 D="file/tip/doc"
al@1089 121
al@1089 122 # list of all processed projects; fields description:
al@1089 123 # [1]: Human readable project name (once)
al@1089 124 # [2]: Project base: http://hg.slitaz.org/[2]
al@1089 125 # [3]: Spanned cells (number or empty)
al@1089 126 # [4]: Pot&po folder: http://hg.slitaz.org/[2]/[4]/
al@1089 127 # [5]: Docs folder: http://hg.slitaz.org/[2]/[5]/
al@1089 128 # [6]: Apps folder: http://hg.slitaz.org/[2]/file/tip/[6]/
al@1089 129 PROJ_LIST="
al@1089 130 SliTaz Base Files|slitaz-base-files||$S||rootfs/usr/share/applications
al@1089 131 pkgs.slitaz.org|slitaz-forge/file/tip/pkgs||po||
al@1089 132 SliTaz Pizza|slitaz-pizza||$S|$D|
al@1168 133 SliTaz Tools|slitaz-tools|4|$S/slitaz-boxes||applications
al@1089 134 |slitaz-tools||$S/slitaz-tools||
al@1089 135 |slitaz-tools||$S/tazbox||
al@1089 136 |slitaz-tools||$S/tazdrop||
al@1291 137 SSFS|ssfs|2|$S/ssfs-server||data
al@1089 138 |ssfs||$S/ssfs||
al@1089 139 TazBug|tazbug||$S||data
al@1291 140 TazLito|tazlito||$S|$D|applications
al@1089 141 TazPanel|tazpanel||$S|$D|data
al@1168 142 TazPkg|tazpkg||$S|$D|applications
al@1089 143 TazUsb|tazusb|2|$S/tazusb|$D|applications
al@1168 144 |tazusb||$S/tazusb-box||
al@1168 145 TazInst|tazinst|3|$S/installer||applications
al@1168 146 |tazinst||$S/slitaz-installer||
al@1168 147 |tazinst||$S/tazinst|$D|
al@1168 148 TazWeb|tazweb||$S|$D|data
al@1291 149 TazIRC|tazirc||$S||data
al@1168 150 CookUtils|cookutils||$S|$D|data
al@1291 151 SliTaz boot scripts|slitaz-boot-scripts||||usr/share/applications
al@1291 152 SliTaz Configs|slitaz-configs|3|$S||rootfs/usr/share/applications
al@1168 153 |slitaz-configs||||rootfs/etc/xdg/openbox
al@1168 154 |slitaz-configs||||rootfs/usr/share/webhome
al@1168 155 SliTaz Doc|slitaz-doc|||slitaz|applications"
al@1089 156
al@1089 157 # print table header
al@1089 158 echof "
al@1089 159 <table>
al@1089 160 <thead class=\"thead\">
al@1089 161 <tr><td>Project</td>
al@1089 162 <td>POT file</td>
al@1089 163 <td>PO files</td>
al@1089 164 <td>Docs</td>
al@1089 165 <td>Menu</td>
al@1089 166 </tr>
al@1089 167 </thead>
al@1089 168 <tbody>"
al@1089 169
al@1089 170
al@1089 171 # main loop
al@1089 172 IFS="
al@1089 173 "
al@1089 174 for PROJECT in $PROJ_LIST
al@1089 175 do
al@1089 176 IFS="|"
al@1089 177 echo "$PROJECT" | while read P_NAME PROJ_BASE P_SPAN PROJ_PODIR PROJ_DOCDIR PROJ_APPDIR
al@1089 178 do
al@1089 179 if [ -n "$P_SPAN" ]; then
al@1089 180 ROWSPAN=" rowspan=\"$P_SPAN\""
al@1089 181 else
al@1089 182 ROWSPAN=""
al@1089 183 fi
al@1089 184
al@1089 185 echof -n " <tr>"
al@1089 186
al@1089 187 if [ -n "$P_NAME" ]; then
al@1089 188 echof "<td$ROWSPAN class=\"proj\">
al@1089 189 <a href=\"http://hg.slitaz.org/$PROJ_BASE\">$P_NAME</a></td>"
al@1089 190 else
al@1089 191 echof "<!-- td -->"
al@1089 192 fi
al@1089 193
al@1089 194 # unconditional out pot and po
al@1089 195 out_pot_po
al@1089 196
al@1089 197 # out doc if exists
al@1089 198 if [ -n "$PROJ_DOCDIR" ]; then
al@1089 199 out_doc
al@1089 200 else
al@1089 201 echof " <td class=\"docs\">&nbsp;</td>"
al@1089 202 fi
al@1089 203
al@1089 204 # out apps if exists
al@1089 205 if [ -n "$PROJ_APPDIR" ]; then
al@1089 206 out_app
al@1089 207 elif [ -n "$P_NAME" ]; then
al@1089 208 echof " <td class=\"desk\">&nbsp;</td>"
al@1089 209 fi
al@1089 210
al@1089 211
al@1089 212 echof " </tr>"
al@1089 213
al@1089 214 IFS="
al@1089 215 "
al@1089 216 done
al@1089 217 done
al@1089 218
al@1089 219 echof " </tbody>
al@1089 220 </table>
al@1154 221 <p>Updated: $(date '+%B %d, %Y @ %H:%M')</p>"
al@1089 222
al@1089 223 mv "${INFO_FILE}.new" "$INFO_FILE"
al@1089 224 # the end