Changes between Version 3 and Version 4 of Dev/Technical/CodeCaveats


Ignore:
Timestamp:
03/25/10 13:59:32 (5 years ago)
Author:
dmartinc
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Dev/Technical/CodeCaveats

    v3 v4  
    4141 
    4242Using [/wiki/Dev/Tools#a3.PylintwithPyDev PyLint] helps detect these problems. 
     43 
     44[[BR]] 
     45 
     46== 4. Use the right i18n (internationalization) function == 
     47 
     48Indico's interface should be multi-language; for this, we have the _ function on the server (Python) side (import with from MaKaC.i18n import _ ), and the $T Javascript function in the client side. 
     49Be careful not to use a Python function inside a Javascript string, for example: 
     50{{{ 
     51#!js 
     52var today = '<%=_("Today") %>'; 
     53}}} 
     54will become, when rendered in English: 
     55{{{ 
     56#!js 
     57var today = 'Today'; 
     58}}} 
     59But when rendered in French, it will become: 
     60{{{ 
     61#!js 
     62var today = 'Aujourd'hui'; 
     63}}} 
     64This will provoke a syntax error because the string was using single quotes ('). 
     65 
     66Therefore, the correct thing to do is: 
     67{{{ 
     68#!js 
     69var today = $T("Today"); 
     70}}}