Mecha CMS

Deep learning on using the API.

Class Language

Author: Taufik Nurrohman · 100 Views

Tweet

Internationalization.

Constructor 

Language($input = []);

Example:

Get language files from the lot\language folder then convert it into object:

$language = new Language;

Set 

Set new language property:

$language->foo = 'bar';
Language::set('foo', 'bar');

Get 

Get language property:

echo $language->foo;
echo Language::get('foo');

Static Call 

Language::{$property}($vars = [], $preserve_case = false);

Get language property statically:

echo Language::home();

Get language property dynamically:

echo $language->home;
echo $language->home();

String Variable 

Let’s say we have a language property called test like this:

test: Hello %{place}%! My name is %{object}%.

Then:

echo Language::test([
    'place' => 'world',
    'object' => 'Mocha'
]);

The code above will return the test value into this:

Hello world! My name is Mocha.