[LON-CAPA-dev] Internationalization

Gerd Kortemeyer lon-capa-dev@mail.lon-capa.org
Sun, 21 Sep 2003 15:34:50 -0400


Minoru,

Yes, the sample file is in ISO, but we have also successfully worked 
with UTF-8. If you could send me a small Japanese sample file in UTF-9, 
I can install it here, and we can test the setup.

Thanks!

- Gerd.

On Sunday, September 21, 2003, at 01:18  AM, Minoru Akiyama wrote:

> Hi, Gerd,
>
> Sample file is not  encoded in UTF-8.
> I'd like to develop Japanese lexicon, but I'm afraid it won't
> work in the case of Japanese(double byte code).
>
> i-Learning / EMIT Japan
> Minoru Akiyama
>
> ----- Original Message -----
> From: "Gerd Kortemeyer" <korte@lite.msu.edu>
> To: <lon-capa-dev@mail.lon-capa.org>; "Leonardo Mendes"
> <lmendes@decom.fee.unicamp.br>; "Ricardo Luis Kulzer"
> <ricardol@decom.fee.unicamp.br>; "Horst Bögel"
> <boegel@chemie.uni-halle.de>; "Shoji Kajita"
> <kajita@itc.nagoya-u.ac.jp>; "Timothy Takemoto"
> <tim@yamaguchi-u.ac.jp>; "Michael Thoennessen"
> <thoennessen@nscl.msu.edu>
> Cc: "Gerd Kortemeyer" <korte@lite.msu.edu>; "Ed Kashy"
> <kashy@nscl.msu.edu>; <cspeier@msu.edu>; "Deborah Kashy"
> <kashyd@pilot.msu.edu>; "Wolfgang Bauer" <bauer@pa.msu.edu>;
> "Helen Keefe" <helen@lon-capa.org>
> Sent: Thursday, September 18, 2003 9:28 PM
> Subject: [LON-CAPA-dev] Internationalization
>
>
>> Hi,
>>
>> As you might have seen from a number of CVS commits in the last
> two
>> days, we have started to internationalize LON-CAPA, so that it
> can run
>> in different languages. We have also started localizing for
> German and
>> Portuguese. Internalizing is the bulk of the work right now,
> localizing
>> can be done anytime, and involves no programming.
>>
>> The internationalization process involves putting a wrapper
> around
>> on-screen user messages and menus and turning them into keys,
> which the
>> Maketext library translates into the desired language output
> using a
>> look-up table ("lexicon").
>>
>> As keys we are currently using the plain English messages, and
> Maketext
>> is configured to replace the message by its own key if no
> translation
>> is found. This makes it easy to phase in the
> internationalization
>> without disturbing the screen output.
>>
>> Internationalization is tedious, and the more we can distribute
> the
>> work, the better.
>>
>> *** New software should be written in internationalized format
> from now
>> on.
>>
>> *** If you feel like doing something brainless but productive,
> grab a
>> module and internationalize it.
>>
>> *** As you come across some code during normal programming,
> just insert
>> the wrappers.
>>
>> *** HERE'S WHAT TO DO:
>>
>> Into the "use" section of a module, we need to insert
>>
>>   use Apache::lonlocal;
>>
>> - note that there are NO BRACKETS, we *want* to pollute our
> namespace.
>>
>> Inside might be something like this
>>
>> sub message {
>>     my $status=shift;
>>     my $message='Status unknown';
>>     if ($status eq 'WON') {
>>        $message='You have won.';
>>     } elsif ($status eq 'LOST') {
>>        $message='You are a total looser.';
>>     }
>>     return $message;
>> }
>> ...
>> $r->print('<h3>Gamble your Homework Points</h3>');
>> ...
>> $r->print(<<ENDMSG);
>> <font size="1">Rules:</font>
>> <font size="0">No purchase necessary. Illegal where not
> allowed.</font>
>> ENDMSG
>>
>> We have to now wrap the subroutine &mt() ("maketext") around
> our
>> messages, but not around markup, etc. We also want minimal
> disturbance.
>> The first two examples are easy:
>>
>> sub message {
>>     my $status=shift;
>>     my $message='Status unknown';
>>     if ($status eq 'WON') {
>>        $message='You have won.';
>>     } elsif ($status eq 'LOST') {
>>        $message='You are a total looser.';
>>     }
>>     return &mt($message);
>> }
>> ...
>> $r->print('<h3>'.&mt('Gamble your Homework Points').'</h3>');
>>
>> The last one is a bummer, since you cannot call subroutines
> inside of
>> (<<MARKER). I have written a little subroutine to generate a
> translated
>> hash for that purpose:
>>
>> my %lt=&Apache::lonlocal::texthash('header' => 'Rules',
> 'disclaimer' =>
>> 'No purchase necessary. Illegal where not allowed.');
>> $r->print(<<ENDMSG);
>> <font size="1">$lt{'header'}:</font>
>> <font size="0">$lt{'disclaimer'}</font>
>> ENDMSG
>>
>> As a programmer, your job is done here. If everything worked,
> you
>> should see no changes on the screen.
>>
>> As a translator, you need to provide the lexicon for the keys,
> which in
>> this case is the plain text message. The lexicons sit in
>> loncom/localize/localize, with the language code as filename,
> for
>> example de.pm for the German translation. The file then simply
> looks
>> like this:
>>
>>     'You have won.'
>> => 'Sie haben gewonnen.',
>>
>>     'You are a total looser.'
>> => 'Sie sind der totale Verlierer.',
>>
>>     'Rules'
>> => 'Regeln',
>>
>>     'No purchase necessary. Illegal where not allowed.'
>> => 'Es ist erlaubt, einfach zu verlieren, und das ist Ihre
> Schuld.'
>>
>> The German translation lexicon is in pretty okay shape, but not
>> complete yet. Portuguese currently only covers the login
> screen.
>> Russian is purely experimental. Looks like UTF-8 is the way to
> encode
>> this, at least for latin/greek-based languages, but we still
> have to
>> learn a lot.
>>
>> This is a relatively easy programming task, and any help is
> appreciated.
>>
>> Maketext can do a whole lot more, see
>>
>>
> http://search.cpan.org/dist/Locale-Maketext/lib/Locale/Maketext.pod
>>
>> but for most purposes, we do not have to mess with that.
>>
>> - Gerd.
>>
>>
>>
>> _______________________________________________
>> LON-CAPA-dev mailing list
>> LON-CAPA-dev@mail.lon-capa.org
>> http://mail.lon-capa.org/mailman/listinfo/lon-capa-dev
>>
>
>
> _______________________________________________
> LON-CAPA-dev mailing list
> LON-CAPA-dev@mail.lon-capa.org
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-dev