[Catalyst] I18N with quotation marks

Gunnar Strand gunnarstrand at yahoo.com
Thu Jul 9 05:32:10 GMT 2009


Cosimo Streppone skrev:
> Gunnar Strand <gunnarstrand at yahoo.com> wrote:
>
>> Ton Voon skrev:
>>>
>>> Final question: How do you internationalise a bit of text that does
>>> want some markup within it? For instance, I want something that 
>>> outputs:
>>>
>>> Click <a href="/about">here</a> for the about page.
>>
>> Wouldn't you need to send every part of the text through c.loc
>> individually? I guess something like this:
>>
>> c.loc("Click ") _ link _ c.loc(" for the about page")
>
> If you collect all your i18n messages into .po files,
> that are worked on by translators, they have little or no
> context information, so they are going to have a really
> hard time figuring out the sense of words.
>
> We internationalized a dynamic non-catalyst website in
> 19 languages now, and we found the following, in gettext notation,
> to be the best for front-end and back-end developers
> and translators.
>
>  _('Click <a href="[_1]">here</a> for the about page')
>
> So,
>
> 1) Keep the markup. It's ugly, but to us it's slightly better than
>   the alternatives.
>
> 2) Variables as variables. This also conserves strings
>   if/when you're changing URLs or variable content.
>   Example:
>
>   "You can upload up to [_1] Mb of pictures."
>
>   As the string embeds the variable, your string won't need
>   to be translated again if you change your upload limit.
>
> 3) Don't break sentences. In general, the longer, the better.
>   In general.
I agree completely, and I may have misunderstood the question, but I 
interpreted it that the I18Ned text would be put through an HTML filter. 
In that case the above example of having markup inside the text sent to 
the localizer will not work.

I personally prefer to use library routines for creating html markup 
instead of hard coding data. I am using Maketext for my project (I'm not 
very experienced yet), but it seems that an alternative would be to 
extend the language file with HTML support in it to produce 
corresponding output:

_('Click [link,_1,here] for the about page')

This would be prettier (IMHO) and allows the rendering mechanism for 
links to be put in one place.

KR,
Gunnar






      



More information about the Catalyst mailing list