Best practice forum (Archived)

Display of time in non-english language packs

 
Christoph Pirringer
Display of time in non-english language packs
by Christoph Pirringer - Friday, 5 August 2016, 7:01 AM
 

Hello!


Can anybody point me towards which steps are necessary to display a 12-hours timeformat including AM and PM in a non-english language.


Thanks a lot,


Christoph 

me
Re: Display of time in non-english language packs
by George Angus - Sunday, 7 August 2016, 7:14 PM
Group Totara

Hi Christoph,

Its set by the language pack - you'd have to identify the strings and edit.

regards,

George.

Christoph Pirringer
Re: Display of time in non-english language packs
by Christoph Pirringer - Sunday, 7 August 2016, 11:52 PM
 

I know there are time-format strings in the language-pack, as in days, hours and minutes, but how do i handle it concerning the logic of whether itis AM or PM ?

me
Re: Display of time in non-english language packs
by George Angus - Monday, 8 August 2016, 3:07 PM
Group Totara

Hi Christoph,

If you have a look in langconfig.php (for example):

$string['alphabet'] = 'A,Ä,B,C,D,E,F,G,H,I,J,K,L,M,N,O,Ö,P,Q,R,S,T,U,Ü,V,W,X,Y,Z';

$string['backupnameformat'] = '%Y%m%d-%H%M';

$string['datepickerplaceholder'] = 'tt/mm/jj';

$string['decsep'] = ',';

$string['firstdayofweek'] = '1';

$string['iso6391'] = 'de';

$string['iso6392'] = 'ger';

$string['labelsep'] = ': ';

$string['listsep'] = ';';

$string['locale'] = 'de_DE.UTF-8';

$string['localewin'] = 'German_Germany.1252';

$string['localewincharset'] = 'WINDOWS-1252';

$string['oldcharset'] = 'ISO-8859-1';

$string['parentlanguage'] = '';

$string['strfdateattime'] = '%d %b %Y um %H:%M';

$string['strfdateshortmonth'] = '%d %b %Y';

$string['strftimedate'] = '%d. %B %Y';

$string['strftimedatefullshort'] = '%d.%m.%y';

$string['strftimedateseconds'] = '%d %b %Y um %H:%M:%S';

$string['strftimedateshort'] = '%d. %B';

$string['strftimedatetime'] = '%d. %B %Y, %H:%M';

$string['strftimedatetimeshort'] = '%d.%m.%Y %H:%M';

$string['strftimedaydate'] = '%A, %d. %B %Y';

$string['strftimedaydatetime'] = '%A, %d. %B %Y, %H:%M';

$string['strftimedayshort'] = '%A, %d. %B';

$string['strftimedaytime'] = '%a, %H:%M';

$string['strftimemonthyear'] = '%B %Y';

$string['strftimerecent'] = '%d. %b, %H:%M';

$string['strftimerecentfull'] = '%a, %d. %b %Y, %H:%M';

$string['strftimeshort'] = '%H:%M';

$string['strftimetime'] = '%H:%M';

$string['thischarset'] = 'UTF-8';

$string['thisdirection'] = 'ltr';

$string['thisdirectionvertical'] = 'btt';

$string['thislanguage'] = 'Deutsch';

$string['thislanguageint'] = 'German';

$string['thousandssep'] = '.';


Any changes here will affect all the users using the language pack.

cheers,

George.

Christoph Pirringer
Re: Display of time in non-english language packs
by Christoph Pirringer - Thursday, 11 August 2016, 7:54 AM
 

So here is what i tried up to now:


I changed the string 'sessiondatetimeformat' in different way to observe its effects.


f.e. when altering it in the english language-pack and removing the '%p' from '%I:%M %p', the AM/PM was removed as expected from the output in the english locale.

But even when i copied the string identically into my german language-file, the AM and PM was not displayed.


Looking up the php-function strftime (http://php.net/manual/en/function.strftime.php), i saw that it supposedly removd the AM/PM when it detected certain non-english locales. So i tried placing setlocale(LC_TIME, 'en_US');, both at the beginning of the  function that outputs the sessions including their respective start- and endtime, or the renderer.php. Neither had any effect on the output.


Could anybody help me further with this problem?

Christoph Pirringer
Re: Display of time in non-english language packs
by Christoph Pirringer - Monday, 22 August 2016, 12:51 AM
 

The issue is resolved now, the solution lay in altering the right strings in the language-pack :)

me
Re: Display of time in non-english language packs
by George Angus - Monday, 22 August 2016, 3:43 PM
Group Totara

Good job!