othmar52 / slimpd

PHP/JS based MPD-web-client for large music collections
GNU Affero General Public License v3.0
41 stars 11 forks source link

Default to US English for locales #48

Closed smuth4 closed 7 years ago

smuth4 commented 7 years ago

I realize this is Americentric, so if you want it to default to en_GB instead, I can also add a separate config option for the locale instead of inferring it solely from the language key. The German default was the cause of the sporadic issue I mentioned in #46 , although I still have no idea why it only happens sometimes.

othmar52 commented 7 years ago

This definitely has to move to config! I also spotted this code snippet yesterday. Further the files index.php and slimpd has

date_default_timezone_set('Europe/Vienna');    // TODO: move to config

Several of my test-instances runs with english frontent-language (in mittle europe). We have to find a solution where this is also possible. Maybe it makes sense to remove setlocale() at all to use systems locale!?

Do you have any ideas on that?

smuth4 commented 7 years ago

I've updated the PR with a more opinionated approach, which inherits by default but allows overriding.

othmar52 commented 7 years ago

Your solution makes sense to me - Thank you!

othmar52 commented 7 years ago

OOPS. Obviously we have to improve your solution. With inactive optional timzone setting i get

Application Error: An exception has been thrown during the rendering of a template ("DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.").

So maybe we have to set a fallback timezone in case config-value is empty and ini_get('date.timezone') is empty!?

or just setting it to UTC within the shipped config which may be overriden by individual user configuration?

othmar52 commented 7 years ago

i think the cleanest solution is to add any valid timezone to core/config/config.ini

[config]
timezone = Africa/Timbuktu

which may get overriden in config_local.ini

so there will be no more need for this condition

if (isset($config['config']['timezone'])) {

and the timezone can be set directly - no matter if its correct or not

date_default_timezone_set($config['config']['timezone']);

Do you have any thoughts on that?