trongate / trongate-framework

The Trongate PHP framework
https://trongate.io
Other
1.12k stars 100 forks source link

Add Default locale to the config php #166

Closed domsinclair closed 3 months ago

domsinclair commented 9 months ago

I would like to suggest that the following is added to the config.php file in the config folder;

define('DEFAULT_LOCALE', 'en_GB');

I would of course , naturally, prefer an en_GB by default if for no other reason than that I cannot abide spelling colour without a U. Joking aside this would have little or no impact on the framework and would be immensely useful for anyone wanting to do localisation.

One could take it a step further and have the soon to be newly revamped Desktop app have it's own configuration file that would let you set what you wanted that value to be on initial app creation.

DaFa66 commented 8 months ago

Hi Dom, we used to have a configuration setting in the Desktop app which may return when DC gets time. Your suggestion to add a locale is a good one.

domsinclair commented 8 months ago

Hi Simon, Spent some more time over the weekend finalising the data generator and realised that a Timezone would also be a useful addition.

DaFa66 commented 8 months ago

Hi Dom,

Timezones can be calculated once set

$timezone = date_default_timezone_get();
echo $timezone;

and set either in your php.ini or by code

date_default_timezone_set('Australia/Melbourne');

There are also two 'not-so-known' defaults already available in Trongate - if you do a global search for 'DEFAULT_' you will see DEFAULT_DATE_FORMAT is set to 'mm/dd/yyyy' (US date format) and DEFAULT_LOCALE_STR is set to 'en-US' (US English) in 'timedate_helper.php' and you can call it on the URL http://localhost/{your_app}/dateformat from a function in Core.php

    private function draw_date_format(): void {
        if (!defined('DEFAULT_DATE_FORMAT')) {
            get_default_date_format();
        }

        if (!defined('DEFAULT_LOCALE_STR')) {
            get_default_locale_str();
        }

        $date_prefs = [
            'default_date_format' => DEFAULT_DATE_FORMAT,
            'default_locale_str' => DEFAULT_LOCALE_STR,
        ];

        http_response_code(200);
        echo json_encode($date_prefs);
        die();
    }

These can be set in config.php to reflect your personal preferences to override these defaults.

trongate commented 6 months ago

You already have the ability to set that optionally. Have a look at timedate_helper.php.

trongate commented 3 months ago

I think this is a documentation issue more than anything. Docs are on the way. If you want to reopen this, please do.