Wedge
Public area => Bug reports => The Pub => Archived fixes => Topic started by: Arantor on February 29th, 2012, 02:56 PM
-
I still don't get why SMF and Wedge don't just have the months set appropriately for language and use them rather than trying to mess around with ucwords...
-
An example? I don't remember this.
-
The bug report points to Dutch. In all other languages, the months are written January/February/whatever, but in Dutch, the correct spelling is entirely lowercase.
Yet, timeformat() pushes them through ucwords() unless a $txt variable is set, which implies it's a known workaround, but if we already have $txt strings for the months, we would have them just be correct without any need to mess with ucwords in the first place.
-
Then ucwords is never run?
-
That's the thing, it's actually broken. Here's our code.
if ($user_info['setlocale'])
{
foreach (array('%a', '%A', '%b', '%B') as $token)
if (strpos($str, $token) !== false)
$str = str_replace($token, !empty($txt['lang_capitalize_dates']) ? westr::ucwords(strftime($token, $time)) : strftime($token, $time), $str);
}
else
{
// Do-it-yourself time localization. Fun.
foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label)
if (strpos($str, $token) !== false)
$str = str_replace($token, $txt[$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str);
}
Now, SMF's code is slightly different because I tweaked how setlocale was run but the basis is the same: if we could setlocale, locale is *probably correct* (certainly the example on the setlocale page in PHP(http://php.net/manual/en/function.setlocale.php) actually validates this... it uses Dutch specifically so that the formatting will be shown) and yet it's discarded.
If we don't trust the locale DB, we shouldn't use it and just use the later branch where we have the strings ourselves, and if we do trust the locale DB, we should leave it the hell alone and not mess about with ucwords on it.
-
Fixed in r1734.