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

best way to build a multi-language site with smarty
Goto page Previous  1, 2, 3, ... 13, 14, 15  Next
 
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 -> Tips and Tricks
View previous topic :: View next topic  
Author Message
andreas
Smarty Pro


Joined: 22 Apr 2003
Posts: 106

PostPosted: Thu Apr 24, 2003 12:48 pm    Post subject: Reply with quote

I think your script is the best way for my application. What I do not know yet is, if I should use your tags(##...) , or if it is better to use something like {translate string="blablabla"} or {translate}blablabla{/translate}, what do you think about using this? Why did you create these "tags"?
What about using a variable ($username) somewhere in a sentence if I want to use your script?
What do you think of saving the data as XML, not flat-files as you do?

________
Ferrari 166 history


Last edited by andreas on Fri Feb 04, 2011 9:00 am; edited 2 times in total
Back to top
View user's profile Send private message
Wom.bat
Smarty Pro


Joined: 24 Apr 2003
Posts: 107
Location: Munich, Germany

PostPosted: Thu Apr 24, 2003 7:17 pm    Post subject: Reply with quote

I personally don't like to have placeholders for text stored in seperate files. I usually do it directly in the templates by using sth like
{if ($_SESSION.language == "EN")}English{elseif ($_SESSION.language == "DE")}Deutsch{/if}
I know that this is not the most comfortable way to extend templates with another language, but I just can't help myself on hating this language-file stuff...
I am taking this approach, too, because you often don't have to create content in different language, but, for example, have different date formatting methods:
{if ($_SESSION.language == "EN")}{$timestamp|date_format:"%B %d %Y, %H:%M"}{elseif ($_SESSION.language == "DE")}{$timestamp|date_format:"%d. %m. %Y, %H:%M"}{/if}
or other things... for example, many languages (german, french, ...) seperate decimal places using a comma: 17,24... but in english, you use a period: 17.24...
Back to top
View user's profile Send private message
AZTEK
Smarty Pro


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

PostPosted: Thu Apr 24, 2003 8:29 pm    Post subject: Reply with quote

Thats why you use the international standard of using a space like 75 934 also this seems to be our first multipage thread w00t Smile
_________________
"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
andreas
Smarty Pro


Joined: 22 Apr 2003
Posts: 106

PostPosted: Fri Apr 25, 2003 7:01 am    Post subject: Reply with quote

Right, date-format is the next problem. IN PHP itself it would be no problem, I can define the date-formate somewhere globally, as

Code:
if($lang="en") {
    $format = "d.m.y";
}

date($format,$timestamp);

date($format,$timestamp2);

date($format);

....



But how could I do this in smarty?
Is there a possibility to use a variable $format as above?

Same problem with using number_format().

Perhaps I should use own date and number-Format functions which use number_format / date...?

________
Ford Escort RS Cosworth specifications

Last edited by andreas on Fri Feb 04, 2011 9:00 am; edited 2 times in total
Back to top
View user's profile Send private message
Wom.bat
Smarty Pro


Joined: 24 Apr 2003
Posts: 107
Location: Munich, Germany

PostPosted: Fri Apr 25, 2003 11:11 am    Post subject: Reply with quote

please see my posting on this page again...
Back to top
View user's profile Send private message
andreas
Smarty Pro


Joined: 22 Apr 2003
Posts: 106

PostPosted: Fri Apr 25, 2003 11:29 am    Post subject: Reply with quote

I have seen it, but I don't want to have things like that in my(each) template! I would like to say from PHP which date-format should be used, and in Smarty only display date without ifs and own formating.
________
cheap vaporizers


Last edited by andreas on Fri Feb 04, 2011 9:00 am; edited 2 times in total
Back to top
View user's profile Send private message
Wom.bat
Smarty Pro


Joined: 24 Apr 2003
Posts: 107
Location: Munich, Germany

PostPosted: Fri Apr 25, 2003 12:32 pm    Post subject: Reply with quote

you could create a config file, sth like date_format.conf like this:
Code:

[en]
format = "%Y-%m-%d"
[de]
format = "%d.%m.%y"

then, in your template:
Code:

{config_load file="date_format.conf" section=$language}

and then do
Code:

{$timestamp|date_format:$smarty.config.format}
Back to top
View user's profile Send private message
andreas
Smarty Pro


Joined: 22 Apr 2003
Posts: 106

PostPosted: Fri Apr 25, 2003 12:55 pm    Post subject: Reply with quote

is it possible to load a config-file from PHP? Before loading the template? Or "assign" it to the template?
________
[URL=http://www.mercedes-wiki.com/wiki/Mercedes_Benz_Limousine_W126_(1000SEL)]Mercedes Benz Limousine W126 (1000SEL)[/URL]


Last edited by andreas on Fri Feb 04, 2011 9:00 am; edited 2 times in total
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Fri Apr 25, 2003 2:29 pm    Post subject: Reply with quote

andreas wrote:
is it possible to load a config-file from PHP? Before loading the template? Or "assign" it to the template?


Yes, with $smarty->config_load()

http://smarty.php.net/manual/en/api.config.load.php
Back to top
View user's profile Send private message Visit poster's website
risto
Smarty Rookie


Joined: 26 Apr 2003
Posts: 21
Location: Norway

PostPosted: Sun Apr 27, 2003 6:51 pm    Post subject: Recomandation!!!!! Reply with quote

Very Happy Very Happy Very Happy
This XML version is just exelent! I very much recomend it!
Back to top
View user's profile Send private message
andre
Smarty Pro


Joined: 23 Apr 2003
Posts: 164
Location: Karlsruhe, Germany

PostPosted: Mon Apr 28, 2003 6:45 am    Post subject: Reply with quote

As long as your PHP has XML support I would recommend using XML style files also. But if your webspace provider doesn't provide DOMXML you will get problems Wink Using phpDOM or phpXML (don't know how it's called) you'll get serious speed problems.
That's the reason why my script uses plain text files.
Back to top
View user's profile Send private message
AZTEK
Smarty Pro


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

PostPosted: Mon Apr 28, 2003 8:55 am    Post subject: Reply with quote

That requires built in expat support which is enable per default not domxml
_________________
"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
andre
Smarty Pro


Joined: 23 Apr 2003
Posts: 164
Location: Karlsruhe, Germany

PostPosted: Mon Apr 28, 2003 11:50 am    Post subject: Reply with quote

Embarassed you got the point ...
Back to top
View user's profile Send private message
andreas
Smarty Pro


Joined: 22 Apr 2003
Posts: 106

PostPosted: Mon Apr 28, 2003 6:41 pm    Post subject: Reply with quote

@andre: as I can install whatever I want to have, would you recommend me to use the XML-soluten as described above, or would you change your script and change the usage of flat-files to usage of xml-files?
________
marijuana sativa


Last edited by andreas on Fri Feb 04, 2011 9:00 am; edited 2 times in total
Back to top
View user's profile Send private message
andre
Smarty Pro


Joined: 23 Apr 2003
Posts: 164
Location: Karlsruhe, Germany

PostPosted: Tue Apr 29, 2003 7:42 am    Post subject: Reply with quote

Quote:
as I can install whatever I want to have, would you recommend me to use the XML-soluten as described above, or would you change your script and change the usage of flat-files to usage of xml-files?


Laughing Do you expect me to answer my own script is sh*t? Wink
Seriously I would now prefer XML for storing the data but it's not really needed in the case of my script. The language files are INI style and very simple to understand and to parse. Using XML here would give no real advantage. If you really want the languages files in XML format it would be no problem to alter my script in a few minutes.

So it's your decision what style of templates you prefer.
Code:

  {tanslate id="hello"} {$username}

Code:

  {translate u=$username}Hello %u{/translate}

Code:

  ##hello## {$username}
  {foo bar="##hello## `$username`"}


All approaches have their advantages and disadvantages. My intention was to make translations as easy to maintain as possible. Thats why I am using separate files which you can give to friends or paid translators to get different language support. There's no need to give your whole project away if you need another language.

The style of the language tags (##hello##) can be varied by changing my script so perhaps you want to use %%hello%% or just anything else.

Hope that helps,
André
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 -> Tips and Tricks All times are GMT
Goto page Previous  1, 2, 3, ... 13, 14, 15  Next
Page 2 of 15

 
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