Merge pull request #19552 from kamil-tekiela/Fix-default-values
[phpmyadmin.git] / bin / update-po
blob1a40fa25358629404922f6e173fa9c1b1b852636
1 #!/bin/sh
2 # vim: expandtab sw=4 ts=4 sts=4:
3 export LC_ALL=C
5 # Do not run as CGI
6 if [ -n "$GATEWAY_INTERFACE" ] ; then
7 echo 'Can not invoke as CGI!'
8 exit 1
9 fi
11 # Exit on failure
12 set -e
14 # Generate Twig template cache in clean dir
15 rm -rf twig-templates/
16 php bin/console cache:warmup --twig-po --env development
18 # Update pot (template), ensure that advisor is at the end
19 LOCS=$(find resources/po -name '*.po' | sed 's@.*/\(.*\)\.po@\1@')
21 find . -name '*.php' -not -path './tests/*' -not -path './resources/po/*' -not -path './tmp/*' -not -path './release/*' -not -path './node_modules/*' -not -path './vendor/*' > twig-templates/filesList
23 php ./bin/match-twig-cache
24 sort --dictionary-order --ignore-case --output ./twig-templates/filesListTemp < ./twig-templates/filesList
25 mv ./twig-templates/filesListTemp ./twig-templates/filesList
26 php ./bin/match-twig-cache --reverse
28 # Allows word splitting for files list.
29 # shellcheck disable=SC2046
30 xgettext \
31 -d phpmyadmin \
32 --msgid-bugs-address=translators@phpmyadmin.net \
33 -o resources/po/phpmyadmin.pot \
34 --language=PHP \
35 --add-comments=l10n \
36 --add-location \
37 --debug \
38 --from-code=utf-8 \
39 --keyword=__ --keyword=_gettext --keyword=_pgettext:1c,2 --keyword=_ngettext:1,2 \
40 --copyright-holder="phpMyAdmin devel team" \
41 $(cat ./twig-templates/filesList)
43 # Fixup filenames for Twig templates
44 php bin/console fix-po-twig
46 # Remote twig templates
47 rm -rf twig-templates/
49 # Keep in sync with create-release.sh
50 fetchReleaseFromFile() {
51 php -r "define('VERSION_SUFFIX', ''); require_once('src/Version.php'); echo \PhpMyAdmin\Version::VERSION;"
54 ver="$(fetchReleaseFromFile)"
56 sed -i.~ '
57 s/SOME DESCRIPTIVE TITLE/phpMyAdmin translation/;
58 s/PACKAGE/phpMyAdmin/;
59 s/(C) YEAR/(C) 2003 - '"$(date +%Y)"'/;
60 s/VERSION/'"$ver"'/;
61 ' resources/po/phpmyadmin.pot
63 # Update po files (translations)
64 for loc in $LOCS ; do
65 sed -i.~ '
66 s/SOME DESCRIPTIVE TITLE/phpMyAdmin translation/;
67 s/PACKAGE/phpMyAdmin/;
68 s/(C) YEAR/(C) 2003 - '"$(date +%Y)"'/;
69 s/VERSION/'"$ver"'/;
70 s/Project-Id-Version: phpMyAdmin .*/Project-Id-Version: phpMyAdmin '"$ver"'\\n"/;
71 ' resources/po/"$loc".po
72 msgmerge --previous -U resources/po/"$loc".po resources/po/phpmyadmin.pot
73 done
75 # Commit changes
76 git add resources/po/*.po resources/po/phpmyadmin.pot
77 git commit -s -m 'Update po files
79 [ci skip]'