Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

date_format language

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
iop
Smarty Rookie


Joined: 06 Dec 2010
Posts: 18

PostPosted: Wed Dec 08, 2010 9:49 pm    Post subject: date_format language Reply with quote

Hey,

its me again Smile

date_format has conversion specifiers like %a with output in different languages according to the current locale. Is there a possibility to switch the languages manually in the template file or something?

Thanks!
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed Dec 08, 2010 9:54 pm    Post subject: Reply with quote

no, mostly because it relies on the proper locales being installed on your system. you would have to make your own modifier that calls setlocale($locale) twice around the php function.
Back to top
View user's profile Send private message Visit poster's website
iop
Smarty Rookie


Joined: 06 Dec 2010
Posts: 18

PostPosted: Wed Dec 08, 2010 10:09 pm    Post subject: Reply with quote

Thanks for your reply mohrt, but can you specify what you mean, please?

..so I have to write my own modifier like "smarty_modifier_date_format" call setlocale($locale) before and after the function code..? Ok, but do I have to replace the original "smarty_modifier_date_format" modifier or how do I call my own modifier otherwise?
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed Dec 08, 2010 10:14 pm    Post subject: Reply with quote

If you want to use the same modifier name, you would replace the modifier shipped with Smarty, or register manually to override it. If you want to use a plugin file, I would recommend using your own like:

{$date|date_format_locale:"%Y-%m-%d":"us_EN"}

That way when you upgrade Smarty you don't lose it again.
Back to top
View user's profile Send private message Visit poster's website
iop
Smarty Rookie


Joined: 06 Dec 2010
Posts: 18

PostPosted: Wed Dec 08, 2010 10:18 pm    Post subject: Reply with quote

Thank you very much mohrt! I'll try it! Smile
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed Dec 08, 2010 10:20 pm    Post subject: Reply with quote

setlocale() before and after the strftime() call.
Back to top
View user's profile Send private message Visit poster's website
iop
Smarty Rookie


Joined: 06 Dec 2010
Posts: 18

PostPosted: Thu Dec 09, 2010 2:12 am    Post subject: Reply with quote

Thanks mohrt, everything works now. I had to figure out first how to install the languages I need on my system but now I am happy - and amazed about the simpleness of writing smarty plugins Smile Thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
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, 2005 phpBB Group
Protected by Anti-Spam ACP