Simple Machines Community Forum

SMF Development => Bug Reports => Fixed or Bogus Bugs => Topic started by: Tomy Tran on June 22, 2011, 04:01:56 AM

Title: AM/PM in your languages or what ever you want for SMF 2.0 stable
Post by: Tomy Tran on June 22, 2011, 04:01:56 AM
After updated to 2.0 Stable, I found the core has some codes to localize symbol AM/PM:

@ file:  Sources / Subs.php
@ line: 799 & 813
   $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str);

even $txt['time_am'] & $txt['time_pm'] are already defined in index.yourlanguage.php but forum is still show AM/PM, this is bug for some hosts.

Any one get this can fix with guide on link http://www.simplemachines.org/community/index.php?topic=368208.0
or like below (I did not redefine to optimise these codes):

@ file:  Sources / Subs.php
@ line: 820 + 821

        Seek ( at least 1 line below):

                // Format any other characters.
                return strftime($str, $time);

        Replace by:

                // Format any other characters.
                $timenow = strftime($str, $time);

                // Replace AM / PM by your defined language.
                $seekit = array( 'am', 'AM', 'pm', 'PM' );
                $pasteit = array( $txt['time_am'], $txt['time_am'], $txt['time_pm'], $txt['time_pm'] );
                $timenow = str_replace( $seekit, $pasteit, $timenow );

                return $timenow;

Remember update your language package to 2.0 stable also. In language package, $txt['time_am'] and $txt['time_pm'] is defined in file index.yourlanguage.php, you may change it to 'morning' and 'afternoon' or what ever.

Good luck.
Title: Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
Post by: Illori on November 18, 2011, 09:26:06 AM
is this still an issue?
Title: Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
Post by: Tomy Tran on November 18, 2011, 06:12:57 PM
This topic is not an issue, SMF is and this is guide for anyone get the trouble. Tks.
Title: Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
Post by: Illori on November 18, 2011, 06:22:31 PM
well if people can have this problem then it may still be an issue.
Title: Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
Post by: Joker™ on November 20, 2011, 08:22:18 AM
I'm not sure which part of the script is getting referred as a bug over here.

To my understanding Tomy Tran you are suggesting that AM and PM are hard coded text strings and a user can't change it?

If thats the case then why not change those text strings in language files itself? You can do it by manually editing the file or even using admin panel.
Title: Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
Post by: Tomy Tran on November 20, 2011, 11:50:00 AM
As my primary language is Vietnamese, and AM in Vietnamese is S or Sáng as well as PM is C or Chiều (already added those parameters in language file). But on the default test site, it still show AM or PM for my Vietnamese language site.

After looked for code and changed it like above, my site is fluently in Vietnamese and Sáng/Chiều replace for AM/PM. I think some one may get this issue can find this topic as a tip. That all.
Title: Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
Post by: Joker™ on November 21, 2011, 06:09:31 AM
Quote from: Tomy Tran © 2012 on November 20, 2011, 11:50:00 AM
As my primary language is Vietnamese, and AM in Vietnamese is S or Sáng as well as PM is C or Chiều (already added those parameters in language file). But on the default test site, it still show AM or PM for my Vietnamese language site.

After looked for code and changed it like above, my site is fluently in Vietnamese and Sáng/Chiều replace for AM/PM. I think some one may get this issue can find this topic as a tip. That all.
If your forum is using Vietnamese language pack then the forum must be making use of "index.vietnamese.php" language file from default. Also note that index.vietnamese.php file has these text strings

$txt['time_am'] = 'sáng';
$txt['time_pm'] = 'chiều';


I've just tested on my test install with Vietnamese language pack and this was the time shown to me
Quote19, 2011, 04:52:27 sáng

Am I missing something around here?
Title: Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
Post by: Tomy Tran on November 21, 2011, 10:24:58 PM
Ah, it works with you, I did not say it doesn't work all, this happen to some forum I don't know why, may be host or something else but my codes make it works for my forum so I share it.

I walk around some Vietnamese forum, it works fine with some but other doesn't. They all use the same language package. See this: http://smf.vn/ - http://forum.vnweb.org (user & pass = demo) - http://myvietnam.com.vn/
Title: Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
Post by: Joker™ on November 22, 2011, 04:59:07 AM
Quote from: Tomy Tran © 2012 on November 21, 2011, 10:24:58 PM
Ah, it works with you, I did not say it doesn't work all, this happen to some forum I don't know why, may be host or something else but my codes make it works for my forum so I share it.

I walk around some Vietnamese forum, it works fine with some but other doesn't. They all use the same language package. See this: http://smf.vn/ - http://forum.vnweb.org (user & pass = demo) - http://myvietnam.com.vn/
After making the changes in the language files have you tried clearing the cache from admin panel?
Title: Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
Post by: Tomy Tran on November 22, 2011, 10:20:20 PM
I clear cache often.
Title: Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
Post by: Joker™ on November 23, 2011, 06:27:04 AM
Quote from: Tomy Tran © 2012 on November 21, 2011, 10:24:58 PM
Ah, it works with you, I did not say it doesn't work all, this happen to some forum I don't know why, may be host or something else but my codes make it works for my forum so I share it.
What I was trying to point out was that your code is making use of hard coded text strings. SMF always make use of text strings from language files. I'm not sure whats happening on your end but I made test on 3 different test forums on 2 different machines and for me the text strings worked fine (AM, PM ones).

Still I'll ask someone else to test it, but TBH its bit difficult to debug a bug which one can't reproduce :).
Title: Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
Post by: Tomy Tran on November 23, 2011, 05:32:13 PM
Quote from: Joker™ on November 23, 2011, 06:27:04 AM
What I was trying to point out was that your code is making use of hard coded text strings. SMF always make use of text strings from language files. I'm not sure whats happening on your end but I made test on 3 different test forums on 2 different machines and for me the text strings worked fine (AM, PM ones).

Still I'll ask someone else to test it, but TBH its bit difficult to debug a bug which one can't reproduce :).

Right, if anyone doesn't know how to code, it's hard coded really. But it's seem happen not usually so I don't want to make a mod. I know SMF always make use of text strings from language files because I am mainly worked on translating language from English into Vietnamese. I must say it's seem happen not usually again :D and don't worry about this small issue. Thanks so much.
Title: Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
Post by: Joker™ on November 24, 2011, 06:10:54 AM
Quote from: Tomy Tran © 2012 on November 23, 2011, 05:32:13 PM
Right, if anyone doesn't know how to code, it's hard coded really. But it's seem happen not usually so I don't want to make a mod. I know SMF always make use of text strings from language files because I am mainly worked on translating language from English into Vietnamese. I must say it's seem happen not usually again :D and don't worry about this small issue. Thanks so much.
So, moving this to Fixed or Bogus Bugs (http://www.simplemachines.org/community/index.php?board=37.0)
Title: Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
Post by: Tomy Tran on November 24, 2011, 10:52:18 PM
Ok, thanks
Title: Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
Post by: Tomy Tran on November 26, 2011, 05:33:52 PM
More information, I just have a look on this forum - http://www.simplemachines.org/community/ - and it doesn't work, it still show AM/PM even I choosed Vietnamese.
Title: Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
Post by: Joker™ on November 27, 2011, 09:27:03 AM
Quote from: Tomy Tran © 2012 on November 26, 2011, 05:33:52 PM
More information, I just have a look on this forum - http://www.simplemachines.org/community/ - and it doesn't work, it still show AM/PM even I choosed Vietnamese.
I'm not in a position to comment on the setup of this forum, but on a fresh SMF 2.0.1 when you install the Vietnamese language pack and switch to it what happens? I mean does "am", "pm" gets changes to the respective words of Vietnamese language?
Title: Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
Post by: emanuele on November 27, 2011, 10:43:58 AM
Well, I have to agree with Tomy: on my testing forum the localization of AM and PM doesn't work...

Additionally, looking at strftime (http://php.net/manual/en/function.strftime.php) specifications, there are a number of cases not taken into account by the current implementation, for example if the admin sets a specific time format using %P, %r.

Mostly unrelated: it's only me or the Vietnamese translation (utf8, not tested the non-utf) seems to have some problem? Or maybe it's me missing something on my computer for the correct display?
Title: Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
Post by: Illori on November 27, 2011, 11:38:03 AM
there is a thread on this in the translators board on that issue i believe.