<?php /* Copyright (c) 2024 Freya Murphy */ class Loader { /** * Loads the given common lang * @param lang_code - the language code */ public function lang($lang_code) { $dir = $GLOBALS['webroot'] . '/lang/' . $lang_code . '/'; $lang = $GLOBALS['lang']; if ($handle = opendir($dir)) { while (false !== ($entry = readdir($handle))) { if ($entry === '.' || $entry === '..' || $entry === 'routes') { continue; } $path = $dir . $entry; require($path); } } $GLOBALS['lang'] = $lang; } /** * Loads a given route specific lang * @param lang_coed - the language code * #param name - the name of the route */ public function route_lang($lang_code, $name) { $dir = $GLOBALS['webroot'] . '/lang/' . $lang_code . '/routes/'; $file = $dir . $name . '.php'; if (file_exists($file)) { $lang = $GLOBALS['lang']; require($dir . $name . '.php'); $GLOBALS['lang'] = $lang; } } }