This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:dev:284:translate [14.08.2015 06:34] – [Wie wird Translate benutzt?] translated first half mrbaseman | en:dev:284:translate [18.07.2018 12:46] (current) – [Translations before 2.8.4] Manuela v.d.Decken | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | FIXME **This page is not fully translated, yet. Please help completing the translation.**\\ //(remove this paragraph once the translation is finished)// | ||
- | |||
====== Centralized management of translations ====== | ====== Centralized management of translations ====== | ||
**Translate** is a package consisting of several classes, that already in WB 2.8.4 take care about all the handling of translations known as ' | **Translate** is a package consisting of several classes, that already in WB 2.8.4 take care about all the handling of translations known as ' | ||
Line 20: | Line 18: | ||
==== General ==== | ==== General ==== | ||
For simplicity, I'm talking only about ' | For simplicity, I'm talking only about ' | ||
- | ==== Translations before 2.8.4 ==== | + | ==== Translations before 2.10.0 ==== |
- | Let's start at the current level at the beginning of 2.8.4 and earlier. In the central language directory of the core, there are a large number of language files (DE.php | EN.php | etc.). Each of these files contains an overwhelmingly large number of language variables (specifically, | + | Let's start at the current level at the beginning of 2.10.0 and earlier. In the central language directory of the core, there are a large number of language files (DE.php | EN.php | etc.). Each of these files contains an overwhelmingly large number of language variables (specifically, |
+ | === Aufbau der Sprachdateien (EN.php) === | ||
+ | < | ||
+ | //Modul Description | ||
+ | $module_description = 'Enter here a really short description of your module. About 200-250 characters should suffice.'; | ||
+ | |||
+ | $MOD_MyModule[' | ||
+ | $MOD_MyModule[' | ||
+ | $MOD_MyModule[' | ||
+ | $MOD_MyModule[' | ||
+ | $MOD_MyModule[' | ||
+ | $MOD_MyModule[' | ||
+ | $MOD_MyModule[' | ||
+ | </ | ||
+ | somebody wrote this kind of entries: | ||
+ | < | ||
+ | $MOD_MyModule[' | ||
+ | $MOD_MyModule_TEXT[' | ||
+ | $MOD_MyModule_MESSAGE[' | ||
+ | </ | ||
+ | It does not look that good, but it works. Both syntax lead to the same Translate keys. | ||
+ | < | ||
+ | echo $oTrans-> | ||
+ | echo $oTrans-> | ||
+ | echo $oTrans-> | ||
+ | echo $oTrans-> | ||
+ | echo $oTrans-> | ||
+ | echo $oTrans-> | ||
+ | echo $oTrans-> | ||
+ | </ | ||
+ | |||
+ | |||
==== The basic system behind Translate ==== | ==== The basic system behind Translate ==== | ||
Line 36: | Line 66: | ||
When you look at the table on the left (Extract from the Language support of Firefox), you can already see various Chinese, several German and English language in several dialects. The previously used, simple 2-letter codes purely following [[http:// | When you look at the table on the left (Extract from the Language support of Firefox), you can already see various Chinese, several German and English language in several dialects. The previously used, simple 2-letter codes purely following [[http:// | ||
- | {{ : | + | {{ : |
// | // | ||
* //**Primary language subtag**// based on [[http:// | * //**Primary language subtag**// based on [[http:// | ||
Line 59: | Line 89: | ||
Even simpler with add-on files that are called Core-controlled: | Even simpler with add-on files that are called Core-controlled: | ||
- | Jetzt müssen eigentlich nur noch die Übersetzungstexte von Translate | + | Now basically the only thing left is actually to call the translated texts by Translate. |
- | <php> $sText = Translate:: | + | <php> $sText = Translate:: |
- | + | ||
- | Für ältere Addons existiert vorübergehend eine Methode, sämtliche Übersetzungstexte in einem Zug an die // | + | |
- | <php> $template-> | + | |
- | Das Problem bei dieser Methode ist, dass immer eine komplette Kopie der Übersetzungstabelle an die Templateengine übergeben wird. | + | |
- | + | ||
- | Wesentlich einfacher und platzsparender ist die Verwendung in Verbindung mit Twig, da hier nur eine speichersparende Referenz auf das Translateobjekt übergeben wird:\\ | + | |
- | <php> $aTwigData[' | + | |
- | + | ||
+ | Temporarily for older Addons a method exists that allows to pass all translation texts in one rushto the // | ||
+ | <php> $template-> | ||
+ | The problem with this method is that always a complete copy of the translation table is passed to the Template Engine. | ||
+ | Much easier and less space is used in conjunction with Twig, since only a memory-saving reference is passed to the Translate object:\\ | ||
+ | <php> $aTwigData[' | ||