[Koha] i18n of .pl scripts
Mark Tearle
mtearle at tearle.com
Fri Sep 8 01:52:47 NZST 2000
On Thu, 7 Sep 2000, Benedykt P. Barszcz wrote:
> Hi all,
> I would like to know whether it is neccesary to add gettext() function
> in line like this:
> #
> print $input->header;
> #
>
You should be able to safely ignore that (mostly) at the moment.
> Secondly where if anywhere should one insert gettext() function in
> this example:
> print <<printend
> <FONT SIZE=6><em>Account for $data->{'firstname'} $data->{'surname'}</em></FONT><P>
> <center>
> <p>
> <TABLE CELLSPACING=0 CELLPADDING=5 border=1 >
> <TR VALIGN=TOP>
> <td bgcolor="99cc33" background="/images/background-mem.gif"
> colspan=2><B>FINES & CHARGES</TD>
> [....]
> printend
>
> Is "FINES & CHARGES" subject to localization by gettext() or is it
> part of the HTML Code and cannot be localized here?
>
> Also should $data->{'firstname'} change into $data-
> >{gettext('firstname')} in the obove example?
>
> How about the formatting strings of type: "<br>" and other html code
> strings, are they to fall within or outside of the gettext() function?
>
> Any help will be appreciated.
> May be a bunch of examples?
> -, pozdrawiam
> Benedykt P. Barszcz
>
I've attached a quick example. printf and sprintf would be the way I'd
tackle this problem. In the format, the %s are replaced with the
strings returned by gettext.
use POSIX; # for setlocale()
use Locale::gettext;
#
bindtextdomain("my_domain", ".");
#
setlocale(LC_MESSAGES, "de");
#
textdomain("my_domain");
#
#
$firstname="Mark";
$surname="Tearle";
$format = <<printend;
%s
<FONT SIZE=6><em>%s
$firstname $surname</em></FONT><P>
<center>
<p>
<TABLE CELLSPACING=0 CELLPADDING=5 border=1 >
<TR VALIGN=TOP>
<td bgcolor="99cc33" background="/images/background-mem.gif"
colspan=2><B>%s</TD>
printend
printf $format, gettext("Welcome to my program"), gettext("Account for"), gettext("FINES & CHARGES");
And trying it out....
21:40 0 mtearle:phregia[626]:/tmp/example>perl test.pl
Welcome to my program
<FONT SIZE=6><em>Account for
Mark Tearle</em></FONT><P>
<center>
<p>
<TABLE CELLSPACING=0 CELLPADDING=5 border=1 >
<TR VALIGN=TOP>
<td bgcolor="99cc33" background="/images/background-mem.gif"
colspan=2><B>FINES & CHARGES</TD>
21:40 0 mtearle:phregia[627]:/tmp/example>setenv LANG de
21:40 0 mtearle:phregia[628]:/tmp/example>perl test.pl
Willkommen in mein Program
<FONT SIZE=6><em>Acount fur
Mark Tearle</em></FONT><P>
<center>
<p>
<TABLE CELLSPACING=0 CELLPADDING=5 border=1 >
<TR VALIGN=TOP>
<td bgcolor="99cc33" background="/images/background-mem.gif"
colspan=2><B>Geldstrafen und Ladungen</TD>
It should be quite easy to get Koha supporting many dialects once you've
finished, Koha in Klingon anyone?
Let me know if this doesn't make any sense to you.
(Chris, C4 needs a file we can put global config options in such as
the path to the .mo translation files?)
Yours
Mark
--
Mark Tearle - mark at tearle.com
Stone: Let's stick to established procedures. -- The Andromeda
Leavitt: Establishment gonna fall down and go boom. Strain (1971)
More information about the Koha
mailing list