Nucleus Support Forum Index

Find on the forum:
any terms  all terms  Advanced Search

RSS 2.0
Browse posts: Unanswered | Mark all read

« »
Loading Nucleus FAQ ticker...
Post new topic Reply to topic
Author Message
Monkeybrain
Nucleus PhD


Joined: 15 Dec 2005
Posts: 525
Location: Kristiansand, Norway

Post Posted: Thu Feb 10, 2011 12:26 am   Post subject: Display monthname according to locale
Reply with quote

How can I display the monthname from a given number, lets say 02, and get the output to be according to the blog locale setting?


I'm currently using this:
Code:
$monthname = date('F', mktime(0, 0, 0, $month_nr,1));

It gives me the correct name of the month, but I would like to get back the correct value for the selected locale setting.
Must be getting tired, I better go sleep on it Mad

Edit: Ok... this should maby be in another part of the forum, please move if so Embarassed

_________________
Is your question not solved yet?
Search our FAQ,
read the Documentation, or
browse the list of available plugins.

Back to top

View user's profile Send private message Visit poster's website
ftruscot
Nucleus Guru
Nucleus Guru


Joined: 22 Feb 2006
Posts: 7449
Location: Massachusetts

Post Posted: Fri Feb 25, 2011 2:53 pm   Post subject:
Reply with quote

Monkeybrain, sorry I missed this when you posted it. If I understand, you are getting the correct month name, but in the language of the server. You want it to get it according to the locale specified in the skin or template used by nucleus?

If you still need help, let me know a little more about where you're using this.

_________________
Is your question not solved yet?
Search our FAQ,
read the Documentation, or
browse the list of available plugins.

Check out my plugins

Back to top

View user's profile Send private message Visit poster's website
ftruscot
Nucleus Guru
Nucleus Guru


Joined: 22 Feb 2006
Posts: 7449
Location: Massachusetts

Post Posted: Fri Feb 25, 2011 8:16 pm   Post subject:
Reply with quote

There's a PHP function called setlocale() that you should use. The issue is that locale is not stored in db as part of the blog object, so you can't pull it from there. One option, if this is a plugin, is to use a blogOption to set the locale per blog, then get that blogOption to use in setlocale() like this:
Code:
$bloglocale = $this->getBlogOption($blogid,'mylocale');
setlocale(LC_TIME,$bloglocale);

_________________
Is your question not solved yet?
Search our FAQ,
read the Documentation, or
browse the list of available plugins.

Check out my plugins

Back to top

View user's profile Send private message Visit poster's website
Monkeybrain
Nucleus PhD


Joined: 15 Dec 2005
Posts: 525
Location: Kristiansand, Norway

Post Posted: Sat Mar 12, 2011 1:05 am   Post subject:
Reply with quote

Thanks Frank!

I was going to use this in a plugin, yes, but I kinda figured out a way of achieving what I wanted by using setlocale() and using the server locale value.

Guess it won't be of much use as most servers are configured using EN locale, even on my norwegian hosts server, so I guess I'l have to add an option like you mentioned.

Thank you for the hint Smile

_________________
Is your question not solved yet?
Search our FAQ,
read the Documentation, or
browse the list of available plugins.

Back to top

View user's profile Send private message Visit poster's website
Post new topic Reply to topic
Display posts from previous:   

Page 1 of 1

All times are GMT + 1 Hour

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2002 phpBB Group