$filename = '/en/';
if (file_exists($filename)) {
$_SESSION['currency'] = 'wmz';
} else {
$_SESSION['currency'] = 'wmr';
}
// en/file.php
return [
'currency' => 'wmz'
];
// ru/file.php
return [
'currency' => 'wmr'
];
function getLocalePath($locale) {
return './' . $locale . '/file.php';
}
function getLocaleArray($locale, $fallbackLocale = 'en') {
$path = getLocalePath($locale);
if (!is_dir($path)
$path = getLocalePath($fallbackLocale);
return include $path;
}
function getTranslate($key, $locale, $fallbackLocale = 'en') {
$data = getLocaleArray(locale, $fallbackLocale);
return $data[$key];
}
$currentLocale = 'ru';
echo getTranslate('currency', $currentLocale);