#!/bin/sh
# drop unused l10n/i18n data

# preparations
rpm -e --nodeps glib2-locales

# the fell swoop
find /usr/share/locale/ -type f \! -name 'alterator*' -delete
rm -rf /usr/share/zoneinfo/{posix,right}/

# charset conversion tables
### NB: BIG5* and friends should be handled consistently
rm -f /usr/lib*/gconv/IBM*
rm -f /usr/lib*/gconv/BIG5*
rm -f /usr/lib*/gconv/EBCDIC*

# en_* variations
rm -rf /usr/{lib,share{,/X11}}/locale/en_[^U]*

# mods
rm -rf /usr/{lib,share{,/X11}}/locale/*@*

# non-utf8 locales
find /usr/lib/locale -mindepth 1 -maxdepth 1 -type d \! -name '*.utf8' -print0 |
        xargs -r0 rm -rf --

# dangling symlinks
find /usr/lib/locale \! -readable -delete

find /usr/share/qt5/translations/ -type f | \
    grep -v -e '/qtbase_[[:alpha:]][[:alpha:]]*\.qm$' \
	-e '/alterator_browser_qt_[[:alpha:]][[:alpha:]]*\.qm$' | \
while read f; do
    rm -f "$f"
done
