Advertisement:

Author Topic: AM/PM in your languages or what ever you want for SMF 2.0 stable  (Read 18133 times)

Offline Tomy Tran

  • Senior Translator
  • Jr. Member
  • *
  • Posts: 314
  • Gender: Male
  • Vietnamese Translator
    • the.tomytran on Facebook
    • tomytran on LinkedIn
    • @_tomytran on Twitter
    • Call to +84 9 0602 6930 or visit www.tomytran.com
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.

Offline Illori

  • Project Manager
  • SMF Master
  • *
  • Posts: 49,741
Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
« Reply #1 on: November 18, 2011, 09:26:06 AM »
is this still an issue?

Offline Tomy Tran

  • Senior Translator
  • Jr. Member
  • *
  • Posts: 314
  • Gender: Male
  • Vietnamese Translator
    • the.tomytran on Facebook
    • tomytran on LinkedIn
    • @_tomytran on Twitter
    • Call to +84 9 0602 6930 or visit www.tomytran.com
Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
« Reply #2 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.

Offline Illori

  • Project Manager
  • SMF Master
  • *
  • Posts: 49,741
Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
« Reply #3 on: November 18, 2011, 06:22:31 PM »
well if people can have this problem then it may still be an issue.

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,914
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
« Reply #4 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.
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

Offline Tomy Tran

  • Senior Translator
  • Jr. Member
  • *
  • Posts: 314
  • Gender: Male
  • Vietnamese Translator
    • the.tomytran on Facebook
    • tomytran on LinkedIn
    • @_tomytran on Twitter
    • Call to +84 9 0602 6930 or visit www.tomytran.com
Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
« Reply #5 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.

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,914
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
« Reply #6 on: November 21, 2011, 06:09:31 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

Code: [Select]
$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
Quote
19, 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

Offline Tomy Tran

  • Senior Translator
  • Jr. Member
  • *
  • Posts: 314
  • Gender: Male
  • Vietnamese Translator
    • the.tomytran on Facebook
    • tomytran on LinkedIn
    • @_tomytran on Twitter
    • Call to +84 9 0602 6930 or visit www.tomytran.com
Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
« Reply #7 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/

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,914
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
« Reply #8 on: November 22, 2011, 04:59:07 AM »
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

Offline Tomy Tran

  • Senior Translator
  • Jr. Member
  • *
  • Posts: 314
  • Gender: Male
  • Vietnamese Translator
    • the.tomytran on Facebook
    • tomytran on LinkedIn
    • @_tomytran on Twitter
    • Call to +84 9 0602 6930 or visit www.tomytran.com
Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
« Reply #9 on: November 22, 2011, 10:20:20 PM »
I clear cache often.

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,914
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
« Reply #10 on: November 23, 2011, 06:27:04 AM »
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

Offline Tomy Tran

  • Senior Translator
  • Jr. Member
  • *
  • Posts: 314
  • Gender: Male
  • Vietnamese Translator
    • the.tomytran on Facebook
    • tomytran on LinkedIn
    • @_tomytran on Twitter
    • Call to +84 9 0602 6930 or visit www.tomytran.com
Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
« Reply #11 on: November 23, 2011, 05:32:13 PM »
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.

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,914
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
« Reply #12 on: November 24, 2011, 06:10:54 AM »
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


Offline Tomy Tran

  • Senior Translator
  • Jr. Member
  • *
  • Posts: 314
  • Gender: Male
  • Vietnamese Translator
    • the.tomytran on Facebook
    • tomytran on LinkedIn
    • @_tomytran on Twitter
    • Call to +84 9 0602 6930 or visit www.tomytran.com
Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
« Reply #14 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.

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,914
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
« Reply #15 on: November 27, 2011, 09:27:03 AM »
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

Offline emanuele

  • SMF Super Hero
  • *******
  • Posts: 14,156
  • Gender: Male
  • THERE'S JUST ME
Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
« Reply #16 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 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.

Offline Illori

  • Project Manager
  • SMF Master
  • *
  • Posts: 49,741
Re: AM/PM in your languages or what ever you want for SMF 2.0 stable
« Reply #17 on: November 27, 2011, 11:38:03 AM »
there is a thread on this in the translators board on that issue i believe.