[23812] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 6015 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 29 20:11:17 2004

Date: Thu, 29 Jan 2004 17:10:46 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 29 Jan 2004     Volume: 10 Number: 6015

Today's topics:
        Is there a "select langauge" module? <Gunnar.News@gustra.org>
    Re: Is there a "select langauge" module? <usenet@morrow.me.uk>
    Re: Is there a "select langauge" module? <Gunnar.News@gustra.org>
    Re: Is there a "select langauge" module? <tadmc@augustmail.com>
    Re: Is there a "select langauge" module? <flavell@ph.gla.ac.uk>
    Re: Is there a "select langauge" module? <pkent77tea@yahoo.com.tea>
    Re: Is there a "select langauge" module? <Gunnar.News@gustra.org>
    Re: Is there a "select langauge" module? (Anno Siegel)
    Re: Is there a "select langauge" module? <flavell@ph.gla.ac.uk>
    Re: Is there a "select langauge" module? <pkent77tea@yahoo.com.tea>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 24 Jan 2004 14:20:14 +0100
From: Gunnar Strand <Gunnar.News@gustra.org>
Subject: Is there a "select langauge" module?
Message-Id: <butrb1$knh$2@hudsucker.umdac.umu.se>

Hi,

I am maintaining a CGI program written in perl for which
we are planning to add support for more than one
language for all program messages. The choice of language
is to be user-selectable. My question is if there exists
any support, e.g. a module, for handling the choice of
language to display? I am thinking of something along the
lines:

use Language;
Language::set_language ( $selected_language );
print $Language::message1, ": ", $Language::message2;

I have been searching cpan and I have only found modules
to determine which language the user wants, i.e. setting
$selected_language to something useful in the above
example.

Kind Regards,

/Gunnar



------------------------------

Date: Sat, 24 Jan 2004 13:40:02 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Is there a "select langauge" module?
Message-Id: <butsji$aqa$2@wisteria.csv.warwick.ac.uk>


Gunnar Strand <Gunnar.News@gustra.org> wrote:
> I am maintaining a CGI program written in perl for which
> we are planning to add support for more than one
> language for all program messages. The choice of language
> is to be user-selectable. My question is if there exists
> any support, e.g. a module, for handling the choice of
> language to display? I am thinking of something along the
> lines:
> 
> use Language;
> Language::set_language ( $selected_language );
> print $Language::message1, ": ", $Language::message2;
> 
> I have been searching cpan and I have only found modules
> to determine which language the user wants, i.e. setting
> $selected_language to something useful in the above
> example.

Is Locale::Maketext what you want?

Ben

-- 
               EAT
               KIDS                                          (...er, whoops...)
               FOR                                             ben@morrow.me.uk
               99p


------------------------------

Date: Sat, 24 Jan 2004 15:30:57 +0100
From: Gunnar Strand <Gunnar.News@gustra.org>
Subject: Re: Is there a "select langauge" module?
Message-Id: <butvfl$oms$1@hudsucker.umdac.umu.se>

Thanks, Ben. Thank was exactly what I was looking
for.

Cheers!

/Gunnar

Ben Morrow wrote:
> Gunnar Strand <Gunnar.News@gustra.org> wrote:
> 
>>I am maintaining a CGI program written in perl for which
>>we are planning to add support for more than one
>>language for all program messages. The choice of language
>>is to be user-selectable. My question is if there exists
>>any support, e.g. a module, for handling the choice of
>>language to display? I am thinking of something along the
>>lines:
>>
>>use Language;
>>Language::set_language ( $selected_language );
>>print $Language::message1, ": ", $Language::message2;
>>
>>I have been searching cpan and I have only found modules
>>to determine which language the user wants, i.e. setting
>>$selected_language to something useful in the above
>>example.
> 
> 
> Is Locale::Maketext what you want?
> 
> Ben
> 



------------------------------

Date: Sat, 24 Jan 2004 09:25:37 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Is there a "select langauge" module?
Message-Id: <slrnc153jh.4hc.tadmc@magna.augustmail.com>

Gunnar Strand <Gunnar.News@gustra.org> wrote:

> My question is if there exists
> any support, e.g. a module, for handling the choice of
> language to display? I am thinking of something along the
> lines:
> 
> use Language;
> Language::set_language ( $selected_language );
> print $Language::message1, ": ", $Language::message2;
> 
> I have been searching cpan and I have only found modules
> to determine which language the user wants, i.e. setting
> $selected_language to something useful in the above
> example.


You could use a hash for each type of message, keyed by $selected_language:

( all untested)


   my %lunch_msg = (
      English => 'I want Taco Bell',
      Spanish => 'Yo quiero Taco Bell',
   )

   ...

   print "$lunch_msg{$selected_language}\n";


Or, better, a single HoH for _every_ type of message your program will use:

   my %msg = (
      lunch => {
                  English => 'I want Taco Bell',      
                  Spanish => 'Yo quiero Taco Bell',   # [1]
               },
      governor => {
                  English => 'See you later Baby',
                  Spanish => 'Hasta la vista Baby',   # [2]
               },
   );

   ...

   print "$msg{lunch}{$selected_language}\n";



[1] editorial license taken with regard to the Spanishness of that phrase  :-)

[2] YMEL (Yet More Editorial License)

-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Sat, 24 Jan 2004 18:16:01 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Is there a "select langauge" module?
Message-Id: <Pine.LNX.4.53.0401241756310.20482@ppepc56.ph.gla.ac.uk>

On Sat, 24 Jan 2004, Tad McClellan wrote:

>    my %lunch_msg = (
>       English => 'I want Taco Bell',
>       Spanish => 'Yo quiero Taco Bell',
>    )

It gets more interesting when the messages need to have values plugged
into them at run-time.

Years ago, IBM internationalised their VM messages by providing
for each language a file of message texts, with the parameters
designated by placeholders $1, $2, $3 etc.

The message-writing routines were called with a message code and a
list of parameter values.  It's a key feature that the parameters did
not have to be placed in numerical sequence - some languages wanted
the parameters in one order, others in another, for best idiom.  So
you might have something like (pure invention)

IBMABC123E Command $1 got Error $3 opening file $2

and so on.

OK, this is a bit simplistic if the parameters themselves need to
be translated!!

all the best.


------------------------------

Date: Sun, 25 Jan 2004 00:43:00 +0000
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Is there a "select langauge" module?
Message-Id: <pkent77tea-0D1F69.00430025012004@pth-usenet-02.plus.net>

In article <Pine.LNX.4.53.0401241756310.20482@ppepc56.ph.gla.ac.uk>,
 "Alan J. Flavell" <flavell@ph.gla.ac.uk> wrote:

> Years ago, IBM internationalised their VM messages by providing
> for each language a file of message texts, with the parameters
> designated by placeholders $1, $2, $3 etc.
> 
> The message-writing routines were called with a message code and a
> list of parameter values.  It's a key feature that the parameters did
> not have to be placed in numerical sequence - some languages wanted
> the parameters in one order, others in another, for best idiom.  So
> you might have something like (pure invention)
> 
> IBMABC123E Command $1 got Error $3 opening file $2

Yep this is, in my limited experience, the way that part of the 
localization of internationalized application is done, and eminently 
sensible it is, too. MacOS programs also often have string resources 
(shown up with ResEdit) that look like "Cannot open file ^1 because: ^2"

Other things you also want to change when creating the message are 
number format, date format, time corrections, gender, pluralization, 
screen space allocated for strings, text directionality, keyboard 
shotcut keys... quite a lot really. Some of this sort of thing is done 
in:

http://java.sun.com/j2se/1.3/docs/api/java/text/MessageFormat.html
and others in
http://java.sun.com/j2se/1.3/docs/api/java/util/ResourceBundle.html

but I can't immediately find a perl module which offers similar 
functions. The MessageFormat class is like a very souped-up sprintf() 
with all the bells and whistles, and you could use the ResourceBundle 
class to load the correct format strings etc. for the current locale or 
user prefs.

I was reading somewhere else that a program was localized into German 
but that the error messages took up about 50% (they said) more space. 
Naturally the GUI elements weren't resized to take account of this :-)

P

-- 
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply


------------------------------

Date: Sun, 25 Jan 2004 22:57:53 +0100
From: Gunnar Strand <Gunnar.News@gustra.org>
Subject: Re: Is there a "select langauge" module?
Message-Id: <bv1e2s$gif$1@hudsucker.umdac.umu.se>

The Locale::Maketext::TJP13 is an excellent article discussing
the problems with translations and describes the reason behind
the Locale::Maketext module:

http://search.cpan.org/~sburke/Locale-Maketext-1.08/lib/Locale/Maketext/TPJ13.pod

The parameterizaion of messages is the central issue in the
article. I wouldn't mind seeing a reference to it in the
perlfaq somewhere. Recommended reading!

Kind Regards,

/Gunnar

pkent wrote:
> In article <Pine.LNX.4.53.0401241756310.20482@ppepc56.ph.gla.ac.uk>,
>  "Alan J. Flavell" <flavell@ph.gla.ac.uk> wrote:
> 
> 
>>Years ago, IBM internationalised their VM messages by providing
>>for each language a file of message texts, with the parameters
>>designated by placeholders $1, $2, $3 etc.
>>
>>The message-writing routines were called with a message code and a
>>list of parameter values.  It's a key feature that the parameters did
>>not have to be placed in numerical sequence - some languages wanted
>>the parameters in one order, others in another, for best idiom.  So
>>you might have something like (pure invention)
>>
>>IBMABC123E Command $1 got Error $3 opening file $2
> 
> 
> Yep this is, in my limited experience, the way that part of the 
> localization of internationalized application is done, and eminently 
> sensible it is, too. MacOS programs also often have string resources 
> (shown up with ResEdit) that look like "Cannot open file ^1 because: ^2"
> 
> Other things you also want to change when creating the message are 
> number format, date format, time corrections, gender, pluralization, 
> screen space allocated for strings, text directionality, keyboard 
> shotcut keys... quite a lot really. Some of this sort of thing is done 
> in:
> 
> http://java.sun.com/j2se/1.3/docs/api/java/text/MessageFormat.html
> and others in
> http://java.sun.com/j2se/1.3/docs/api/java/util/ResourceBundle.html
> 
> but I can't immediately find a perl module which offers similar 
> functions. The MessageFormat class is like a very souped-up sprintf() 
> with all the bells and whistles, and you could use the ResourceBundle 
> class to load the correct format strings etc. for the current locale or 
> user prefs.
> 
> I was reading somewhere else that a program was localized into German 
> but that the error messages took up about 50% (they said) more space. 
> Naturally the GUI elements weren't resized to take account of this :-)
> 
> P
> 



------------------------------

Date: 26 Jan 2004 12:23:10 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Is there a "select langauge" module?
Message-Id: <bv30re$ngq$1@mamenchi.zrz.TU-Berlin.DE>

pkent  <pkent77tea@yahoo.com.tea> wrote in comp.lang.perl.misc:

[...]

> I was reading somewhere else that a program was localized into German 
> but that the error messages took up about 50% (they said) more space. 
> Naturally the GUI elements weren't resized to take account of this :-)

Every translation tends to make a text longer (you'll always have to
talk around things that don't have an exact equivalent in the target
language).  German may be a particularly long-worded language, but let
an independent translator translate it back into English and it'll get
longer again.

Anno


------------------------------

Date: Mon, 26 Jan 2004 19:13:38 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Is there a "select langauge" module?
Message-Id: <Pine.LNX.4.53.0401261908440.31392@ppepc56.ph.gla.ac.uk>

On Mon, 26 Jan 2004, Anno Siegel wrote:

> Every translation tends to make a text longer

There's a distinct tendency, indeed.  (And, to bring it slightly
on-topic, much the same tends to be true of rewriting a program in
a different language.  Seen all the C-style loops around here? ;-)

> (you'll always have to talk around things that don't have an exact
> equivalent in the target language).

Well, "you'll have to" is a bit of an exaggeration.  A *good*
translator would grasp the underlying meaning of the original, and
then express that meaning in the idiom of the target language, rather
than strugging at a word by word conversion.

Unfortunately, when translating someone else's diagnostic messages,
the underlying meaning of the original is all too often sufficiently
unclear that even a good translator cannot discern it accurately! :-}


------------------------------

Date: Tue, 27 Jan 2004 22:47:07 +0000
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Is there a "select langauge" module?
Message-Id: <pkent77tea-DE3A2B.22470727012004@pth-usenet-01.plus.net>

In article <bv1e2s$gif$1@hudsucker.umdac.umu.se>,
 Gunnar Strand <Gunnar.News@gustra.org> wrote:

> The Locale::Maketext::TJP13 is an excellent article discussing
> the problems with translations and describes the reason behind
> the Locale::Maketext module:
> 
> http://search.cpan.org/~sburke/Locale-Maketext-1.08/lib/Locale/Maketext/TPJ13.
> pod
> 
> The parameterizaion of messages is the central issue in the
> article. I wouldn't mind seeing a reference to it in the
> perlfaq somewhere. Recommended reading!

Yep, that just about starts to hint at the horrors that await people if 
they make_bad_ _assumptions_! :-) The world has a lot of languages and a 
lot of ways of doing things.

It's as bad as people, in international contexts, assuming that you 
_will_ have a ZIP code and it _will_ be 5 or 9 digits long, or that you 
know what '01/02/04' means. It goes without saying that there is nothing 
wrong with this if you know who your audience are, for example :-) 
Obviously I'm not saying everything must always be i18nized... but where 
appropriate it should be done, and all that. Just like the perl docs say 
about portability "perl can be portable but you don't have to make your 
program portable, it all depends on your needs". I paraphrase...

P

-- 
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 6015
***************************************


home help back first fref pref prev next nref lref last post