AM/PM in your languages or what ever you want for SMF 2.0 stable

Started by Tomy Tran, June 22, 2011, 04:01:56 AM

Previous topic - Next topic

Tomy Tran

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.

Illori


Tomy Tran

This topic is not an issue, SMF is and this is guide for anyone get the trouble. Tks.

Illori

well if people can have this problem then it may still be an issue.

Joker™

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.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Tomy Tran

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.

Joker™

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?
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Tomy Tran

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/

Joker™

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?
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Tomy Tran


Joker™

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 :).
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Tomy Tran

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.

Joker™

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
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Tomy Tran


Tomy Tran

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.

Joker™

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?
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

emanuele

Well, I have to agree with Tomy: on my testing forum the localization of AM and PM doesn't work...

Additionally, looking at strftime 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?


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Illori

there is a thread on this in the translators board on that issue i believe.

Advertisement: