Since the default glibc source installs some 200 charmaps I wanted to know which ones would work and which not .
Puppy ships with one or two dozen charmaps by default .
Puppy chooselocale code is a little weird to understand .
So I started some days ago to implement the " -createall " option into chooselocale , but that looks ugly for now .
So just a languages_create_all script :
Code: Select all
#!/bin/sh
# Karl Reimer Godt April 2013
trap 'echo -e "\n";exit' INT
WANTED_LANG='';
[ "$1" ] && WANTED_LANG="$1" #ie de
WANTED_LANG="${WANTED_LANG:0:2}"
echo "WANTED_LANG=$WANTED_LANG'"
for language in $(ls -1 /usr/share/i18n/locales | grep -v -E 'i18n|iso|translit|POSIX|C'); do
echo "${language:0:2}"
[ ! "$WANTED_LANG" ] || { [ "${language:0:2}" = "$WANTED_LANG" ] || continue; }
while read char_map ; do
char_map=${char_map%\.*}
echo "${language}.${char_map}"
LOGFILE=$tmpDir/${language}.${char_map}.log
#timeout -t 10 -s HUP
localedef $L_QUIET $L_FORCE $VERB -f $char_map -i $language --no-archive "${language}.${char_map}" > "$LOGFILE" 2>&1;LOCALEDEFR=$?
if [ "$LOCALEDEFR" != 0 ] ; then
echo -e "\\033[1;31mSomething Wrong"
[ -s "$LOGFILE" ] && tail "$LOGFILE" || rm -f "$LOGFILE"
echo -e "\\033[0;39m"
if [ ! "${language//[_[:alpha:]]/}" ] ; then
rmdir /usr/lib/locale/${language}.`echo "${char_map//-/}" | tr '[A-Z]' '[a-z]'`
else
rmdir /usr/lib/locale/${language}.${char_map}
fi
else
[ -s "$LOGFILE" ] || rm -f "$LOGFILE"
fi
done<<EOI
$(ls -1 /usr/share/i18n/charmaps)
EOI
read -p "Press Enter to continue, Cntrl+C to abort :" ENTERKEY
done
I use it to debug if languages don't compile
f.ex output of de_LU@euro with cp775 :
de_LU@euro.CP775
Something Wrong
/usr/share/i18n/charmaps/CP775:268: unknown character `U00000080'
no output file produced because warnings were issued
NOTE : A /usr/lib/locale/$LANG contains 0,2-1,2MB of files . If run 200maps X 200langs -> SOME MEGA or GIGABYTE .
I have put in interactive mode , to be able to stop it . Also accepts $1 ( aa , af , .. , en , .. , zh , zu ) .