Forums / General / Translation of variables

Translation of variables

Author Message

Claudia Kosny

Sunday 27 August 2006 3:59:34 am

Hi there

I would like to use the i18n operator on string variables but have problems using ezlupdate with this.
Example:

{def $countries = ezini('CountrySettings','Countries', 'content.ini')}
<select >
 {foreach $countries as $current_country}
   <option value="{$current_country}">{$current_country|i18n('my/countries')}</option>
 {/foreach}
</select>

What I want to achieve is that the countries are translated in the current language, even though they are only in English in the ini file.

The translation itself works absolutely fine (provided I added the proper entries in the translation.ts) , the only problem is the ezlupdate program. The program exits when encountering an argument that is not enclosed by quotation marks. I can certainly understand that it is not possible to create a proper entry in the translation.ts file for an argument which is not a string. But I don't see why the program does not just skip this entry and continues scanning the rest of my templates.

I have read the bug reports regarding this problem but they were closed without giving a solution.
The suggestion by Marc Boon to use

{'%var'|i18n('context','comment',hash('%var',$var))}

does not work as this way the content of the variable is not translated, just passed through.

My current workaround is to remove the offending line in my template, run ezlupdate and then add the line again, which is certainly workable but error-prone.

So here finally my question: Could someone give me some pointers on how to change the exlupdate such that it just skips invalid arguments (with an error message)? Or, if that does not cause problems with any licenses, couldsomeone contribute such a version, preferably for both Windows and Linux?

Thanks

Claudia

Thomas Nunninger

Sunday 27 August 2006 6:04:58 am

Hi Claudia,

I'm no C programmer. But I guess the solution is in file 'fetchtr_tpl.cpp'. Around line 164 I find:

        if ( endpos < 0 )
        {
            qWarning( filename + ":error: Found non-quoted context, skipping translation" );
            exit( 1 );
//             continue;
        }

Perhaps it's enough to comment the exit and uncomment the continue... I would try if it skips variables correctly then. Also I would make a diff of the result of translation.ts before and after changing the C code to ensure that everything works as expected (of course without variables in the templates to translate).

Additionally you can change the qWarning function like:

qWarning( filename + ":error: Found non-quoted context, skipping translation" + "content: " + content );

Then you should see the skipped content strings.

If you got an other error message just search for it in the code and try to solve it in a similar way. There are only two other exit commands between line 144 and 174. Shouldn't be that hard... With printing the content variable it should be solvable.

But I don't know if you will run in some other problems of wrong strings where e.g. only one quotation marks exists (or whatever). (Perhaps there is a reason for the exit instead of continue...)

Would be nice to hear if it works.

Have a nice day

Thomas

Claudia Kosny

Sunday 27 August 2006 11:35:48 pm

Hi Thomas

Thank you for the tips. I tried it yesterday but unfortunately I seem to have some problems with qt on my computer, so I will have to try it again whenI have more time to solve this.

I'll post my results once I get it done.

Claudia

Ludovic André

Thursday 08 February 2007 7:00:52 am

Hi Claudia,

just to give a little feedback about changing the C code of ezlupdate, I did this today... I encountered the same problem as you, and yeah it's really boring to remove the things from the template, generate the file, then replace the stuff in the template.
I removed the exit(1) called when empty source, and uncommented the continue line.

It appeared to be working properly as of now...

Hope it helps!

Regards

Ludovic André

eZ debug

Timing: Jan 18 2025 15:19:23
Script start
Timing: Jan 18 2025 15:19:23
Module start 'content'
Timing: Jan 18 2025 15:19:24
Module end 'content'
Timing: Jan 18 2025 15:19:24
Script end

Main resources:

Total runtime0.7685 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.0060 587.6875180.8438
Module start 'content' 0.00610.6647 768.5313595.7813
Module end 'content' 0.67070.0978 1,364.3125337.3984
Script end 0.7685  1,701.7109 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00380.4983210.0002
Check MTime0.00150.1890210.0001
Mysql Total
Database connection0.00080.107110.0008
Mysqli_queries0.707592.05701990.0036
Looping result0.00160.20181970.0000
Template Total0.737295.920.3686
Template load0.00210.274520.0011
Template processing0.735195.652620.3676
Template load and register function0.00010.018610.0001
states
state_id_array0.00090.110710.0009
state_identifier_array0.00120.156620.0006
Override
Cache load0.00190.2439430.0000
Sytem overhead
Fetch class attribute can translate value0.00110.139140.0003
Fetch class attribute name0.00080.110450.0002
XML
Image XML parsing0.00110.142640.0003
class_abstraction
Instantiating content class attribute0.00000.001150.0000
General
dbfile0.00170.2197270.0001
String conversion0.00000.000630.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/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.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/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 25
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs