[!!!][TASK] Drop core 6->7 auto TCA migrations
[Packages/TYPO3.CMS.git] / Build / Scripts / xlfcheck.sh
1 #!/bin/bash
2
3 #########################
4 #
5 # Find all xmlns:t3 namespace definition and
6 # t3:id numbers in XLF language files
7 # and check their uniqueness.
8 #
9 # It expects to be run from the core root.
10 #
11 ##########################
12
13 XLF_FILES="xlffiles.txt"
14 XLF_IDS="xlfids.txt"
15 XLF_XMLNS="xlfxmlns.txt"
16
17 function join { local IFS="$1"; shift; echo "$*"; }
18
19 echo 'Collecting XLF files'
20 find typo3/ -name '*.xlf' > $XLF_FILES
21 XLFCNT=$(cat xlffiles.txt | wc -l)
22
23 # Check for xmlns
24 echo 'Extracting xmlns:t3 information'
25 sed -ne 's/.*\(xmlns:t3="http:\/\/typo3.org\/schemas\/xliff"\)/\1/pg' `cat $XLF_FILES` | sort > $XLF_XMLNS
26 XLFXMLNSCNT=$(cat $XLF_XMLNS | wc -l)
27 DIFFXMLNS=$(join , $(uniq -d $XLF_XMLNS))
28 MISSINGXMLNS=$(join , $(grep -L 'xmlns:t3="http://typo3.org/schemas/xliff"' `cat $XLF_FILES`))
29
30 # Checks for t3:id
31 echo 'Extracting t3:id information'
32 sed -ne 's/.*t3:id="\([0-9]\+\)".*/\1/pg' `cat $XLF_FILES` | sort > $XLF_IDS
33
34 echo 'Processing ids'
35 XLFIDCNT=$(cat $XLF_IDS | wc -l)
36 UXLFIDCNT=$(uniq $XLF_IDS | wc -l)
37 DIFFIDS=$(join , $(uniq -d $XLF_IDS))
38 MISSINGIDS=$(join , $(grep -L 't3:id' `cat $XLF_FILES`))
39
40 # Cleanup of temporary files
41 rm $XLF_IDS $XLF_FILES $XLF_XMLNS
42
43 if [ $XLFCNT -ne $XLFXMLNSCNT ];
44 then
45 echo "There is at least one XLF file missing a xmlns for t3 (xmlns:t3)."
46 echo "Missing in: $MISSINGXMLNS"
47 exit 1
48 fi
49
50 if [ $XLFCNT -ne $XLFIDCNT ];
51 then
52 echo "There is at least one XLF file missing a unique ID (t3:id)."
53 echo "Missing in: $MISSINGIDS"
54 exit 1
55 fi
56 if [ $XLFIDCNT -ne $UXLFIDCNT ];
57 then
58 echo "There is an XLF id that does not seem to be UNIQUE."
59 echo "Search for t3:id $DIFFIDS"
60 exit 1
61 fi
62
63 exit 0