Skip to content

Translations

xolf edited this page Jul 13, 2018 · 4 revisions

Setup

All the translation files are located in /files/Translations/{language}. The normal fallback language is de, however you're able to change this in your _conf.php. So if no specific language is provided, Dreamcoil will use the translation from the fallback directory. All translation files return an array, with the translations. The file name is used for the namespace.

Usage

$trans = new Translate();

// Hello
echo $trans->get('main.hello');

// Static example:
// Hello
echo \Dreamcoil::__('main.hello');

// Placeholder example:
// Dreamcoil reached 2134 downloads
echo $trans->get('main.downloads', ['downloads' => 2134]);

// Disable HTML-Escaping
echo $trans->get('main.escape'); // Ö - ä
define("DISABLE_DREAMCOIL_TRANSLATE_HTML_ESCAPE", true);
echo $trans->get('main.escape'); // Ö - ä

/files/Translations/en/main.php

return [
    'hello' => 'Welcome to Dreamcoil!',
    'downloads' => 'Dreamcoil reached %downloads% downloads',
    'escape' => 'Ö - ä'
]

Cache

All translate keys, got stored. So Dreamcoil looks for a file once, saves all the translation keys to memory.

Navigation

First use

Clone this wiki locally