Wedge

Public area => Bug reports => The Pub => Archived fixes => Topic started by: Arantor on February 29th, 2012, 02:56 PM

Title: SMF bug 4870 (incorrectly capitalised month names)
Post 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...
Title: Re: SMF bug 4870 (incorrectly capitalised month names)
Post by: Nao on March 1st, 2012, 08:44 AM
An example? I don't remember this.
Title: Re: SMF bug 4870 (incorrectly capitalised month names)
Post by: Arantor on March 1st, 2012, 09:20 AM
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.
Title: Re: SMF bug 4870 (incorrectly capitalised month names)
Post by: Nao on March 1st, 2012, 09:47 AM
Then ucwords is never run?
Title: Re: SMF bug 4870 (incorrectly capitalised month names)
Post by: Arantor on March 1st, 2012, 09:55 AM
That's the thing, it's actually broken. Here's our code.

Code: [Select]
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.
Title: Re: SMF bug 4870 (incorrectly capitalised month names)
Post by: Arantor on October 7th, 2012, 05:46 PM
Fixed in r1734.