I have index.php with included file strings.php for translating phrases. In strings.php is included file based on user language: $lang.php. This $lang.php file is automatically generated from $lang.ini and contains single array:
<?php $translation = array (
'USER_PROFILE' => 'Uživatelský profil',
'MESSAGES' => 'Zprávy',
'NOTIFICATIONS' => 'Oznámení',
'SETTINGS' => 'Nastavení',
...
There is a class Strings with static function and globally assigned array $translation from $lang.php in strings.php:
include_once('cache/'.$lang.'.php');
class Strings {
static public function translate($string) {
global $translation;
...
}
}
But $translation in translate() function returns null in this case. If I include $lang.php in index.php it suddenly works, but if I call Strings::translate() function in other file, $translation again returns null. I don't understand this behavior. (Sorry for english)