L10n::message PHP Method

message() public method

If there is no defined message for $id in the current language the function looks for an alterantive in English. If that also fails an error message is returned. If $id is NULL or '' the empty string will be returned.
public message ( string $id ) : string
$id string message id
return string localized message string
    function message($id)
    {
        if (empty($id)) {
            return '';
        }
        if (array_key_exists($id, $this->langa)) {
            return $this->langa[$id];
        } else {
            if (array_key_exists($id, $this->langb)) {
                return $this->langb[$id];
            } else {
                return 'Undefined message!';
            }
        }
    }

Usage Example

Esempio n. 1
0
 function testArrayGet()
 {
     global $langde;
     $l10n = new L10n('de');
     $this->assertEqual($langde['admin'], $l10n->message('admin'));
     $this->assertEqual($langde['admin'], $l10n['admin']);
     $this->assertEqual('Undefined message!', $l10n['bla bla']);
 }