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 problems...

 
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
Cronet
Smarty Rookie


Joined: 21 May 2003
Posts: 15

PostPosted: Tue Jul 08, 2003 8:15 pm    Post subject: date_format problems... Reply with quote

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
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Tue Jul 08, 2003 8:17 pm    Post subject: Reply with quote

It would be very helpful if you gave at least some hints as to your OS, version, etc.
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Tue Jul 08, 2003 8:24 pm    Post subject: Reply with quote

http://php.net/manual/en/function.setlocale.php may be a starter.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Cronet
Smarty Rookie


Joined: 21 May 2003
Posts: 15

PostPosted: Tue Jul 08, 2003 9:11 pm    Post subject: Reply with quote

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
View user's profile Send private message
BloodRath
Smarty Rookie


Joined: 06 Jul 2003
Posts: 23
Location: France

PostPosted: Sat Jul 12, 2003 12:54 am    Post subject: Reply with quote

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.... Wink
Back to top
View user's profile Send private message
AZTEK
Smarty Pro


Joined: 16 Apr 2003
Posts: 235
Location: Purdue University

PostPosted: Sat Jul 12, 2003 1:33 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Cronet
Smarty Rookie


Joined: 21 May 2003
Posts: 15

PostPosted: Sat Jul 12, 2003 11:06 am    Post subject: Reply with quote

Thank you for your answers...

I try it this weekend with your method!!
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