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.

eZ debug

Timing: Jan 18 2025 22:14:15
Script start
Timing: Jan 18 2025 22:14:15
Module start 'layout'
Timing: Jan 18 2025 22:14:15
Module start 'content'
Timing: Jan 18 2025 22:14:15
Module end 'content'
Timing: Jan 18 2025 22:14:15
Script end

Main resources:

Total runtime0.7331 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0066 589.2891152.6563
Module start 'layout' 0.00660.0022 741.945339.5078
Module start 'content' 0.00880.7229 781.4531556.5234
Module end 'content' 0.73170.0014 1,337.976612.1094
Script end 0.7331  1,350.0859 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.5286160.0002
Check MTime0.00180.2425160.0001
Mysql Total
Database connection0.00090.119510.0009
Mysqli_queries0.669291.2839570.0117
Looping result0.00060.0793550.0000
Template Total0.703495.920.3517
Template load0.00220.300820.0011
Template processing0.701295.637220.3506
Template load and register function0.00010.015010.0001
states
state_id_array0.00080.109910.0008
state_identifier_array0.00090.118420.0004
Override
Cache load0.00190.2574390.0000
Sytem overhead
Fetch class attribute can translate value0.00080.106120.0004
Fetch class attribute name0.00210.285050.0004
XML
Image XML parsing0.00080.115420.0004
class_abstraction
Instantiating content class attribute0.00000.002560.0000
General
dbfile0.00080.1089240.0000
String conversion0.00000.001040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 19
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs