|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
iop Smarty Rookie
Joined: 06 Dec 2010 Posts: 18
|
Posted: Wed Dec 08, 2010 9:49 pm Post subject: date_format language |
|
|
Hey,
its me again
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Dec 08, 2010 9:54 pm Post subject: |
|
|
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 |
|
iop Smarty Rookie
Joined: 06 Dec 2010 Posts: 18
|
Posted: Wed Dec 08, 2010 10:09 pm Post subject: |
|
|
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Dec 08, 2010 10:14 pm Post subject: |
|
|
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 |
|
iop Smarty Rookie
Joined: 06 Dec 2010 Posts: 18
|
Posted: Wed Dec 08, 2010 10:18 pm Post subject: |
|
|
Thank you very much mohrt! I'll try it! |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Dec 08, 2010 10:20 pm Post subject: |
|
|
setlocale() before and after the strftime() call. |
|
Back to top |
|
iop Smarty Rookie
Joined: 06 Dec 2010 Posts: 18
|
Posted: Thu Dec 09, 2010 2:12 am Post subject: |
|
|
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 Thanks! |
|
Back to top |
|
|
|
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
|