Skip to content

Commit

Permalink
Add option to set a locale
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
asdfuser committed Jun 14, 2020
1 parent 1aca13e commit b2df860
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/config.yml.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions lib/Pico.php
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,7 @@ protected function loadConfig()
'rewrite_url' => null,
'debug' => null,
'timezone' => null,
'locale' => null,
'theme' => 'default',
'theme_config' => null,
'theme_meta' => null,
Expand Down Expand Up @@ -974,6 +975,10 @@ protected function loadConfig()
}
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 {
Expand Down

0 comments on commit b2df860

Please sign in to comment.