|
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 |
Cronet Smarty Rookie
Joined: 21 May 2003 Posts: 15
|
Posted: Tue Jul 08, 2003 8:15 pm Post subject: date_format problems... |
|
|
hi there!
I want to use the modeifider date_format:"%a" ..
In the manual is the hint
"%a - abbreviated weekday name according to the current locale "
How to set the locale manually?
I get only the english statements.. but I need the german....
It would be nice if anybody could help...
Greets
Cronet |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Tue Jul 08, 2003 8:17 pm Post subject: |
|
|
It would be very helpful if you gave at least some hints as to your OS, version, etc. |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
|
Back to top |
|
Cronet Smarty Rookie
Joined: 21 May 2003 Posts: 15
|
Posted: Tue Jul 08, 2003 9:11 pm Post subject: |
|
|
Hi!
tried this example from php.net
<?php
setlocale (LC_TIME, "C");
print (strftime ("%A in Finnish is "));
setlocale (LC_TIME, "fi_FI");
print (strftime ("%A, in French "));
setlocale (LC_TIME, "fr_FR");
print (strftime ("%A and in German "));
setlocale (LC_TIME, "de_DE");
print (strftime ("%A.\n"));
?>
OUTPUT:
Tuesday in Finnish is Tuesday, in French Tuesday and in German Tuesday.
I'm using a win system, and smarty 2.5.0, php 4.3.0
Greets
Cronet |
|
Back to top |
|
BloodRath Smarty Rookie
Joined: 06 Jul 2003 Posts: 23 Location: France
|
Posted: Sat Jul 12, 2003 12:54 am Post subject: |
|
|
if it could help u i achieve this transformation this way
1/ use the translation functions from AZTEK (a too nice function !!!!!!!! )
2/ define in your eng.xml or fr.xml file those thing
<message>
<id>date_day_name_0</id>
<string>sunday</string> <!-- your translation -->
</message>
...
3/ rewrite the modifier date to
parse the datestring with regexp and split it
4/ retrieve the name of the day with :
mktime and date
5/ rewrite the month, and the name of the day via the t() (cf AZTEK function)
by example :
$nameOfDay = mktime(0,0,0,$month,$day,$year);
$nameOfDay = t('date_day_name_'.date('w',$nameOfDay));
i haven't finish all the format option of my modifier it's the reason why i haven't send here the complete code _________________ froggies forever.... |
|
Back to top |
|
AZTEK Smarty Pro
Joined: 16 Apr 2003 Posts: 235 Location: Purdue University
|
Posted: Sat Jul 12, 2003 1:33 am Post subject: |
|
|
Because I found that php's locale stuff does not work on all systems exactly as I would like it to I do something close to what BloodRath said. IMHO the best way is to use a multilanguage system, take your pick from http://www.phpinsider.com/smarty-forum/viewtopic.php?t=84. I guess BloodRath liked mine. So as an example using my system.
Code: | <?xml version="1.0" encoding="utf-8" ?>
<locale lang="de">
<header>
<project>Something</project>
<create>2003-07-11 20:27-0500</create>
<revise>2003-07-11 20:27-0500</revise>
<trans>My 2 years of German in High School</trans>
<lang>Deutsch</lang>
</header>
<message>
<id>Mon</id>
<string>Mon</string>
</message>
<message>
<id>Tue</id>
<string>Die</string>
</message>
<message>
<id>Wed</id>
<string>Mit</string>
</message>
<message>
<id>Thu</id>
<string>Don</string>
</message>
<message>
<id>Fri</id>
<string>Fri</string>
</message>
<message>
<id>Sat</id>
<string>Sam</string>
</message>
<message>
<id>Sun</id>
<string>Son</string>
</message>
</locale> |
in de.xml and then use something like
[php:1:eb2b520702]<?php echo t(strftime("%a")); ?>[/php:1:eb2b520702]
now I know my German is rusty and I have no idea if those are the real abreviations I just pulled the first 3 letters from my memory of high school german class. _________________ "Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane |
|
Back to top |
|
Cronet Smarty Rookie
Joined: 21 May 2003 Posts: 15
|
Posted: Sat Jul 12, 2003 11:06 am Post subject: |
|
|
Thank you for your answers...
I try it this weekend with your method!! |
|
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
|