public static function configure() { if (is_null(static::$site)) { static::$site = kirby::panelsetup(); } // load all available routes static::$routes = array_merge(static::$routes, require root('panel.app.routes') . DS . 'api.php'); static::$routes = array_merge(static::$routes, require root('panel.app.routes') . DS . 'views.php'); // setup the blueprint root blueprint::$root = c::get('root.site') . DS . 'blueprints'; // start the router static::$router = new Router(); static::$router->register(static::$routes); // content language switcher variable if (static::$site->multilang()) { if ($language = server::get('http_language') or $language = s::get('lang')) { static::$site->visit('/', $language); } app::$language = static::$site->language()->code(); s::set('lang', app::$language); } // load the interface language file if (static::$site->user()) { $languageCode = static::$site->user()->language(); } else { $languageCode = c::get('panel.language', 'en'); } // validate the language code if (!in_array($languageCode, static::languages()->keys())) { $languageCode = 'en'; } // store the interface language app::$interfaceLanguage = $languageCode; $language = (require root('panel.app.languages') . DS . $languageCode . '.php'); // set all language variables l::$data = $language['data']; // register router filters static::$router->filter('auth', function () { if (!app::$site->user()) { go('panel/login'); } }); // check for a completed installation static::$router->filter('isInstalled', function () { if (app::$site->users()->count() == 0) { go('panel/install'); } }); // only use the fragments of the path without params static::$path = implode('/', (array) url::fragments(detect::path())); }
/** * Load language files if available. */ protected function localize() { $finder = $this->finder(); $config = $this->config(); $base = 'en'; $root = $finder->languages(); $current = $this->site->multilang() ? $this->site->language() : $config->get('language', $base); if (file_exists($root . DS . $base . '.php')) { $localization = $finder->load($base, 'languages'); $localization = $localization['data']; if ($current !== 'en' && file_exists($root . DS . $current . '.php')) { $translation = $finder->load($current, 'languages'); $localization = array_merge($localization, $translation['data']); } l::$data = array_merge(l::$data, $localization); } }
public function i18n() { // load the interface language file if ($user = $this->site()->user()) { $this->language = $user->language(); } else { $this->language = $this->kirby()->option('panel.language', 'en'); } $translation = (require $this->roots()->languages() . DS . 'en.php'); $translation = array_merge($translation, require $this->roots()->languages() . DS . $this->language . '.php'); // set all language variables l::$data = $translation['data']; }
public function i18n() { // load the interface language file if ($user = $this->site()->user()) { $this->language = $user->language(); } else { $this->language = $this->kirby()->option('panel.language', 'en'); } $translation = (require $this->roots()->languages() . DS . 'en.php'); $translation = a::merge($translation, require $this->roots()->languages() . DS . $this->language . '.php'); // set all language variables l::$data = $translation['data']; // set language direction (ltr is default) if (isset($translation['direction']) and $translation['direction'] == 'rtl') { l::set('language.direction', 'rtl'); } else { l::set('language.direction', 'ltr'); } }
public function load() { return l::$data = data::read($this->root . DS . 'core.json'); }