Multilingual static texts: how to reuse and customise ?

Author Message

Xavier Dutoit

Wednesday 12 July 2006 11:33:50 pm

Hi,

Since the 3.8 version provides a much more usable multiligual content managemeny system, I'm trying to use the native ez functions for that.

I want to have one design for all the languages, and I obvioulsy have some static content in it (eg. a button "home page").

I'm wondering if I can use the already translated texts.

I could find some (eg design/admin/content/search contains "search"), but I haven't been able to find most (eg "home page").

How do you do ? Are you re-using existing translations or do everything ?

Moreover, I'd like to create my own .ts, but don't know where to put it so it's taken into account. I couldn't find anything about creating your own translation without having to create an extension (and even so, that's more by looking at the existing code). Is there a doc you could refer me too ?

Thanks in advance,

X+

http://www.sydesy.com

Ɓukasz Serwatka

Friday 14 July 2006 12:03:57 am

Salut!

There are 3 approches if you can't find already translated text in the exisiting translations:

1. Add missing translation to existing files under share/translation. This is less flexible since you need to take care about future updates, but of course the fastest way to add missing untranslated labels.

2. Create translation extension:

Extension structure:

extension
	|
	| - - mytranslationext
			|
			| - - settings
			|	| - - site.ini.append.php
			|
			| - - translations
				|
				| - - pol-PL
				|	| - - translation.ts
				|
				| - - fre-FR
				|	| - - translation.ts
				|
				| - - untranslated
					| - - translation.ts
						

Source: extension/mytranslationext/settings/site.ini.append.php

<?php /*

[RegionalSettings]
TranslationExtensions[]=mytranslationext

*/ ?>

This is example content of untranslated translation.ts XML file. This is source file for other translation used in the extension. Use QT Linguist to make the translation:

Source: extension/mytranslationext/translations/untranslated/translation.ts

<!DOCTYPE TS><TS>
<context>
    <name>extension/mytranslationext</name>
    <message>
        <source>Example lable</source>
        <comment>Example comment</comment>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <source>More examples</source>
        <translation type="unfinished"></translation>
    </message>
</context>
</TS>

In templates use:

{'Example'|i18n( 'extension/mytranslationext' )}

Where i18n as parameter takes context name from your extension translation.ts.

3. Define translation with missing strings as an array then check current object locale and display correct translation.

I would recommend use translation extension.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Xavier Dutoit

Friday 14 July 2006 12:41:29 am

Hi,

Thanks for the explainations.

As an evolution, wouldn't it make sense to be able to put translations into the design instead of having another extension ? I mean, the translations are going to be used by the templates, so I'd rather keep them together instead of ending with one extension per site on the top of one settings/siteaccess and design/

I remember having seen a web interface to manage translations, but couldn't put my hand on it on the contrib. Does it rig a bell to someone or was I day dreaming ?

I'll let you know if I can find it ....

BTW, ez still doesn't provide any way to access the translation into another language than the current one (,something like : {'Example'|i18n( 'extension/mytranslationext',"eng-UK" )} ? That would come really handy.

http://www.sydesy.com

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