Not signed in (Sign In)
 
Nov 16th 2007 edited
 
Framework.Functions.php's TimeDiff function uses date() which doesn't support different locales to format dates:
http://lussumo.com/community/discussion/7409/time-stamp-language/

Not quite sure the best way to fix this, since simply changing the function would break all existing translations due to the different format codes.
 
Nov 16th 2007 edited
 
What about something like that:if ($Context->GetDefinition('OldPostDateFormatCodeLC') !== 'OldPostDateFormatCodeLC') {
strftime($Context->GetDefinition('OldPostDateFormatCodeLC'), $Time);
} else {
date($Context->GetDefinition('OldPostDateFormatCode'), $Time);
}


And users will set the format like that:setlocale(LC_TIME, "de_DE");
$Context->Dictionary['OldPostDateFormatCodeLC'] = '%d. %B %Y';
 
Nov 27th 2007
 
It seems setting locales are troublesome, even with php5. There are platform specific rules and threading issues that are inherent in PHP.

Maybe this is best kept to a extension or manual hack for those users who desire international date formatting. I'll consider this completed when it's in the wiki.


Perhaps Max_B has some input? I recall he contributed a bunch of translation ideas for Vanilla 1.
 
Nov 28th 2007
 
About setting locales:
Yes it is platform dependent. I stay away of windows servers, so I have no input.
Even on 'nix there are two brands:

On BSD'ish (OS X), the LANG env variable is used, the setlocale() function has (had? not checked recently) no effect (does'nt harm anyway). Setting the LANG variable require the putenv() function which is sometimes disabled. Also the LANG variable must be writable.

On linux the LANG variable is not used. The setlocale() function does the job. The target language must be installed on the system (most are in standard distribution, but not always).
Then comes the trap of locale string format: the php setlocale use 'fr_FR' OR 'fr_fr' (depending of the implementation) format where IANA format id fr-FR r fr-fr. So to set the locale to French you should use setlocale(array('fr', 'fr_fr', 'fr_FR')), just to be sure.

Date format:
The dat() function used in the core does not use locale but for single language forum it's not a problem. One just need to set up the date format in the language file.
strftime() is a good move. To ensure backward compatibility we need to write a simple transcoding function for the format string from the date() format to the strftime(). Only a few codes are widely used so it is not big stuff.

Side note:
Now that I'm using Zend framework for all my development I get rid of those headaches, for locale format as well as translation. Zend supersede the basic php functions, with gettext-like translation functionality without portability issues and a bunch of localization functions for date number and the like.
I already suggested to Mark to use it for vanilla 2, not sure he will.

Issue information

  • 35
  • No assigned user

    No assigned user

     

  • On Hold
  • Low
  • Bug

Vanilla 1.1.2 is a product of Lussumo. More Information: Documentation, Community Support.