I'm crazy with i18n

Author Message

Adolfo Barragán

Saturday 12 August 2006 1:59:57 am

Please, excuse me the lenght of message, but I'm exasperate with i18n

I try build a multilingual site and I need translate some static (hard coded) text on template. I follow instructions on http://ez.no/community/forum/setup_design/multilingual_static_texts_how_to_reuse_and_customise but I get nothing.

I've created the extension:

ezpublishroot
  |
  |-- extension
      |
      |-- StaticText
          |
          |- settings
          |    |
          |    |- site.ini.append.php         
          |
          |- translations
              |- esl-ES
              |    |
              |    |- translation.ts
              |
              |- untranslated
                  |
                  |- translation.ts

I've activated the extension in settings/override/site.ini.append.php:

[ExtensionSettings]
ActiveExtensions[]=ezdhtml
ActiveExtensions[]=StaticText

I've create my own "translation.ts" file under esl-ES with this content:

<!DOCTYPE TS><TS>
<context>
    <name>huntingservices/monterias</name>
   ...
    <message>
        <source>make reservation</source>
        <translation>efectuar reserva</translation>
    </message>
   ...
</context>
</TS>

On template, I have:

    <input type="image" src={"reservar.gif"|ezimage} alt={'make reservation'|i18n('huntingservices/monterias')} title={'make reservation'|i18n('huntingservices/monterias')} width="24" height="24" name="ActionAddToBasket" />

With these settings I don't get translated text and, also, I only get the first word (i.e: I only get "make" ).

If I copy content of <i>extension/StaticText/translations/esl-ES/translation.ts</i> on <i>share/translations/esl-ES/translation.ts</i> then, it work, but I only get first word: In english site the hint of image show "make" and in spanish site show "efectuar".

What is wrong?

regards
Adolfo Barragán

Claudia Kosny

Saturday 12 August 2006 2:30:33 pm

Hello Adolfo,

I can at least tell you the most likely reason why you see only the word 'make' (or the respective translation): In you template code you need to suround the content of the of the alt attribute with quotes, otherwise your brwoser simply does not know that the second word belogs to the alt attribute es well. The same applies for the title attribute.

So the correct template code would be:

<input type="image" src={"reservar.gif"|ezimage} alt="{'make reservation'|i18n('huntingservices/monterias')}" title="{'make reservation'|i18n('huntingservices/monterias')}" width="24" height="24" name="ActionAddToBasket" />

Regarding the problem that your translation does not work if the translation.ts is part of the extension:
Did you add

[RegionalSettings]
TranslationExtensions[]=myextension

(See also http://ez.no/products/ez_publish/documentation/development/extensions/translation)

Good luck

Claudia

Adolfo Barragán

Saturday 12 August 2006 11:30:19 pm

Hello Claudia:

I surrounded by quotes the content of the alt ant title attributes and I get now all words.

Regarding problem with extension:

[RegionalSettings]
TranslationExtensions[]=myextension

Yes, I put these settings in <i>extension/StaticText/settings/site.ini.append.php</i> and in <i>settings/siteaccess/es/site.ini.append.php</i> but I can't use traslation as an extension. I get untranslated text.

Thanks,
Adolfo Barragán

Claudia Kosny

Sunday 13 August 2006 7:50:51 am

Hi Adolfo,

I would go straight to the function responsible for loading the .ts files and check what directories are used there.
The easiest (though most likely not the most elegant) way is to go to the file
\lib\ezi18n\classes\eztstranslator.php and insert some wellplaced debug notices in the function loadTranslationFile. (Don't forget to make a backup of the file ...)

With eZDebug::writeNotice( 'using translation folders:' . print_r($this>RootCache, true)); in line 146 you can see what directories are considered for holding translations.

An eZDebug::writeNotice( 'found translation file:' . $path); at the end of the foreach ( $roots as $root ) loop (line 171) will show you what files are considered.

(Please note that line numbers might differ slightly as played around with the formatting of this file and I am to lazy to download a fresh copy.)

Save the file, enable debug output, clear the cache and refresh your webpage. In the debug output you should now see the at least some information about what EZ is doing.

If your folder or file does not turn up there, make sure that you do not have a typo in your site.ini.append or in your filename. If your translation appears to be loaded just fine, please show me your site.ini.append file and maybe also your translation.ts.

Claudia

Maxime Thomas

Thursday 14 September 2006 8:02:54 am

Hi,

I've got the same problem. My extension is well structured but it seems that the translations file is not properly loading. So, I've tried your solution and the path is good.

It's maybe a problem of cache.

Max

Maxime Thomas
maxime.thomas@wascou.org | www.wascou.org | http://twitter.com/wascou

Company Blog : http://www.wascou.org/eng/Company/Blog
Technical Blog : http://share.ez.no/blogs/maxime-thomas

Claudia Kosny

Thursday 14 September 2006 11:33:09 am

Hello

To test the cache theory you could disable the translation cache and see whether it makes a difference. Also try to use a context which is unique to your extension. Does the translation work if you add them into the main translation.ts? Do you get any error messages if you insert any mistakes into your translation.ts (really destroy the xml structure)?

Apart from that I would post a bug report if you are sure that everything else is ok.
Make sure to include all interesting info like the location of your translation.ts, your ini settings, the paths which seem to be loaded in the loadTranslationFile function, any interesting debug notices you get...

Greetings from Luxembourg

Claudia

Maxime Thomas

Monday 18 September 2006 1:16:03 am

This is what I've done :
- I have unplugged my extension,
- I have cleared the cache,
- I have plugged again my extension
And then in the debug, I have seen an error :

Error parsing XML, unmatched tags source

I looked at my XML but it looks allright.

And, I tried to create a new file with just one translation. And it works but all the accents have gone. I changed the encoding type in my editor (CSP512 -> UTF-8) and accents come back.

So this is maybe a problem of encoding type. I've seen in the loadTranslationFile function that ez try at first time to reach a file wich path is :

extension/<my_extension>/translations/<language_code>/<encoding_type>/translation.ts

I don't know more on this problem, but it's very strange and difficult to debug.

Greetings from France.

Max

Maxime Thomas
maxime.thomas@wascou.org | www.wascou.org | http://twitter.com/wascou

Company Blog : http://www.wascou.org/eng/Company/Blog
Technical Blog : http://share.ez.no/blogs/maxime-thomas

Claudia Kosny

Monday 18 September 2006 11:59:48 am

Hi Maxime

With regards to the invalid xml try to open the file in linguist - this will most likely give a line number for the error.

Regarding the new translation file: If you run the whole website using utf-8 (which is the default for the newest EZ versions) every textfile that contains some text which will be displayed on the website has to be utf-8 as well (which is a major annoyance when you use csvimport and your customer has never heard of charsets). If you look at the translation files that are shipped with EZ you can see that they are utf-8 as well.

BTW: What encoding is CSP512?

Greetings from Luxembourg

Claudia

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.