Use i18n in php

Author Message

Paul Etienney

Sunday 05 December 2010 10:04:05 pm

Hello eZ riders,

My question is very simple yet i did not find the right resource.

I need to translate text in a php module using the same mechanism as the i18n operator but i can't find the way to make this code work properly :

$language = ezcurrentLanguage();            
if ( $language != "eng-GB" )
{
$file = 'translation.ts';
$ini = eZINI::instance();
$useCache = $ini->variable( 'RegionalSettings', 'TranslationCache' ) != 'disabled';
eZTSTranslator::initialize( $context, $language, $file, $useCache );
$man = eZTranslatorManager::instance();
$newValue = $man->translate( $context, $value, $comment );
if ( $newValue )
{
$value = $newValue;
}

Thanks

-- Good websites creation --
My site : http://www.pauletienney.com
Twitter : http://www.twitter.com/p_etienney

Daisy Radix

Sunday 05 December 2010 11:29:22 pm

Hello,

Check the file kernel/common/ezpi18n.php ( tr function) :)

eZ Publish certified developper :http://auth.ez.no/certification/verify/378142

Paul Etienney

Friday 24 December 2010 8:58:02 am

Shame on me ! It was soooooooo easy !

If you want to user the i18n operator in php module just do this :

eZTranslateText( 'contextName', 'text to translate');

And that's it !

Merry Christmas.

-- Good websites creation --
My site : http://www.pauletienney.com
Twitter : http://www.twitter.com/p_etienney

Nicolas Pastorino

Friday 24 December 2010 11:16:26 am

"

Shame on me ! It was soooooooo easy !

If you want to user the i18n operator in php module just do this :

eZTranslateText( 'contextName', 'text to translate');

And that's it !

Merry Christmas.

"

Merry Christmas to you too !

But...i could not get a hold on this eZTranslateText function (4.4) :)

I usually use the following :

ezpI18n::tr( $context, $source, $comment = null, $arguments = null )

Cheers !

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

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