Date format per language

General discussion of Mantis.

Moderators: Developer, Contributor

Post Reply
federico
Posts: 35
Joined: 27 Mar 2019, 17:35

Date format per language

Post by federico »

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: 35
Joined: 27 Mar 2019, 17:35

Re: Date format per language

Post by federico »

Sorry. Stupid question
federico
Posts: 35
Joined: 27 Mar 2019, 17:35

Re: Date format per language

Post by federico »

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: 8366
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Date format per language

Post by atrol »

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: 35
Joined: 27 Mar 2019, 17:35

Re: Date format per language

Post by federico »

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: 8366
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Date format per language

Post by atrol »

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