l10n-support/ca/scripts

Antoni Bella PĂ©rez null at kde.org
Tue Jun 5 14:46:22 UTC 2018


SVN commit 1517233 by bellaperez:

Catalan works: This script search outdated (or missing) screenshots within the translations
  - More functions
  - Output improvements
  ** Now, it works!

CCMAIL: kde-i18n-ca at kde.org

 M  +43 -30    doc_parse_dates.sh  


--- trunk/l10n-support/ca/scripts/doc_parse_dates.sh #1517232:1517233
@@ -2,37 +2,26 @@
 #
 # The goal is parse screenshots date changes in KDE tranlations.
 #  - kio-extras is problematic
-#  - Missing server query
-#  - Time screenshot file must be analyzed
+#  - trunk and kf5 only
+#  - working fine ;-)
 # ...
 
-LANGCODE='ca'
-REPO="https://cgit.kde.org"
+LANGCODE="$LANGUAGE" # 'ca' code for Catalan
+GITREPO="https://cgit.kde.org"
+SVNREPO="svn://anonsvn.kde.org"
 
-git_log() { wget $REPO/konsole.git/log/doc/manual/draganddrop-contextmenu.png; }
-
-parse_date() {
-  DATE_L=$()
-  HOUR_L=$()
-  DATE_R=$()
-  HOUR_R=$()
-
-  if [ $DATE_L -gt $DATE_R ]; then
-        echo
-  fi
-}
-
 header_table() {
             echo -e "\n    Screenshot name                                      Git date      Local date"
-            echo "  |--------------------------------------------------|--------------|--------------|"
+            echo "  |--------------------------------------------------|---------------|---------------|"
 }
 
 footer_table() {
-            echo -e "  |--------------------------------------------------|--------------|--------------|\n"
+            echo -e "  |--------------------------------------------------|---------------|---------------|\n"
 }
 
 found_ss() { ls documentation/$MODULE/$DOCDIR/{*.jpg,*.png} 2>/dev/null | head -1; }
 
+MODULE0=""
 # Search folders created with DocBook files that are in the repo translations.
 for docdir in $(find $LANGCODE/docs/* -type f -name *.docbook | xargs dirname | sort | uniq)
   do
@@ -39,7 +28,11 @@
     MODULE=$(dirname $docdir | cut -f 3 -d'/')          # applications
     DOCDIR0=$(dirname $docdir | cut -f 4 -d'/')         # kioslave, kcontrol5 or kioslave5
     DOCDIR=$(basename $docdir)                          # keditbookmarks
-    test "$MODULE" = "calligra" && exit 0               # NOTE: Uncomment for testing over 'applications' module only
+    if [ -n $MODULE0 ];then
+        [ "$MODULE" != "$MODULE0" ] && read -p "'$MODULE' be parsed: Are you sure? Y/y or N/n: " && [[ $REPLY =~ ^[Nn]$ ]] && exit 0
+    fi
+    MODULE0="$MODULE"
+
     # wacomtablet, gopher, gdrive, kcm_ssl, kcron, kamera, cddbretrieval5, audiocd
     # blockdevices, desktop, kgamma5, khotkeys, kwindecoration, kwineffects, kwinscreenedges
     # kwintabbox, plasma-pa, powerdevil, screenlocker, windowbehaviour, windowspecific
@@ -48,7 +41,7 @@
         DOCDIR=$(echo "$GITDIR" | cut -f 2 -d' ')
     # calligra
     elif [[ "$DOCDIR" = +(calligra|sheets|stage) ]]; then
-        GITDIR="$REPO/calligra.git HEAD:doc/$DOCDIR"
+        GITDIR="$GITREPO/calligra.git HEAD:doc/$DOCDIR"
         DOCDIR=$(echo "$GITDIR" | cut -f 3 -d':' | sed -e 's/doc\///')
     # plasma-sdk
     elif [[ "$DOCDIR" = +(engineexplorer|plasmoidviewer) ]]; then
@@ -56,29 +49,29 @@
         DOCDIR=$(echo "$GITDIR" | cut -f 2 -d' ')
     # plasma-desktop
     elif [[ "$DOCDIR" = +(autostart|baloo|clock|colors|componentchooser|cursortheme|desktopthemedetails|emoticons|fontinst|fonts|formats|icons|joystick|kcmaccess|kcmlaunchfeedback|kcmnotify|kcmsmserver|kcmstyle|kded|keyboard|keys|mouse|paths|phonon|solid-actions|solid-device-automounter|spellchecking|splashscreen|translations|workspaceoptions) ]]; then
-        GITDIR="$REPO/plasma-desktop.git HEAD:doc/kcontrol/$DOCDIR"
+        GITDIR="$GITREPO/plasma-desktop.git HEAD:doc/kcontrol/$DOCDIR"
                 DOCDIR=$(echo "$GITDIR" | cut -f 3 -d':' | sed -e 's/doc\///')
     # konqueror - kcontrol5
     elif   [[ "$DOCDIR" = +(bookmarks|filemanager|history|kcmcss|khtml-adblock|khtml-behavior|khtml-general|khtml-java-js|performance) ]]; then
-        GITDIR="$REPO/konqueror.git HEAD:doc/kcontrol5/$DOCDIR"
+        GITDIR="$GITREPO/konqueror.git HEAD:doc/kcontrol5/$DOCDIR"
         DOCDIR=$(echo "$GITDIR" | cut -f 3 -d':' | sed -e 's/doc\///')
     # kio
     elif [[ "$DOCDIR" = +(cache|cookies|netpref|proxy|smb|trash|useragent|webshortcuts) ]]; then
         [ "$DOCDIR" = "smb" ] && [ "$DOCDIR0" = "kioslave5" ] && continue
-        GITDIR="$REPO/kio.git HEAD:docs/kcontrol5/$DOCDIR"
+        GITDIR="$GITREPO/kio.git HEAD:docs/kcontrol5/$DOCDIR"
         DOCDIR=$(echo "$GITDIR" | cut -f 3 -d':' | sed -e 's/docs\///')
     elif   [[ "$DOCDIR" = +(data|file|ftp|help|documentationnotfound|http|mailto|telnet|webdav) ]]; then
-        GITDIR="$REPO/kio.git HEAD:docs/kioslave5/$DOCDIR"
-        test "$DOCDIR" = documentationnotfound && GITDIR="$REPO/kio.git HEAD:docs/kioslave5/help/$DOCDIR"
+        GITDIR="$GITREPO/kio.git HEAD:docs/kioslave5/$DOCDIR"
+        test "$DOCDIR" = documentationnotfound && GITDIR="$GITREPO/kio.git HEAD:docs/kioslave5/help/$DOCDIR"
         DOCDIR=$(echo "$GITDIR" | cut -f 3 -d':' | sed -e 's/docs\///')
     # kde-cli-tools
     elif [  "$DOCDIR" = "filetypes" ]; then
-        GITDIR="$REPO/kde-cli-tools.git HEAD:docs/kcontrol5/$DOCDIR"
+        GITDIR="$GITREPO/kde-cli-tools.git HEAD:docs/kcontrol5/$DOCDIR"
         DOCDIR=$(echo "$GITDIR" | cut -f 3 -d':' | sed -e 's/docs\///')
     # kio-extras
     elif [[ "$DOCDIR" = +(bookmarks|bzip2|fish|gzip|info|man|network|nfs|recentdocuments|sftp|smb|tar|thumbnail|xz) ]]; then
         [ "$DOCDIR" = "smb" ] && [ "$DOCDIR0" = "kcontrol5" ] && continue
-        GITDIR="$REPO/kio-extras.git HEAD:doc/kioslave5/$DOCDIR"
+        GITDIR="$GITREPO/kio-extras.git HEAD:doc/kioslave5/$DOCDIR"
         DOCDIR=$(echo "$GITDIR" | cut -f 3 -d':' | sed -e 's/doc\///')
     # ldap, pop3, sieve
     elif [[ "$DOCDIR" = +(ldap|pop3|sieve) ]]; then
@@ -88,7 +81,10 @@
         GITDIR=$(grep "^entry $DOCDIR " scripts/documentation_paths)
     fi
 
-    echo "** $docdir -> $GITDIR" # NOTE: If GITDIR var is empty, change above
+    [ -z $GITDIR ] && GITDIR="\e[0;31m** Solve GITDIR var! **\e[0m"
+    echo -e "** $docdir -> $GITDIR" # NOTE: If GITDIR var is empty, add or change above
+    # Var empty, not pparsed
+    [ -z $GITDIR ] && continue
     # Without screenshots, not parsed
     [ -z $(found_ss) ] && continue
 
@@ -98,8 +94,25 @@
         # Find item/s into documentation/'module'/'app' local dir
         for screenshot in $(find documentation/$MODULE/$DOCDIR/* -type f -name "*.png" -o -name "*.jpg")
           do
+            GITM=$(echo $GITDIR | awk '{print $3}' FS=".git" | cut -f 2 -d'/')
+            GITD=$(echo $GITDIR | awk '{print $2}' FS="HEAD:")
+            SCREENSHOT=$(filename $screenshot)
+            OUTPUT_FILE="$MODULE-$DOCDIR0$DOCDIR-$SCREENSHOT.html"
 
-            echo "  - $(filename $screenshot)"
+            # Git: date get from the svn web server (I do not know any other option within the KDE infrastructure)
+            wget --quiet --tries=100 --output-document=$OUTPUT_FILE $GITREPO/$GITM.git/log/$GITD/$SCREENSHOT
+            DATE_G=$(grep "^<tr\>" $OUTPUT_FILE | tail -n 1 | awk '{print $2}' FS="<td>" | tr -d '\-</td>')
+
+            # SVN: date get from nonsvn.kde.org (in the local file, it can be incorrect)
+            if [ -f $docdir/$SCREENSHOT ]; then
+                DATE_S=$(svn log $SVNREPO/home/kde/trunk/l10n-kf5/$docdir/$SCREENSHOT | grep "^r" | head -1 | awk '{print $5}' | tr -d '-')
+                [ $DATE_S -gt $DATE_G ] && DATE_S="\e[0;32m$DATE_S\e[0m" || DATE_S="\e[0;31m$DATE_S\e[0m"
+              else
+                DATE_S="\e[1;31mNot found!\e[0m  |"
+            fi
+
+            printf "%-63s %-15s %-15s \n" "  - $(echo -e "\e[0;36m$SCREENSHOT\e[0m")" "|   $DATE_G" "|   $(echo -e $DATE_S)"
+            rm -f $OUTPUT_FILE
           done
         [ -n $(found_ss) ] && footer_table
     fi


More information about the kde-i18n-ca mailing list