From b2df86054646aac86c6eea6dc103413596bfc514 Mon Sep 17 00:00:00 2001 From: Daniel Willmann Date: Sun, 14 Jun 2020 12:57:36 +0200 Subject: [PATCH] Add option to set a locale MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As mentioned in https://www.php.net/manual/en/function.basename.php both basename() and dirname() are locale aware. An incorrect locale can cause the page tree to behave in strange ways. For example the structure /über-uns |-index.md |-impressum.md could lead to the page impressum not being a child of über-uns. --- config/config.yml.template | 1 + lib/Pico.php | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/config/config.yml.template b/config/config.yml.template index 159585b..5500ccb 100644 --- a/config/config.yml.template +++ b/config/config.yml.template @@ -7,6 +7,7 @@ base_url: ~ # Pico will try to guess its base URL, if th rewrite_url: ~ # A boolean (true or false) indicating whether URL rewriting is forced debug: ~ # Set this to true to enable Pico's debug mode timezone: ~ # Your PHP installation might require you to manually specify a timezone +locale: ~ # Your PHP installation might require you to manually specify a locale to use ## # Theme diff --git a/lib/Pico.php b/lib/Pico.php index efb5b33..071e66f 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -936,6 +936,7 @@ class Pico 'rewrite_url' => null, 'debug' => null, 'timezone' => null, + 'locale' => null, 'theme' => 'default', 'theme_config' => null, 'theme_meta' => null, @@ -974,6 +975,10 @@ class Pico } date_default_timezone_set($this->config['timezone']); + if ($this->config['locale'] !== null) { + setlocale(LC_ALL, $this->config['locale']); + } + if (!$this->config['plugins_url']) { $this->config['plugins_url'] = $this->getUrlFromPath($this->getPluginsDir()); } else {