Localization#
i-doit supports multilingualism -- currently limited to German and English, managed through "translation files". These files are located in the add-on directory underneath the "lang" folder and follow the naming scheme "
Global Translations#
In i-doit, there are many (>400) "universal" translations, such as "Designation", "Yes", "No", and many more. These are located in i-doit's own translation files (e.g., "
Custom Translations#
We use so-called "language constants" that always begin with the string "LC_" and include the add-on identifier in their name to guarantee uniqueness and prevent potential collisions. An additional "grouping" of constants is done through word separation using double underscores ("__"). This grouping is used to separate constants for navigation, authorization system, or error messages from each other, for example.
The content of a translation file looks as follows ("
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
Since i-doit 1.10.2, translations no longer need to be manually registered in the init.php. i-doit will include the required translations automatically.
Usage in PHP Code#
To use translations in PHP code, the "language" service from the Dependency Injection Container must be used:
1 2 3 4 5 6 7 | |
Usage in Smarty Templates#
We provide a Smarty plugin to also access translated language constants in the template context:
1 | |
Usage in JavaScript#
For usage in JavaScript, a small detour via a Smarty template is necessary. Under certain circumstances, a parameter must be used to prevent HTML entities from being output in JavaScript:
1 2 3 4 5 6 7 8 9 10 11 | |
Alternatively, it is possible to load translations via an Ajax request or include JavaScript files via Smarty "include" to then work with Smarty within the JavaScript file -- however, we advise against this!
Smarty in JavaScript
We recommend keeping any Smarty code out of JavaScript files!