Mailing List Archive

RE: Translating Trac
Hi,

>From: =?ISO-8859-1?Q?Jonas_Borgstr=F6m?= <jonas@edgewall.com>
>Subject: Re: [Trac] Translation in trac..
> > neo_cs is used for
> > - About.py (with the template inside, wich make it hard to translate)
> > - and the RSS files (timeline_rss.cs, ...)
> > ..and not trac.py : is it normal ?
> >
>I'm not sure I understand what you mean (except the About.py part)?
Okay, I've mistaken (and I sent this email before looking attentively at the
ClearSilver documentation : I first thought that neo_util was used for the
hdf format ;/ )

>
> > I'm evaluating the possibility to use gettext() so as to extract
> > translated text from python files and templates. Has anybody already
> > tried something like this before ?
> >
> > The other solution is to use the ClearSilver's HDF format : This
> > requires including "neo_util" in trac.py in order to manage translatable
> > templates : it's used (for only 5 variables :) in the 'netcon' demo
> > project (http://www.neomason.com/netcon/) . Any other experience in such
> > a direction ?
> >
>I think gettext is the way to go provided that it works on windows as
>well.
I aggree with you : however, I met several problems and About.py was the
typical case where I was impossible to extract gettext'ed variables as they
are all embedded in a single string.
Then I read the CS's online doc and tried the patch below wich works
perfectly for me.
The advantage of the gettext method is that it avoids to read another file
because all translated text should be compiled in a .mo file which should be
used to generate the .pyc translated file (but I must admit that I only
managed to extract gettext variables and compile the messages.po file - but
the python compiled file doesn't take care about it despite tha
--enable-gettext option used to compile CS. Maybe a problem of path, I may
ask about it on the CS list)

I've also included the "hdf-way-of-translating" philosophy in the following
files :
browser.py changeset.py file.py perm.py report.py search.py ticket.py
But I haven't tested it yet (must do it before submitting)

All this on the official 0.6.1 last version..
Ah, of course, I've a french version of all the templates (including all the
.cs files)

Does it seem good for the trac team ?

regards,

.Gilles

Index: About.py
===================================================================
--- About.py (revision 474)
+++ About.py (working copy)
@@ -33,15 +33,15 @@
<?cs include "header.cs"?>
<div id="page-content">
<div id="subheader-links">
- <a href="<?cs var:trac.href.about ?>">About Trac</a>&nbsp;
- | <a href="<?cs var:trac.href.about_config ?>">View Config</a>&nbsp;
+ <a href="<?cs var:trac.href.about ?>"><?cs var:Lang.Title ?></a>&nbsp;
+ | <a href="<?cs var:trac.href.about_config ?>"><?cs var:Lang.ViewConfig
?></a>&nbsp;
</div>
<div id="main">
<div id="main-content">
<?cs if about.page == "config"?>
- <h3>Configuration</h3>
+ <h3><?cs var:Lang.Configuration ?></h3>
<table>
- <tr><th>Section</th><th>Name</th><th>Value</th></tr>
+ <tr><?cs var:Lang.Headers ?></tr>
<?cs each:item = about.config ?>
<tr>
<td><?cs var:item.section ?></td>
@@ -53,23 +53,21 @@
<?cs else ?>
<a class="noline" href="http://trac.edgewall.com"
style="float: right"><img src="<?cs var:htdocs_location
?>trac_banner.png" alt=""/></a>
-<h1>About Trac <?cs var:trac.version ?></h1>
+<h1><?cs var:Lang.Title ?> <?cs var:trac.version ?></h1>
<p>
-Trac is a web-based software project management and bug/issue
-tracking system emphasizing ease of use and low ceremony.
-It provides an interface to the Subversion revision control systems,
integrated Wiki and convenient report facilities.
+<?cs var:Lang.Intro.1 ?>
+<?cs var:Lang.Intro.2 ?>
</p>
<p>
- Trac is distributed under the GNU General Public License (GPL).<br />
- The entire text of the license should be found in the COPYING file,
- included in the package.
+ <?cs var:Lang.License.1 ?><br />
+ <?cs var:Lang.License.2 ?>
</p>
<p>
- Please visit the Trac open source project:
+ <?cs var:Lang.PleaseVisit ?>
<a
href="http://projects.edgewall.com/trac/">http://projects.edgewall.com/trac/</a>
</p>
<p>
- Trac is a product of <a href="http://www.edgewall.com/">Edgewall
Software</a>, provider of professional Linux and software development
services.
+ <?cs var:Lang.Detail ?>
</p>
<p>
Copyright &copy; 2003,2004 <a href="http://www.edgewall.com/">Edgewall
Software</a>
@@ -105,7 +103,8 @@


def display (self):
- cs = neo_cs.CS(self.cgi.hdf)
+ self.cgi.hdf.readFile("about.hdf")
+ cs = neo_cs.CS(self.cgi.hdf)
cs.parseStr(self.about_cs)
print "Content-type: text/html\r\n"
print cs.render()

========================= END OF THE PATCH ====================
here is the 'about.hdf' file, that should be saved in the templates
directory
==============================================================
Lang {
Title=About Trac
ViewConfig=View Config
Configuration=Configuration
Headers=<th>Section</th><th>Name</th><th>Value</th>
Intro.1=Trac is a web-based software project management and
bug/issue tracking system emphasizing ease of use and low ceremony.
Intro.2=It provides an interface to the Subversion revision control
systems, integrated Wiki and convenient report facilities.
License.1=Trac is distributed under the GNU General Public License
(GPL).
License.2=The entire text of the license should be found in the
COPYING file, included in the
package.
PleaseVisit=Please visit the Trac open source project:&nbsp;
Detail=Trac is a product of <a
href="http://www.edgewall.com/">Edgewall Software</a>, provider of
professional Linux and software development services.
}

_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail
RE: Translating Trac [ In reply to ]
Am 07.05.2004 um 09:23 schrieb Gilles Vincent:
> ========================= END OF THE PATCH ====================
> here is the 'about.hdf' file, that should be saved in the templates
> directory
> ==============================================================
> Lang {
> Title=About Trac
> ViewConfig=View Config
> Configuration=Configuration
> Headers=<th>Section</th><th>Name</th><th>Value</th>

I don't think it's a good idea to put block level markup in the
translation file. The "Headers" item should be separated into
"Header.Section", "Header.Name" and "Header.Value", for example. Things
like links are okay, though (IMHO).

BTW, isn't Trac using lower-case names in data-sets as a convention
("lang.title" instead of "Lang.Title")?

Other than that I think this looks nice, but I'm a "newbie" ;-) I'd
probably contribute a german localization whenever this (or some other
I18N mechanism) gets in.

Cheers,
Chris
--
Christopher Lenz
/=/ cmlenz at gmx.de
RE: Translating Trac [ In reply to ]
Hi,

>From: =?ISO-8859-1?Q?Jonas_Borgstr=F6m?= <jonas@edgewall.com>
>Subject: Re: [Trac] Translation in trac..
> > neo_cs is used for
> > - About.py (with the template inside, wich make it hard to translate)
> > - and the RSS files (timeline_rss.cs, ...)
> > ..and not trac.py : is it normal ?
> >
>I'm not sure I understand what you mean (except the About.py part)?
Okay, I've mistaken (and I sent this email before looking attentively at the
ClearSilver documentation : I first thought that neo_util was used for the
hdf format ;/ )

>
> > I'm evaluating the possibility to use gettext() so as to extract
> > translated text from python files and templates. Has anybody already
> > tried something like this before ?
> >
> > The other solution is to use the ClearSilver's HDF format : This
> > requires including "neo_util" in trac.py in order to manage translatable
> > templates : it's used (for only 5 variables :) in the 'netcon' demo
> > project (http://www.neomason.com/netcon/) . Any other experience in such
> > a direction ?
> >
>I think gettext is the way to go provided that it works on windows as
>well.
I aggree with you : however, I met several problems and About.py was the
typical case where I was impossible to extract gettext'ed variables as they
are all embedded in a single string.
Then I read the CS's online doc and tried the patch below wich works
perfectly for me.
The advantage of the gettext method is that it avoids to read another file
because all translated text should be compiled in a .mo file which should be
used to generate the .pyc translated file (but I must admit that I only
managed to extract gettext variables and compile the messages.po file - but
the python compiled file doesn't take care about it despite tha
--enable-gettext option used to compile CS. Maybe a problem of path, I may
ask about it on the CS list)

I've also included the "hdf-way-of-translating" philosophy in the following
files :
browser.py changeset.py file.py perm.py report.py search.py ticket.py
But I haven't tested it yet (must do it before submitting)

All this on the official 0.6.1 last version..
Ah, of course, I've a french version of all the templates (including all the
.cs files)

Does it seem good for the trac team ?

regards,

.Gilles

Index: About.py
===================================================================
--- About.py (revision 474)
+++ About.py (working copy)
@@ -33,15 +33,15 @@
<?cs include "header.cs"?>
<div id="page-content">
<div id="subheader-links">
- <a href="<?cs var:trac.href.about ?>">About Trac</a>&nbsp;
- | <a href="<?cs var:trac.href.about_config ?>">View Config</a>&nbsp;
+ <a href="<?cs var:trac.href.about ?>"><?cs var:Lang.Title ?></a>&nbsp;
+ | <a href="<?cs var:trac.href.about_config ?>"><?cs var:Lang.ViewConfig
?></a>&nbsp;
</div>
<div id="main">
<div id="main-content">
<?cs if about.page == "config"?>
- <h3>Configuration</h3>
+ <h3><?cs var:Lang.Configuration ?></h3>
<table>
- <tr><th>Section</th><th>Name</th><th>Value</th></tr>
+ <tr><?cs var:Lang.Headers ?></tr>
<?cs each:item = about.config ?>
<tr>
<td><?cs var:item.section ?></td>
@@ -53,23 +53,21 @@
<?cs else ?>
<a class="noline" href="http://trac.edgewall.com"
style="float: right"><img src="<?cs var:htdocs_location
?>trac_banner.png" alt=""/></a>
-<h1>About Trac <?cs var:trac.version ?></h1>
+<h1><?cs var:Lang.Title ?> <?cs var:trac.version ?></h1>
<p>
-Trac is a web-based software project management and bug/issue
-tracking system emphasizing ease of use and low ceremony.
-It provides an interface to the Subversion revision control systems,
integrated Wiki and convenient report facilities.
+<?cs var:Lang.Intro.1 ?>
+<?cs var:Lang.Intro.2 ?>
</p>
<p>
- Trac is distributed under the GNU General Public License (GPL).<br />
- The entire text of the license should be found in the COPYING file,
- included in the package.
+ <?cs var:Lang.License.1 ?><br />
+ <?cs var:Lang.License.2 ?>
</p>
<p>
- Please visit the Trac open source project:
+ <?cs var:Lang.PleaseVisit ?>
<a
href="http://projects.edgewall.com/trac/">http://projects.edgewall.com/trac/</a>
</p>
<p>
- Trac is a product of <a href="http://www.edgewall.com/">Edgewall
Software</a>, provider of professional Linux and software development
services.
+ <?cs var:Lang.Detail ?>
</p>
<p>
Copyright &copy; 2003,2004 <a href="http://www.edgewall.com/">Edgewall
Software</a>
@@ -105,7 +103,8 @@


def display (self):
- cs = neo_cs.CS(self.cgi.hdf)
+ self.cgi.hdf.readFile("about.hdf")
+ cs = neo_cs.CS(self.cgi.hdf)
cs.parseStr(self.about_cs)
print "Content-type: text/html\r\n"
print cs.render()

========================= END OF THE PATCH ====================
here is the 'about.hdf' file, that should be saved in the templates
directory
==============================================================
Lang {
Title=About Trac
ViewConfig=View Config
Configuration=Configuration
Headers=<th>Section</th><th>Name</th><th>Value</th>
Intro.1=Trac is a web-based software project management and
bug/issue tracking system emphasizing ease of use and low ceremony.
Intro.2=It provides an interface to the Subversion revision control
systems, integrated Wiki and convenient report facilities.
License.1=Trac is distributed under the GNU General Public License
(GPL).
License.2=The entire text of the license should be found in the
COPYING file, included in the
package.
PleaseVisit=Please visit the Trac open source project:&nbsp;
Detail=Trac is a product of <a
href="http://www.edgewall.com/">Edgewall Software</a>, provider of
professional Linux and software development services.
}

_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail
RE: Translating Trac [ In reply to ]
>>Lang {
>> Title=About Trac
>> ViewConfig=View Config
>> Configuration=Configuration
>> Headers=<th>Section</th><th>Name</th><th>Value</th>
>
>I don't think it's a good idea to put block level markup in the translation
>file. The "Headers" item should be separated into "Header.Section",
>"Header.Name" and "Header.Value", for example. Things like links are okay,
>though (IMHO).
>
Ok, you're right (especially if one version use only CSS for formating
output)

>BTW, isn't Trac using lower-case names in data-sets as a convention
>("lang.title" instead of "Lang.Title")?
>
Where can such a convention be found ?
I thought this wasn't really important because of the name of the main
python modules which start with an uppercase, and I followed the examples
from ClearSilver..
But changing the data-sets name are not a problem.

>Other than that I think this looks nice, but I'm a "newbie" ;-) I'd
>probably contribute a german localization whenever this (or some other I18N
>mechanism) gets in.
>
This would be great !
I've practically finished my test phase and It works fine for me..
Moreother, a friend of mine is actually translating the default wiki pages
in french.

I'll propose a localization version as soon as possible.

.Gilles Vincent

_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE*
http://join.msn.com/?page=features/junkmail
RE: Translating Trac [ In reply to ]
Bonjour,

Si vous avez besoin d'aide pour la traduction ou pour la relire, vous
pouvez me la faire parvenir

Bonne journ?e

Francois Harvey
SecuriWeb inc.

Gilles Vincent wrote:
>>> Lang {
>>> Title=About Trac
>>> ViewConfig=View Config
>>> Configuration=Configuration
>>> Headers=<th>Section</th><th>Name</th><th>Value</th>
>>
>>
>> I don't think it's a good idea to put block level markup in the
>> translation file. The "Headers" item should be separated into
>> "Header.Section", "Header.Name" and "Header.Value", for example.
>> Things like links are okay, though (IMHO).
>>
> Ok, you're right (especially if one version use only CSS for formating
> output)
>
>> BTW, isn't Trac using lower-case names in data-sets as a convention
>> ("lang.title" instead of "Lang.Title")?
>>
> Where can such a convention be found ?
> I thought this wasn't really important because of the name of the main
> python modules which start with an uppercase, and I followed the
> examples from ClearSilver..
> But changing the data-sets name are not a problem.
>
>> Other than that I think this looks nice, but I'm a "newbie" ;-) I'd
>> probably contribute a german localization whenever this (or some other
>> I18N mechanism) gets in.
>>
> This would be great !
> I've practically finished my test phase and It works fine for me..
> Moreother, a friend of mine is actually translating the default wiki
> pages in french.
>
> I'll propose a localization version as soon as possible.
>
> .Gilles Vincent
>
> _________________________________________________________________
> The new MSN 8: advanced junk mail protection and 2 months FREE*
> http://join.msn.com/?page=features/junkmail
>
> _______________________________________________
> Trac mailing list
> Trac@lists.edgewall.com
> http://lists.edgewall.com/mailman/listinfo/trac
RE: Translating Trac [ In reply to ]
Am 07.05.2004 um 09:23 schrieb Gilles Vincent:
> -<h1>About Trac <?cs var:trac.version ?></h1>
> +<h1><?cs var:Lang.Title ?> <?cs var:trac.version ?></h1>

This snippet raises another question about the
"hdf-way-of-translating": Is there a way to do parameter substitution
in localized strings?

Ideally, the snippet above should look something like:

<h1><?cs var:lang.title ?><?cs param:trac.version ?><?cs /var ?>

and the HDF syntax might look like:

lang {
title = About Trac {0}
...
}

(I just made up that syntax, no idea whether clearsilver has something
like that)

As you probably know, this is a very important feature for an
internationalization mechanism, because different languages have
different ways of assembling sentences from words. Often, localizable
strings will contain dynamic parts that need to be substituted at
runtime.

Cheers,
Chris
--
Christopher Lenz
/=/ cmlenz at gmx.de
RE: Translating Trac [ In reply to ]
Am 07.05.2004 um 13:22 schrieb Gilles Vincent:
>>> Lang {
>>> Title=About Trac
>>> ViewConfig=View Config
>>> Configuration=Configuration
>>> Headers=<th>Section</th><th>Name</th><th>Value</th>
>>
>> I don't think it's a good idea to put block level markup in the
>> translation file. The "Headers" item should be separated into
>> "Header.Section", "Header.Name" and "Header.Value", for example.
>> Things like links are okay, though (IMHO).
>>
> Ok, you're right (especially if one version use only CSS for formating
> output)

Well, the main reason is that page structure should not depend on the
localization. If you put structural elements in translations, one can
never be sure whether translators use (for example) <td> instead of
<th>, or something completely different. And if you want to change the
structure, you'd need to touch both the templates *and* the
localizations.

>> BTW, isn't Trac using lower-case names in data-sets as a convention
>> ("lang.title" instead of "Lang.Title")?
>>
> Where can such a convention be found ?
[snip]

In the source :-) But I'm not sure whether that's a real "convention".
I guess the Trac devs can comment on this?

Cheers,
Chris
--
Christopher Lenz
/=/ cmlenz at gmx.de
RE: Translating Trac [ In reply to ]
>>-<h1>About Trac <?cs var:trac.version ?></h1>
>>+<h1><?cs var:Lang.Title ?> <?cs var:trac.version ?></h1>
>
>This snippet raises another question about the "hdf-way-of-translating": Is
>there a way to do parameter substitution in localized strings?
>
>Ideally, the snippet above should look something like:
>
> <h1><?cs var:lang.title ?><?cs param:trac.version ?><?cs /var ?>
>
>and the HDF syntax might look like:
>
> lang {
> title = About Trac {0}
> ...
> }
>
>(I just made up that syntax, no idea whether clearsilver has something like
>that)
>
>As you probably know, this is a very important feature for an
>internationalization mechanism, because different languages have different
>ways of assembling sentences from words. Often, localizable strings will
>contain dynamic parts that need to be substituted at runtime.
>
Yes, there is such a mecanism :
for example for the 'newticket.cs' templates here is the new code :
....
27 <div class="tkt-prop">
28 <label for="description"><?cs evar:Lang.Label.Description
?></label><br />
29 <textarea id="description" name="description" class="textwidget"
....
The corresponding value is in the hdf file is :
Lang.Label.Description=Full Description (You may use <a tabindex="42"
href="<?cs var:$trac.href.wiki ?>WikiFormatting">WikiFormatting</a> here):

The eval function indicates that the string must also be parsed (and not
only included)

I think it's enought for managing dynamic values.

regards,

.Gilles Vincent

_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail