+# set up /etc/locale.gen, only GRML_FULL and LOCALES have
+# the full setup, GRMLBASE installs a minimal configuration
+fcopy /etc/locale.gen
+
+# get rid of locales unless using class LOCALES
+set +u
+if ! ifclass LOCALES ; then
+set -u
+ echo 'Removing /usr/share/locale'
+
+ # get rid of the original
+ rm -rf $target/usr/share/locale
+
+ # restore *empty* directories because otherwise installation/upgrade of packages might fail
+ [ -d "$target"/usr/share/locale ] || mkdir "$target"/usr/share/locale
+ $ROOTCMD ln -s /etc/locale.alias /usr/share/locale/locale.alias
+
+ # make sure the directories of removed locales exist; ugly hack but no other solution present :(
+ echo 'Creating empty /usr/share/locale/*/LC_MESSAGES directories'
+ for f in $($ROOTCMD dpkg -S LC_MESSAGES | awk '{print $2}' | grep '/usr/share/locale/' | sed 's#LC_MESSAGES.*##' | sort -u) ; do
+ if ! [ -d "$target/$f"/LC_MESSAGES ] ; then
+ $ROOTCMD mkdir -p "$f"/LC_MESSAGES
+ fi
+ done
+fi
+