[Koha-devel] translation complaint...

Tonnesen Steve tonnesen at cmsd.bc.ca
Wed Jan 29 17:34:04 CET 2003


Here's my proposal:

Existing english language template example:

---
<TMPL_IF NAME="loggedinuser">
    <p align=left>Logged in as: <TMPL_VAR NAME="loggedinuser">
[<a href=/cgi-bin/koha/opac-user.pl>Members Home</a>]
[<a href=/cgi-bin/koha/opac-logout.pl>Log Out</a>]</p>
<TMPL_ELSE>
    <p align=left><a href=/cgi-bin/koha/opac-user.pl>Log In</a> to
Koha</p>
</TMPL_IF>
---

would be rewritten as:

<TMPL_IF NAME="loggedinuser">
    <p align=left>

<TMPL_VAR NAME="STRING_LoggedInAs">

<TMPL_VAR NAME="loggedinuser">    
[<a href=/cgi-bin/koha/opac-user.pl>

<TMPL_VAR NAME="STRING_MembersHome">

</a>]   
[<a href=/cgi-bin/koha/opac-logout.pl>

<TMPL_VAR NAME="STRING_Logout">

</a>]</p>
<TMPL_ELSE>
    <p align=left><a href=/cgi-bin/koha/opac-user.pl>

<TMPL_VAR NAME="STRING_LoginToKoha">
</a>
</p>
</TMPL_IF>
---


Then we'd need perl code (most likely in the get_template_and_user
subroutine) that would do the following:

foreach my $variable ($template->param) {
    if (/^STRING_(.*)/) {
        my $string_identifier=$1;
        $template->param($variable => gettext($string_identifier);
    }
}

The gettext() routine could be an internal function, or we could use some
other implementation.

One problem I've noticed with this is it doesn't allow us to have strings
with printf variables in them like: 

Hello %s, welcome to Koha!

Where this would be printed as:

printf "Hello %s, welcome to Koha!", $fullname;

That means you end up translating the string "Hello" and the string
", welcome to Koha!" separately, and completely out of context.

It might be possible to gettext the "Hello %s, welcome to Koha!" string on
the perl side, use printf to add the variable substitution and then pass
the whole thing into HTML::Template as a single variable, but that defeats
a lot of the gains that templating gives us.

As an example from above, the "Logged in as..." string might be handled
as:

my $string=gettext("LoggedInAs");

which would return, in English, "Logged in as %s.";

$template->param("STRING_LoggedInAs", sprintf $string, $userid);

We would also lose the automatic processing that the get_template_and_auth
method gave us (wherein that routine just parsed through all the
"STRING_*" variables in the template and translates them from gettext
files). 

It's starting to look to me like it's going to be difficult no matter what
route we take.  The easiest solution for all is probably the
get_template_and_auth method, but we end up translating partial sentences.
If there was some way to pass a context, as in:

Translate "Hello" as part of the phrase "Hello Steve, Welcome to Koha!".
  and
Translate ", Welcome to Koha" as part of the phrase "Hello Steve, Welcome
to Koha!".

Off the top of my head, I would envision context phrases being stored
elsewhere with a numeric index, and the STRING_phrase variables being
extended to allow a context number like STRING_phrase_154 where the 154
would point to a context string.

Steve.



On 30 Jan 2003, Benedict wrote:

> I have no idea how to code but after reading the Maketext documentation
> this is probably the line we should include wherever an english string
> should be represented by another language. (it's a great simplification)
>  print $lh->maketext("You won!"), "\n";
> 
> In french it should print "Tu as gagne".
> 
> I am just wondering where these strings would have to live...in template
> files or in the perl scripts.
> If template files are to remain clean of any code than this would not be
> a good idea, would it?
> 
> Benedict
> 
> 
> 
> 
> 
> -------------------------------------------------------
> This SF.NET email is sponsored by:
> SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
> http://www.vasoftware.com
> _______________________________________________
> Koha-devel mailing list
> Koha-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/koha-devel
> 






More information about the Koha-devel mailing list