Re: Multilangual support for websites
| From: | Bram van Leur | Date: | Mon, 03 Jun 2002 09:01:22 +0000 |
| Subject: | Re: Multilangual support for websites | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-4508@lists.php.net to get a copy of this message | ||
I'm doing exactly the same using named strings in a database. A smarty-complier-function retrieves the desired language-specific string.
I've created a system (which I call NetPages, for no particular reason) which uses Smarty as it's template engine. It extends smarty which some functions I needed like automatically generating (image) urls (possibly language specific) and the text strings in the page.
A nice trick I've used is a informational comment on the top of each Template. At compile-time, a smarty-prefilter-function fetches that header which for example looks like this:
{*NetPagesTplHdr
# Copyright TotalGSM / NetImpuls New Media 2002
@name rtl_displayrt
@description Displays a ringtone with all of it's options.
@pagetype tgsmnormal
@css all rtl_displayrt
@jsfiles dynapi rtl rtl_displayrt otainc
*}
Most 'tags' in this header are self-explaining. Pagetype lets NetPages decide which header and footer to attach (which sometimes can be 'tgsmblank' for a popup-template or 'tgsmwizard' for some pages which appear inside a special frame for example). The Pagetype header is filled with some code to include the javascript files and the links to the style sheets.
So far for my (kinda odd) implementation of multi-lingual stuff. It gets much weirder if I start to explain how URLs get generated using a random set of parameters... so I won't bother you with that. Hope this story is usefull to someone.
Onno De Graaff wrote:
Are there any best practices or code-examples on supporting multilangual templates?
The kind of solution I'm working on at the moment is as follows:
[ show_users.tpl ]
include [ app_header.tpl ]
include [ app_footer.tpl ]
Every tpl contains certain language-specific elements. However,
I don't like to create a tpl for every language (and any browser).
Instead I created a Smarty-function that retrieves content for the
language elements in the requested language. This function uses tpl-specific files for caching, which are exported managed from a central database. This database is managed by the client using a webfrontend.
In this way
* templates are not language-specific, just define layout and interaction
* language elements are bind to a specific (included) template
If anyone is busy working on the same topic and like to exchange thoughts, feel free to toss your ideas this way =)
Grtz!
--
Bram v. Leur
The Netherlands
Proud to PHP!