This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:dev:284:translate [13.08.2015 20:23] – [Zentrale Verwaltung der Übersetzungen] translated 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 15: | Line 13: | ||
is needed, and you are done. | is needed, and you are done. | ||
- | If you now pose the legitimate question: 'is that all?', | + | If you now pose the legitimate question: 'is that all?', |
- | ===== Allgemeiner Aufbau der Übersetzungs-Struktur | + | ===== General structure of the translation mechanism |
- | ==== Allgemein | + | ==== General |
- | Der Einfachheit halber rede ich hier immer nur von 'Sprachdateien' | + | For simplicity, I'm talking only about 'language files' here. However, in real case usage the translations no longer have to be defined necessarily as arrays |
- | ==== Übersetzungen vor 2.8.4 ==== | + | ==== Translations before |
- | Fangen wir beim aktuellen Stand zu Beginn der 2.8.4 und zuvor an. Im zentralen Sprachverzeichnis des Core existieren eine große Anzahl von Sprachdateien | + | 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 |
+ | === Aufbau der Sprachdateien (EN.php) === | ||
+ | < | ||
+ | //Modul Description | ||
+ | $module_description = 'Enter here a really short description of your module. About 200-250 characters should suffice.'; | ||
- | ==== Das Grundsystem hinter Translate ==== | + | $MOD_MyModule[' |
- | Translate basiert auf der Vorgabe, dass Sprachdateien grundsätzlich jeweils nur die für den jeweiligen Bereich notwendigen Einträge enthalten. Im Gegenzug werden relativ viele, kleine Sprachdateien eingesetzt. Jedes Addon, jede ACP-Erweiterung **muss** und sogar jedes einzelne Template/ | + | $MOD_MyModule[' |
- | Diese Aufteilung vereinfacht die Arbeit eines Entwicklers. Er muss nicht mehr 'halbwegs passende' | + | $MOD_MyModule[' |
- | Was sollen Sprachdateien in Templates?? \\ | + | $MOD_MyModule[' |
- | Alle Sprachdateien sind 'Ausgabe-Global' | + | $MOD_MyModule[' |
+ | $MOD_MyModule[' | ||
+ | $MOD_MyModule['MESSAGE_ARCHIVE_NOT_DELETED'] = ' | ||
+ | </PHP> | ||
+ | somebody wrote this kind of entries: | ||
+ | < | ||
+ | $MOD_MyModule['PRINT' | ||
+ | $MOD_MyModule_TEXT[' | ||
+ | $MOD_MyModule_MESSAGE['ARCHIVE_DELETED'] = ' | ||
+ | </PHP> | ||
+ | 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-> | ||
+ | </ | ||
- | ==== Struktur der Translation Tabellen ==== | ||
- | {{: | ||
- | //**Translate**// arbeitet intern mit mehreren Übersetzungstabellen (TranslationTable). Jede dieser Tabellen setzt sich aus einer bis maximal | + | ==== The basic system behind Translate ==== |
+ | Translate is based on the premise that language files generally contain only the necessary items for each area. In return, a relatively large number of small language files is used. Each addon, each ACP extension | ||
+ | This division simplifies the work of a developer. He no longer has to find 'halfway matching' | ||
+ | What are language files good for in templates ?? \\ | ||
+ | All language files are ' | ||
- | Wenn man sich die Tabelle links (Auszug aus der Sprachauswahl des FireFox) anschaut, erkennt man bereits verschiedene chinesische, | + | ==== Structure of translation tables ==== |
- | {{ : | + | |
- | // | + | |
- | * //**primary language subtag**// basierend auf [[http:// | + | |
- | * //**region subtag**// basierend auf [[http:// | + | |
- | * //**variant subtags**// auszugsweise basierend auf der [[http:// | + | |
- | Mit diesem System können fast alle auf der Erde vorkommenden Sprachen und Sprachvariationen abgebildet werden. In den vollständigen IETF-Tags stünden noch weit mehr Informationen, | + | |
- | ==== Wie verarbeitet Translate jetzt diese Informationen? | + | {{:dev:284:translate:sprachcountrycodes-de.gif?nolink |Sprachauswahl im FireFox}} |
- | Die komplette Struktur von Translate basiert auf komplexen Übersetzungstabellen die jeweils für den Core, ein Modul oder ein Template zuständig sind. Der Grundstruktur basiert auf den 3 Spracheinstellungen und dem FallBack-Mechanismus, | + | |
- | - die Systemsprache (SYSTEM_LANGUAGE). Das ist die Sprache des Systems, auf deren Basis grundsätzlich programmiert wird. In der Regel einfaches Englisch **[en]**. | + | |
- | - die Default-Sprache (DEFAULT_LANGUAGE), | + | |
- | - die Benutzersprache (USER_LANGUAGE), | + | |
- | Für jede Spracheinstellung wird jetzt eine Hilfstabelle aufgebaut, die sich jeweils wiederum aus bis zu 3 Sprachdateien zusammengemischt, | + | |
- | So wie das jetzt für die zentrale Übersetzungstabelle beschrieben ist, exakt genau so geschieht es auch für jedes einzelne Modul und dessen Template, das Sprachdateien mitliefert und das auch tatsächlich geladen und benutzt wird. | + | |
- | + | ||
- | + | ||
- | ==== Wie wird Translate benutzt? ==== | + | |
- | + | ||
- | Für Addon-Entwickler ist Translate sehr einfach einzusetzen. Die Grundinitialisierung wird **immer** automatisch vom Core vorgenommen und Addons haben damit überhaupt nichts zu schaffen. Bei älteren Addons, die noch PHP-Dateien enthalten, die direkt von außen aufgerufen werden müssen, sind 2 bis maximal 4 Translate-Methoden erforderlich (alle Kommandos werden in der Standalone-Form angegeben). Bedingung für den Einsatz von Translate ist, dass die Datei '' | + | |
- | * < | + | |
- | * < | + | |
- | * < | + | |
- | * < | + | |
- | Einfacher noch geht es bei Addon-Dateien, | + | |
- | Jetzt müssen eigentlich nur noch die Übersetzungstexte von Translate | + | //**Translate**// works internally with several translation tables |
- | <php> $sText = Translate:: | + | |
- | Für ältere Addons existiert vorübergehend eine Methode, sämtliche Übersetzungstexte | + | 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 |
- | <php> $template->set_var(Translate:: | + | {{ : |
- | Das Problem bei dieser Methode ist, dass immer eine komplette Kopie der Übersetzungstabelle an die Templateengine übergeben wird. | + | // |
+ | * //**Primary language subtag**// based on [[http:// | ||
+ | * //**Region subtag**// based on [[http:// | ||
+ | * //**Variant subtags**// in part based on the [[http:// | ||
+ | With this system, almost all languages and language variations occurring in the world can be mapped. In the full IETF tags still stood far more information, | ||
+ | ==== How does Translate | ||
+ | The complete structure of Translate is based on complex translation tables which are each responsible for the core, a module or template. The basic structure is based on the 3 language settings and the fallback mechanism specified by WebsiteBaker: \\ | ||
+ | - The system language | ||
+ | | ||
+ | - The user language (USER_LANGUAGE) that the individual visitor to the website chooses. | ||
+ | Now, an auxiliary table is set up for each language setting, each in turn mixed together from up to 3 language files, which specifies the language code. This 3 auxiliary tables are then mapped together in the order System->Default-> | ||
+ | Exactly as just described for the central translation table, it also happens the same way for each individual module and its template which ships with language files and actually loads and uses them. | ||
- | Wesentlich einfacher und platzsparender ist die Verwendung in Verbindung mit Twig, da hier nur eine speichersparende Referenz auf das Translateobjekt übergeben wird:\\ | + | ==== How to use Translate |
- | <php> $aTwigData[' | + | |
+ | For Addon developers Translate is very easy to use. The basic initialization is done automatically **always** from Core and therefore Addons don't have to care at all about this mechanism. In older addons that contain PHP files that need to be called directly from the outside, 2 to a maximum of 4 Translate methods need to be called (all commands are given in the form of standalone). Condition for the use of Translate is that the file '' | ||
+ | * < | ||
+ | * < | ||
+ | * < | ||
+ | * < | ||
+ | Even simpler with add-on files that are called Core-controlled: | ||
+ | Now basically the only thing left is actually to call the translated texts by Translate. The easiest way is: \\ | ||
+ | <php> $sText = Translate:: | ||
+ | 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[' | ||