script to create all charmaps for all languages

For efforts in internationalising Puppy and solving problems in this area
Post Reply
Message
Author
User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

script to create all charmaps for all languages

#1 Post by Karl Godt »

Gambling for to know a little more about charmaps and languages I wanted to create them all into /usr/lib/locale .

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 
The script does not alter /etc/profile .
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 ) .

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: script to create all charmaps for all languages

#2 Post by L18L »

Karl Godt wrote:.. If run 200maps X 200langs -> SOME MEGA or GIGABYTE ...
I also do not have some GIGABYTE 8)

But here is my attempt for Danish in Süd-Schleswig:
/usr/share/i18n/locales/da_DE wrote:escape_char /
comment_char %
% Locale for Danish in Germany
% Contributed by Ulrich Drepper <drepper@redhat.com>, 2000
% Contributed by L18L for South Schleswig 2013

LC_IDENTIFICATION
title "Danish locale for Germany"
source "Danish Standards Association"
address "Kollegievej 6, DK-2920 Charlottenlund, Danmark"
contact ""
email "bug-glibc-locales@gnu.org"
tel ""
fax ""
language "Danish"
territory "Germany"
revision "1.0"
date "2000-06-29"
%
category "da_DE:2000";LC_IDENTIFICATION
category "da_DE:2000";LC_CTYPE
category "da_DE:2000";LC_COLLATE
category "da_DE:2000";LC_TIME
category "da_DE:2000";LC_NUMERIC
category "da_DE:2000";LC_MONETARY
category "da_DE:2000";LC_MESSAGES
category "da_DE:2000";LC_PAPER
category "da_DE:2000";LC_NAME
category "da_DE:2000";LC_ADDRESS
category "da_DE:2000";LC_TELEPHONE

END LC_IDENTIFICATION

LC_CTYPE
copy "de_DE"
END LC_CTYPE

LC_COLLATE

% Copy the template from ISO/IEC 14651
copy "iso14651_t1"

END LC_COLLATE

LC_MONETARY
copy "de_DE"
END LC_MONETARY

LC_NUMERIC
copy "de_DE"
END LC_NUMERIC

LC_TIME
copy "de_DE"
END LC_TIME

LC_MESSAGES
copy "da_DK"
END LC_MESSAGES

LC_PAPER
copy "de_DE"
END LC_PAPER

LC_NAME
copy "de_DE"
END LC_NAME


LC_ADDRESS
copy "de_DE"
END LC_ADDRESS

LC_TELEPHONE
copy "de_DE"
END LC_TELEPHONE

LC_MEASUREMENT
copy "de_DE"
END LC_MEASUREMENT
it is just copied from de_DE@euro and manually edited.
Testers from North-Schleswig welcome 8)

-----
[edit] above file da_DE changed after successful test 8)
Last edited by L18L on Sun 21 Apr 2013, 15:26, edited 1 time in total.

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

da_DE

#3 Post by L18L »

above file da_DE changed after successful test 8)

locale da_DE.UTF-8 is reality :lol:

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#4 Post by Karl Godt »

Thanks , L18L . I don't belong to the danish minority . Maybe there is a dk_GL , dk_BH , dk_JL , dk_SL , dk_LL , dk_FY and a dk_OD for all these islanders ?
:D

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

#5 Post by L18L »

Karl Godt wrote:Thanks , L18L . I don't belong to the danish minority . Maybe there is a dk_GL , dk_BH , dk_JL , dk_SL , dk_LL , dk_FY and a dk_OD for all these islanders ?
:D
Surely not. There is no language dk
Danish is da
Denmark is DK
Icelandic is is
.....

Why did I post that da_DE to you ?
Just for the contrast to your
script for all ... combined with all ..... good for ?

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#6 Post by Karl Godt »

Ich kenne keinen Menschen, der GUT ist .

Next time givt dat auffe Mütze Lutz !

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

#7 Post by L18L »

Sorry :oops:
Image

Post Reply