ezscript_require with i18n strings

Author Message

Jerome Despatis

Saturday 29 January 2011 2:48:20 am

Hi,

I've some javascripts (bundled in a global minified .js file thanks to ezscript_require).

In those javascripts, I may have functions that use localized strings. For now, I give those localized strings as an argument to those .js functions, but really not a perfect solution.

=> hence my question: as ezscript_require parses all my .js script, is it possible to use some kind of i18n("...") function in the .js file, and ezscript replaces them according to siteaccess for example (in the case siteaccess is the language)

Or any idea is welcome to use localized strings in a .js file, (that would be parsed by ezlupdate to easily create translation.ts for each foreign language)

Thanks

Jerome Despatis

Saturday 29 January 2011 10:17:12 am

Well gonna use a i18n() js func in my js scripts and an ezjscore server functions to provide this function with all localized strings. As it is a php class, it will get parsed by ezlupdate...

Gaetano Giunta

Monday 31 January 2011 1:16:34 am

Not something I recommend, but you can use the "include" template function to actually have some js files parsed using the template engine (hence translatable via i18n) and included on the page. Just use the 'file:' namespace instead of the 'design:' one. Drawback is that you'll have css/jss inline

Principal Consultant International Business
Member of the Community Project Board

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 05:14:42
Script start
Timing: Jan 18 2025 05:14:42
Module start 'layout'
Timing: Jan 18 2025 05:14:42
Module start 'content'
Timing: Jan 18 2025 05:14:43
Module end 'content'
Timing: Jan 18 2025 05:14:43
Script end

Main resources:

Total runtime0.7357 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.0055 589.0391152.6250
Module start 'layout' 0.00550.0027 741.664139.4688
Module start 'content' 0.00820.7260 781.1328530.3438
Module end 'content' 0.73420.0015 1,311.47668.3125
Script end 0.7357  1,319.7891 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.4245160.0002
Check MTime0.00130.1809160.0001
Mysql Total
Database connection0.00090.125710.0009
Mysqli_queries0.689893.7557570.0121
Looping result0.00060.0876550.0000
Template Total0.705995.920.3529
Template load0.00200.270620.0010
Template processing0.703995.666320.3519
Template load and register function0.00030.034310.0003
states
state_id_array0.00110.154810.0011
state_identifier_array0.00100.139320.0005
Override
Cache load0.00160.2182140.0001
Sytem overhead
Fetch class attribute can translate value0.00060.077020.0003
Fetch class attribute name0.00220.300740.0006
XML
Image XML parsing0.00060.081120.0003
class_abstraction
Instantiating content class attribute0.00000.001540.0000
General
dbfile0.00080.1134160.0001
String conversion0.00000.001140.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/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
3content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 9
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs