Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Language Localization (l18n, L10n) - Multilingual Output

by davidfilmer (Acolyte)
on Aug 01, 2003 at 21:46 UTC ( #280166=perlquestion: print w/replies, xml ) Need Help??
davidfilmer has asked for the wisdom of the Perl Monks concerning the following question:

I'm developing a script (web cgi) for which I would like to offer multilanguage support. I would like some advise on how I might (better) approach this task. The script will be fairly small and usage (on a non-profit org website) will be fairly light, so efficiency concerns aren't terribly important.

What I'm presently thinking is that I won't hard-code any output in my script, but will populate (from a database or whatever) a hash which would look this:
    $lang{'yes'} = 'sí';
    $lang{'no'} = 'ningún';
    $lang{'The answer is'} = 'La respuesta es';

Then, in my script, I would output something like:
    print "$lang{'The answer is'} $lang{'yes'}.";
and it would print:
    La respuesta es sí.
assuming I had populated the hash from a Spanish database. (In the English version, the hash values are simply the same as the hash keys.)

Does this seem a good approach? It seems a bit clumsy, but a better idea doesn't come to mind (though I can think of a couple of ideas that I think are much worse). A better suggestion would be most welcome!

  • Comment on Language Localization (l18n, L10n) - Multilingual Output

Replies are listed 'Best First'.
Re: Language Localization (l18n, L10n) - Multilingual Output
by adrianh (Chancellor) on Aug 01, 2003 at 22:01 UTC
Re: Language Localization (l18n, L10n) - Multilingual Output
by waswas-fng (Curate) on Aug 01, 2003 at 22:06 UTC
    You will run into problems where the nouns adverbsetc change location in languages. For example some languages would be "The red car". where others could be "The car red". I think it may be more worth while to use a full template system for completly changing the output text to the translated languages.

    -Waswas

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://280166]
Approved by Zaxo
help
Chatterbox?
[Corion]: ambrus: AnyEvent(::HTTP) doesn't integrate well with Prima, that's my main problem
[Corion]: There is a weirdo shim because there is a POE integration for Prima, and if you use that, you can use the POE adapter of AnyEvent. What I'd want is something transport agnostic that parses HTTP or produces HTTP output, so that the communication with ...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2016-12-07 15:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (130 votes). Check out past polls.