From 442da207d2c7fa514d77f1d9a6e166d25c802a9d Mon Sep 17 00:00:00 2001 From: DrMaxNix Date: Sun, 25 Feb 2024 18:06:26 +0100 Subject: [PATCH] :sparkles: lang selection (fix #7) --- init.php | 28 +++++++++++++++++++++++++++ meta.php | 8 ++++++-- page/lang_autoselect.php | 41 ++++++++++++++++++++++++++++++++++++++++ page/start/index.php | 4 ++-- page/strings.php | 8 ++++++++ 5 files changed, 85 insertions(+), 4 deletions(-) create mode 100644 init.php create mode 100644 page/lang_autoselect.php create mode 100644 page/strings.php diff --git a/init.php b/init.php new file mode 100644 index 0000000..e548d72 --- /dev/null +++ b/init.php @@ -0,0 +1,28 @@ + diff --git a/meta.php b/meta.php index 5b24977..7166d7f 100644 --- a/meta.php +++ b/meta.php @@ -5,7 +5,10 @@ // DEPENDENCIES // // used extensions - static::$ext[] = "excuse"; + static::$ext[] = "project"; + static::$ext[] = "lang"; + static::$ext[] = "request"; + static::$ext[] = "url"; // ROUTES // @@ -16,6 +19,7 @@ // pages static::$route["thi-hub.de"] = [ - ["path" => "", "target" => "page/start"] + ["path" => "", "target" => "page/start"], + ["path" => ":lang", "target" => "page/start"], ]; ?> diff --git a/page/lang_autoselect.php b/page/lang_autoselect.php new file mode 100644 index 0000000..3fbb7fe --- /dev/null +++ b/page/lang_autoselect.php @@ -0,0 +1,41 @@ +get()); + $path_raw_full = implode("/", $path_raw); + Url_redirect::path_modify($path_raw_full); + } + + + // LANGUAGE MANAGER // + // hack: fake get param from url path + $_GET["lang"] = $param_lang; + + // initialize + Data::$lang_object = new Lang(list: ["de", "en"], default: "de"); + Data::$lang = Data::$lang_object->get(); + + // load dict + Data::$dict = new Lang_Dict(Data::$lang_object); + require("./page/strings.php"); +?> diff --git a/page/start/index.php b/page/start/index.php index 578ed9e..c4fe8ec 100644 --- a/page/start/index.php +++ b/page/start/index.php @@ -1,7 +1,7 @@ diff --git a/page/strings.php b/page/strings.php new file mode 100644 index 0000000..49bada5 --- /dev/null +++ b/page/strings.php @@ -0,0 +1,8 @@ +define([ + + ]); +?>