This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
en:dev:284:translate [16.05.2015 11:47] – created Manuela v.d.Decken | en:dev:284:translate [14.08.2015 06:44] – finished translation and removed fixme mrbaseman | ||
---|---|---|---|
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)// | + | ====== |
- | + | **Translate** | |
- | ====== | + | The days when adventurous constructs like the following had to be integrated |
- | **Translate** | + | |
- | Die Zeiten, als in Addons die Übersetzungen noch mit solchen und ähnlichen, abenteuerlichen Konstrukten ' | + | |
// Load Language file | // Load Language file | ||
if(LANGUAGE_LOADED) { | if(LANGUAGE_LOADED) { | ||
Line 12: | Line 10: | ||
} | } | ||
} | } | ||
- | </ | + | </ |
- | und schon ist alles erledigt. | + | is needed, and you are done. |
- | Wenn jetzt die berechtigte Frage kommt: 'was ist dann alles erledigt?', | + | 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.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 |
- | ==== Das Grundsystem hinter | + | ==== The basic system behind |
- | Translate | + | Translate |
- | Diese Aufteilung vereinfacht die Arbeit eines Entwicklers. Er muss nicht mehr 'halbwegs passende' | + | This division simplifies the work of a developer. He no longer has to find 'halfway matching' |
- | Was sollen Sprachdateien | + | What are language files good for in templates |
- | Alle Sprachdateien sind 'Ausgabe-Global' | + | All language files are 'output |
- | + | ==== Structure of translation tables | |
- | ==== Struktur der Translation Tabellen | + | |
{{: | {{: | ||
- | // | + | // |
- | Wenn man sich die Tabelle links (Auszug aus der Sprachauswahl des FireFox) anschaut, erkennt man bereits verschiedene chinesische, mehrere deutsche und noch mehr verschiedene englische Sprachweisen. Die bisher genutzten, simplen | + | 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 |
{{ : | {{ : | ||
- | // | + | // |
- | * //**primary | + | * //**Primary |
- | * //**region | + | * //**Region |
- | * //**variant | + | * //**Variant |
- | Mit diesem System können fast alle auf der Erde vorkommenden Sprachen und Sprachvariationen abgebildet werden. In den vollständigen | + | 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, including the used character set (script). We have restricted ourselves here deliberately only to the actual language code plus the regional allocation. The Variant |
- | + | ==== How does Translate | |
- | ==== Wie verarbeitet | + | The complete structure of Translate |
- | Die komplette Struktur von Translate | + | - The system language |
- | - die Systemsprache | + | - The default language |
- | - die Default-Sprache | + | - The user language |
- | - die Benutzersprache | + | 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 |
- | Für jede Spracheinstellung wird jetzt eine Hilfstabelle aufgebaut, die sich jeweils wiederum aus bis zu 3 Sprachdateien zusammengemischt, die der Sprachcode vorgibt. Diese 3 Hilfstabellen werden nur in der Reihenfolge | + | Exactly as just described for the central translation table, it also happens the same way for each individual module and its template |
- | 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 abgerufen werden. Der einfachste Weg ist:\\ | + | |
- | <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:\\ | + | ==== 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[' | ||