[TASK] Add XLF file checker for TRAVIS CI 29/34229/2
authorMarkus Klein <klein.t3@reelworx.at>
Fri, 14 Nov 2014 19:45:17 +0000 (20:45 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 15 Nov 2014 21:16:47 +0000 (22:16 +0100)
The script checks for the presence of a t3:id in the XLF files.
Moreover the uniqueness is verified.

Resolves: #62965
Releases: master, 6.2
Change-Id: I8a2514b31c1484988ef7add937502424f64ed1e4
Reviewed-on: http://review.typo3.org/34229
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
.travis.yml
typo3/sysext/core/Build/Scripts/xlfcheck.sh [new file with mode: 0644]

index 23b3074..87b1e04 100644 (file)
@@ -33,6 +33,7 @@ before_script:
     fi
   - echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
   - echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
+  - chmod a+x typo3/sysext/core/Build/Scripts/*
   - sudo apt-get install parallel
   - composer self-update
   - composer --dev install
@@ -58,3 +59,7 @@ script:
             exit 99;
         fi
     "
+  - >
+    echo;
+    echo "Running XLF checker";
+    ./typo3/sysext/core/Build/Scripts/xlfcheck.sh
diff --git a/typo3/sysext/core/Build/Scripts/xlfcheck.sh b/typo3/sysext/core/Build/Scripts/xlfcheck.sh
new file mode 100644 (file)
index 0000000..fd3c5ce
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+#########################
+#
+# Find all t3:id numbers in XLF language files
+# and check their uniqueness.
+#
+# @author Markus Klein <klein.t3@reelworx.at>
+# @date 2014-11-14
+#
+##########################
+
+function join { local IFS="$1"; shift; echo "$*"; }
+
+find typo3 -name '*.xlf' > xlffiles.txt
+sed -ne 's/.*t3:id="\([0-9]\+\)".*/\1/pgM' `cat xlffiles.txt` | sort > xlfids.txt
+uniq xlfids.txt > uxlfids.txt
+XLFCNT=$(cat xlffiles.txt | wc -l)
+XLFIDCNT=$(cat xlfids.txt | wc -l)
+UXLFIDCNT=$(cat uxlfids.txt | wc -l)
+DIFFIDS=$(join , $(uniq -d xlfids.txt))
+MISSINGIDS=$(join , $(grep -LP 't3:id' `cat xlffiles.txt`))
+rm xlfids.txt uxlfids.txt xlffiles.txt
+if [ $XLFCNT -ne $XLFIDCNT ];
+then
+       echo "There is at least one XLF file missing a unique ID (t3:id)."
+       echo "Missing in: $MISSINGIDS"
+       exit 1
+fi
+if [ $XLFIDCNT -ne $UXLFIDCNT ];
+then
+       echo "There is an XLF id that does not seem to be UNIQUE."
+       echo "Search for t3:id $DIFFIDS"
+       exit 1
+fi
+exit 0