View previous topic :: View next topic |
Author |
Message |
andreas Smarty Pro
Joined: 22 Apr 2003 Posts: 106
|
|
Back to top |
|
Wom.bat Smarty Pro
Joined: 24 Apr 2003 Posts: 107 Location: Munich, Germany
|
Posted: Thu Apr 24, 2003 7:17 pm Post subject: |
|
|
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 |
|
AZTEK Smarty Pro
Joined: 16 Apr 2003 Posts: 235 Location: Purdue University
|
Posted: Thu Apr 24, 2003 8:29 pm Post subject: |
|
|
Thats why you use the international standard of using a space like 75 934 also this seems to be our first multipage thread w00t _________________ "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 |
|
andreas Smarty Pro
Joined: 22 Apr 2003 Posts: 106
|
|
Back to top |
|
Wom.bat Smarty Pro
Joined: 24 Apr 2003 Posts: 107 Location: Munich, Germany
|
Posted: Fri Apr 25, 2003 11:11 am Post subject: |
|
|
please see my posting on this page again... |
|
Back to top |
|
andreas Smarty Pro
Joined: 22 Apr 2003 Posts: 106
|
|
Back to top |
|
Wom.bat Smarty Pro
Joined: 24 Apr 2003 Posts: 107 Location: Munich, Germany
|
Posted: Fri Apr 25, 2003 12:32 pm Post subject: |
|
|
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 |
|
andreas Smarty Pro
Joined: 22 Apr 2003 Posts: 106
|
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
|
Back to top |
|
risto Smarty Rookie
Joined: 26 Apr 2003 Posts: 21 Location: Norway
|
Posted: Sun Apr 27, 2003 6:51 pm Post subject: Recomandation!!!!! |
|
|
This XML version is just exelent! I very much recomend it! |
|
Back to top |
|
andre Smarty Pro
Joined: 23 Apr 2003 Posts: 164 Location: Karlsruhe, Germany
|
Posted: Mon Apr 28, 2003 6:45 am Post subject: |
|
|
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 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 |
|
AZTEK Smarty Pro
Joined: 16 Apr 2003 Posts: 235 Location: Purdue University
|
Posted: Mon Apr 28, 2003 8:55 am Post subject: |
|
|
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 |
|
andre Smarty Pro
Joined: 23 Apr 2003 Posts: 164 Location: Karlsruhe, Germany
|
Posted: Mon Apr 28, 2003 11:50 am Post subject: |
|
|
you got the point ... |
|
Back to top |
|
andreas Smarty Pro
Joined: 22 Apr 2003 Posts: 106
|
|
Back to top |
|
andre Smarty Pro
Joined: 23 Apr 2003 Posts: 164 Location: Karlsruhe, Germany
|
Posted: Tue Apr 29, 2003 7:42 am Post subject: |
|
|
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? |
Do you expect me to answer my own script is sh*t?
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 |
|
|