Implemented locale system (without lang detection)

master
Bofh 1 year ago
parent adda2114e5
commit 91f6dd2a8b

@ -4,3 +4,20 @@ $env = 'prod';
if (getenv('ENV') !== false && in_array(getenv('ENV'), ['prod', 'dev']))
$env = getenv('ENV');
define('ENV', $env);
# load locales
$lang = 'es';
$lang_file = '/src/locales/'.$lang.'.json';
$locales = (object)[];
if (file_exists($lang_file))
$locales = json_decode(file_get_contents($lang_file), true);
$locales;
function l($key, $default='') {
global $locales;
$parts = explode('.', $key);
if (isset($locales[$parts[0]][$parts[1]]))
echo $locales[$parts[0]][$parts[1]];
else echo $default;
}

@ -0,0 +1,11 @@
{
"all": {
"app_name": "RealFan",
"_": ""
},
"home": {
"register": "Regístrate",
"_": ""
},
"_": ""
}
Loading…
Cancel
Save