Date format per language

General discussion of Mantis.

Moderators: Contributor, Developer

Post Reply
federico
Posts: 25
Joined: Mar 27, 2019 12:35 pm

Date format per language

Post by federico » Apr 24, 2019 8:30 am

Hello.

I would like to set the date format depending on the global variable "g_active_language "(suposed it stores the user language for each request). I tried the following code in "custom_strings.inc.php", but nothing happened, so I supposed at this point, "g_active_language" is defined, but it is being overriden later, as well as the rest of the variables inside the "switch" ("s_" sub-fixed) has the right values.

Code: Select all

switch($g_active_language){
	case 'spanish':
  		$g_normal_date_format 	= 'd-m-Y H:i:s';
                $g_short_date_format 	= 'd-m-y';
                $g_complete_date_format = 'D d-M-Y H:i:s';
               break;
         default:
}
I also tried the same code in "config_inc.php", and it fail reporting "g_active_language" is undefined, so I have to suppose when this file is loaded, "g_active_language" is not defined yet.

Where can I write this piece of code to get the expected result?

Thanks.

federico
Posts: 25
Joined: Mar 27, 2019 12:35 pm

Re: Date format per language

Post by federico » Apr 26, 2019 3:46 am

Sorry. Stupid question

federico
Posts: 25
Joined: Mar 27, 2019 12:35 pm

Re: Date format per language

Post by federico » Apr 26, 2019 3:55 am

But it should be more accurate to take in account the possibility that users could configure their preferred "date format" view, because it makes the UI more friendly considering additional cultural aspects. Of course, I can explain to the US readers, they have to read dates in an spanish way (most of my users are spanish).

atrol
Site Admin
Posts: 7615
Joined: Mar 26, 2008 4:37 pm
Location: Germany

Re: Date format per language

Post by atrol » Apr 27, 2019 9:16 am

The right place for a workaround would be to change source of function config_get
Please use Search before posting and read the Manual

federico
Posts: 25
Joined: Mar 27, 2019 12:35 pm

Re: Date format per language

Post by federico » Apr 28, 2019 5:43 am

Thank you, atrol. I will check your proposal.

I come from the java and the .net development world. In your oppinion, which is the best free and friendly PHP development environment for windows, in order to keep my mantisbt extensions tidy. I am using notepad+, and it being a bit hard.

atrol
Site Admin
Posts: 7615
Joined: Mar 26, 2008 4:37 pm
Location: Germany

Re: Date format per language

Post by atrol » Apr 28, 2019 6:35 am

I am no professional PHP developer who uses PHP on a daily base. Just learned a bit PHP for Mantis purposes.
I am using a commercial IDE.

Might help https://codingcyber.org/best-free-php-i ... opers-674/
Please use Search before posting and read the Manual

Post Reply