2024-02-13 14:39:04 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
srcdirs="panels shell subprojects/gvc"
|
|
|
|
uidirs=$srcdirs
|
|
|
|
desktopdirs=$srcdirs
|
|
|
|
policydirs=$srcdirs
|
|
|
|
xmldirs=$srcdirs
|
|
|
|
|
2024-03-04 12:34:53 +01:00
|
|
|
# find source files that contain gettext functions with literal or GETTEXT_PACKAGE argument
|
2024-04-15 09:08:06 +00:00
|
|
|
files=$(grep -ElRs --include='*.c' 'gettext2? ?\(("|GETTEXT_PACKAGE,)' $srcdirs)
|
2024-03-04 12:34:53 +01:00
|
|
|
|
|
|
|
# find source files that contain gettext macros
|
|
|
|
files="$files "$(grep -lRs --include='*.c' --include='*.h' '[^I_)]_(' $srcdirs)
|
2024-02-13 14:39:04 +01:00
|
|
|
|
|
|
|
# find ui files that contain translatable string
|
|
|
|
files="$files "$(grep -lRis --include='*.ui' 'translatable="[ty1]' $uidirs)
|
|
|
|
|
|
|
|
# find .desktop files
|
|
|
|
files="$files "$(find $desktopdirs -name '*.desktop*')
|
|
|
|
|
|
|
|
# find .policy files
|
|
|
|
files="$files "$(find $policydirs -name '*.policy*')
|
|
|
|
|
|
|
|
# find .xml.in and .gschema.xml files
|
|
|
|
files="$files "$(find $xmldirs -not -name '*.gresource.xml*' \
|
|
|
|
-name '*.xml.in*' -o \
|
|
|
|
-name '*.gschema.xml')
|
|
|
|
|
|
|
|
# filter out excluded files
|
|
|
|
if [ -f po/POTFILES.skip ]; then
|
|
|
|
files=$(for f in $files; do
|
|
|
|
! grep -q "^$f" po/POTFILES.skip && echo "$f"
|
|
|
|
done)
|
|
|
|
fi
|
|
|
|
|
|
|
|
# find those that aren't listed in POTFILES.in
|
|
|
|
missing=$(for f in $files; do
|
|
|
|
! grep -q "^$f" po/POTFILES.in && echo "$f"
|
|
|
|
done)
|
|
|
|
|
|
|
|
# find those that are listed in POTFILES.in but do not contain translatable strings
|
|
|
|
invalid=$(while IFS= read -r f; do
|
|
|
|
! grep -q "$f" <<< "$files" && echo "$f"
|
|
|
|
done < <(grep '^[^#]' po/POTFILES.in))
|
|
|
|
|
2024-02-14 21:50:35 +01:00
|
|
|
# find out if POTFILES.in is sorted correctly, ignoring empty lines
|
2024-02-14 23:02:34 +01:00
|
|
|
sorted=$(grep '^[^#]' po/POTFILES.in | \
|
|
|
|
LC_ALL=en_US.UTF-8 sort -cu 2>&1 >/dev/null | \
|
|
|
|
awk -F ': *' '{print $5}')
|
2024-02-14 21:50:35 +01:00
|
|
|
|
|
|
|
if [ ${#missing} -eq 0 ] && [ ${#invalid} -eq 0 ] && [ ${#sorted} -eq 0 ]; then
|
2024-02-13 14:39:04 +01:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ${#missing} -ne 0 ]; then
|
|
|
|
cat >&2 << EOT
|
|
|
|
|
|
|
|
The following files are missing from po/POTFILES.in or po/POTFILES.skip:
|
|
|
|
|
|
|
|
EOT
|
|
|
|
for f in $missing; do
|
|
|
|
echo " $f" >&2
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ${#invalid} -ne 0 ]; then
|
|
|
|
cat >&2 << EOT
|
|
|
|
|
|
|
|
The following files are in po/POTFILES.in but are missing or not translatable:
|
|
|
|
|
|
|
|
EOT
|
|
|
|
for f in $invalid; do
|
|
|
|
echo " $f" >&2
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2024-02-14 21:50:35 +01:00
|
|
|
if [ ${#sorted} -ne 0 ]; then
|
|
|
|
cat >&2 << EOT
|
|
|
|
|
|
|
|
The following file is not sorted properly in po/POTFILES.in:
|
|
|
|
|
|
|
|
EOT
|
|
|
|
echo " $sorted" >&2
|
|
|
|
fi
|
|
|
|
|
2024-02-13 14:39:04 +01:00
|
|
|
echo >&2
|
|
|
|
|
|
|
|
exit 1
|