diff --git a/src/base.php b/src/base.php index b7972f1..f5906c9 100644 --- a/src/base.php +++ b/src/base.php @@ -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; +} diff --git a/src/locales/es.json b/src/locales/es.json new file mode 100644 index 0000000..9c187d9 --- /dev/null +++ b/src/locales/es.json @@ -0,0 +1,11 @@ +{ + "all": { + "app_name": "RealFan", + "_": "" + }, + "home": { + "register": "RegĂ­strate", + "_": "" + }, + "_": "" +}