Forums / Developer / Use i18n in php

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

eZ debug

Timing: Jan 17 2025 23:56:03
Script start
Timing: Jan 17 2025 23:56:03
Module start 'content'
Timing: Jan 17 2025 23:56:05
Module end 'content'
Timing: Jan 17 2025 23:56:05
Script end

Main resources:

Total runtime1.8814 sec
Peak memory usage4,096.0000 KB
Database Queries199

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0070 588.7031180.8594
Module start 'content' 0.00701.7394 769.5625605.5078
Module end 'content' 1.74640.1350 1,375.0703337.3906
Script end 1.8814  1,712.4609 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00380.2022210.0002
Check MTime0.00150.0792210.0001
Mysql Total
Database connection0.00100.052010.0010
Mysqli_queries1.798395.58121990.0090
Looping result0.00230.12311970.0000
Template Total1.854498.620.9272
Template load0.00210.111220.0010
Template processing1.852398.449220.9261
Template load and register function0.00010.007210.0001
states
state_id_array0.00060.033610.0006
state_identifier_array0.00150.081020.0008
Override
Cache load0.00160.0838330.0000
Sytem overhead
Fetch class attribute can translate value0.00150.081640.0004
Fetch class attribute name0.00200.105270.0003
XML
Image XML parsing0.00320.168540.0008
class_abstraction
Instantiating content class attribute0.00000.000880.0000
General
dbfile0.00580.3083390.0001
String conversion0.00000.000430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/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
1content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 24
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs