| | 43 | |
| | 44 | [[BR]] |
| | 45 | |
| | 46 | == 4. Use the right i18n (internationalization) function == |
| | 47 | |
| | 48 | Indico'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. |
| | 49 | Be careful not to use a Python function inside a Javascript string, for example: |
| | 50 | {{{ |
| | 51 | #!js |
| | 52 | var today = '<%=_("Today") %>'; |
| | 53 | }}} |
| | 54 | will become, when rendered in English: |
| | 55 | {{{ |
| | 56 | #!js |
| | 57 | var today = 'Today'; |
| | 58 | }}} |
| | 59 | But when rendered in French, it will become: |
| | 60 | {{{ |
| | 61 | #!js |
| | 62 | var today = 'Aujourd'hui'; |
| | 63 | }}} |
| | 64 | This will provoke a syntax error because the string was using single quotes ('). |
| | 65 | |
| | 66 | Therefore, the correct thing to do is: |
| | 67 | {{{ |
| | 68 | #!js |
| | 69 | var today = $T("Today"); |
| | 70 | }}} |