eZ Community » Forums » Setup & design » i18n: doesn't show any translation
expandshrink

i18n: doesn't show any translation

i18n: doesn't show any translation

Wednesday 07 November 2007 9:51:44 am - 3 replies

Hello.
We installed the ezsearch extension. We override its templates. Some of the translation work, some doesn't.
Now I see there is a general translation.ts inside the folder /share/translations/ita-IT/, as well as a file that is specific to the extension, that is in the folder /extensions/ezfind/translations/ita-IT.

I am quite sure the general translation file is used, and if I try a "static" translation (with no parameters), such as

<p>{"Last month"|i18n('design/standard/content/search')}</p>

it works, and I got the italian text

But if I try a "dynamic" one such as

<p>{'No results were found when searching for &lt;%1&gt;'|i18n('design/standard/content/search','',array($search_text|wash))}</p>

then it doesn't work, and all I got is the english text with the parameter value correctly substituted with the value passed to the function ($search_text).

In the translation.ts file (under /share/translations/ita-IT/) I have the correct context and (it seems to me) the correct message:
<context>
<name>design/admin/content/search</name>
...
...
<message>
<source>No results were found when searching for &lt;%1&gt;</source>
<translation>Cercando &lt;%1&gt; non è stato trovato nessun risultato</translation>
</message>
...
...
</context>

So what do I do wrong? What can be the problem blocking the translation?
Thank you very much,
Mirko.

Thursday 08 November 2007 2:50:57 pm

I narrowed down the issue, and found out that what bothers the i18n function is the fact that there were some "entities" into the keys used to get the translated text. In particular:

(in the translation.ts file)
<message>
<source>No results were found when searching for &lt;%1&gt;</source>
<translation>Cercando &lt;%1&gt; non è stato trovato nessun risultato</translation>
</message>

The problem is somehow connected with the presence of the "&lt;" and "&gt;" entities. I don't know wether that is a configuration problem specific to our ez Publish installation, or if there is some other reason.

If someone could help sorting that out, it would be very much appreciated.

Thank you,
Mirko.

Thursday 08 November 2007 3:33:34 pm

Ok. I finally got it solved.
My fault.

In the xml file (translation.ts),I had something like:
<message>
<source>No results were found when searching for &lt;%1&gt;</source>
<translation>Cercando &lt;%1&gt; non è stato trovato nessun risultato</translation>
</message>

When calling the i18n function, I assumed (wrongly) that I should use the entities "&gt;" to specify the key (source), as follows:

<p>{'No results were found when searching for &lt;%1&gt;'|i18n('design/standard/content/search','',array($search_text|wash))}</p>

Changing that to:

<p>{'No results were found when searching for <%1&>'|i18n('design/standard/content/search','',array($search_text|wash))}</p>

Solved my problem.

It really gave me a headache. I hope this post will be useful to someone else.
And maybe this aspect of the i18n process should be pointed out in the documentation.

Regards,
Mirko.

Monday 01 February 2010 5:50:16 pm

Hello,

For me, the translation from English to French using the above solution didn't work. Maybe have I missed or misunderstood something in the above explanation.

So here is what I did. First of all, I must precise that I didn't use the Greater/lower signs. I used the double quotes instead.

In my template I put this :

<code>

<div class="feedback">
<h2>{"Search for \"%1\" returned %2 matches"|i18n("presse/content/search",,array($search_text|wash,$search_count))}</h2>
</div>
</code>

And in my translation.ts file I put in the right section (for me, in the "presse/content/search" section) the following :

<code>

<message>
<source>Search for "%1" returned %2 matches</source>
<translation>La recherche de "%1" a retourné %2 résultats</translation>
</message>

</code>

The displayed result on my page when I switch to French is :

La recherche de "mon texte" a retourné 7 résultats

The displayed result on my page when I switch to English is :

Search for "mon texte" returned 7 matches

If it can help happy.gif Emoticon

Cheers!

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from