How to restrict who may read my blog?
[SMARTY] Multilangual support for websites
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What can I do?
• What to Read?
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Зарегистрируйся!

QAIX > PHP web-programming > [SMARTY] Multilangual support for websites 3 June 2002 12:01:22

  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Moderators:

[SMARTY] Multilangual support for websites

Onno de Graaff 3 June 2002 12:01:22
 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!

--
Smarty General Mailing List (http://smarty.php.­net/)
To unsubscribe, visit: http://www.php.net/­unsub.php


Add comment
LIMBOURG Arnaud 31 May 2002 13:06:43 permanent link ]
 One way is to have templates for each language and structure them like:

mytemplatesdir/
en/
main.tpl
fr/
main.tpl
es/
main.tpl


You define a var on script execution like $mylang

and do

$smarty->display($m­ylang . "/main.tpl);

Arnaud.
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!>
-- > Smarty General Mailing List (http://smarty.php.­net/)> To unsubscribe, visit: http://www.php.net/­unsub.php>

--
Smarty General Mailing List (http://smarty.php.­net/)
To unsubscribe, visit: http://www.php.net/­unsub.php


Add comment
Ben Godfrey 31 May 2002 13:45:42 permanent link ]
 
This isn't a best practice suggestion, it's just a random idea,
but I think that config files sound like a great solution to
localisation. Stick all your data in there and load the right
one by assigning a language template variable from the PHP:

$smarty->assign("la­nguage_config", "config/$language.c­fg");

{config_load file=$language_conf­ig}

Ben


On Friday, May 31, 2002, at 11:06 AM, LIMBOURG Arnaud wrote:
One way is to have templates for each language and structure them like:>
mytemplatesdir/> en/> main.tpl> fr/> main.tpl> es/> main.tpl>
You define a var on script execution like $mylang>
and do>
$smarty->display($m­ylang . "/main.tpl);>
Arnaud.>
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!>>
-->> Smarty General Mailing List (http://smarty.php.­net/)>> To unsubscribe, visit: http://www.php.net/­unsub.php>>
--> Smarty General Mailing List (http://smarty.php.­net/)> To unsubscribe, visit: http://www.php.net/­unsub.php>


--
Smarty General Mailing List (http://smarty.php.­net/)
To unsubscribe, visit: http://www.php.net/­unsub.php


Add comment
Ubaldo Huerta 31 May 2002 19:19:11 permanent link ]
 A variation on this theme that has proved very useful for me is
the following:

foo.tpl
{ config_load file=_foo.conf section=$lang }
{#copyright#}

_foo.conf
copyright = untranslated

[english]
copyright = Copyright 2002 All rights reserved

[spanish]
copyright = Copyright 2002 Todos los derechos reservados

[catala]
copyright = Copyright 2002 Todos los derechos sin traducir

foo.php
$smarty->assign("la­ng","spanish");
$smarty->display("f­oo.tpl");

Mucha suerte
Ubaldo

From: Ben Godfrey <ben@hypothetical.c­o.uk>>To: smarty-general@list­s.php.net>CC: smarty-general@list­s.php.net>Subject: Re: [SMARTY] Multilangual support for websites>Date: Fri, 31 May 2002 11:45:42 +0100>
This isn't a best practice suggestion, it's just a random idea, but I think >that config files sound like a great solution to localisation. Stick all >your data in there and load the right one by assigning a language template >variable from the PHP:>
$smarty->assign("l­anguage_config", "config/$language.c­fg");>
{config_load file=$language_conf­ig}>
On Friday, May 31, 2002, at 11:06 AM, LIMBOURG Arnaud wrote:>
One way is to have templates for each language and structure them like:>>
mytemplatesdir/>>­en/>>main.tpl>>fr/>>­main.tpl>>es/>>main.­tpl>>
You define a var on script execution like $mylang>>
and do>>
$smarty->display(­$mylang . "/main.tpl);>>
Arnaud.>>
Are there any best practices or code-examples on supporting>>>multil­angual 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!>>>
-->>>Smarty General Mailing List (http://smarty.php.­net/)>>>To unsubscribe, visit: http://www.php.net/­unsub.php>>>
-->>Smarty General Mailing List (http://smarty.php.­net/)>>To unsubscribe, visit: http://www.php.net/­unsub.php>>
-->Smarty General Mailing List (http://smarty.php.­net/)>To unsubscribe, visit: http://www.php.net/­unsub.php




___________________­____________________­____________________­______
Join the world’s largest e-mail service with MSN Hotmail.
http://www.hotmail.­com


--
Smarty General Mailing List (http://smarty.php.­net/)
To unsubscribe, visit: http://www.php.net/­unsub.php


Add comment
Bertrand DUNOGIER 2 June 2002 22:47:50 permanent link ]
 
i have a config-file for each template. for every language a haveRC> a section in each config-file. then i have a language variable asRC> well. let's say $lng and it's assigned to each template.RC> in the templates then i sayRC> {config_load file="filename" section=$lng}
This method takes in my opinion too much time to implement. You have
to modify every template the designer gives you to make it fit the
multilingual system...

What i'm using at the moment is a very simple {translate} function,
which takes as an optionnal argument the language, or uses the session
var $_SESSION['lang'] and echoes the corresponding string.
Example:
{translate fr='texte francais' en='english text'}

until now, it worked perfectly.

Bertrand


--
Smarty General Mailing List (http://smarty.php.­net/)
To unsubscribe, visit: http://www.php.net/­unsub.php


Add comment
Bram van Leur 3 June 2002 12:01:22 permanent link ]
 I'm doing exactly the same using named strings in a database. A
smarty-complier-fun­ction 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-fu­nction 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!


--
Smarty General Mailing List (http://smarty.php.­net/)
To unsubscribe, visit: http://www.php.net/­unsub.php


Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или УК РФ.


QAIX > PHP web-programming > [SMARTY] Multilangual support for websites 3 June 2002 12:01:22

see also:
PHP 4.x on Apache 2.x?
Need PHP 4.0.3pl1
PHP 4.1.0 Comments
пройди тесты:
see also:
What is OPC drum?-Conditioning
Who supply the accessaries of toner…

  Copyright © 2001—2008 QAIX
Idea: Miсhael Monashev
Помощь и задать вопросы можно в сообществе support.qaix.com.
Сообщения об ошибках оставляем в сообществе bugs.qaix.com.
Предложения и комментарии пишем в сообществе suggest.qaix.com.
Информация для родителей.
Write us at:
If you would like to report an abuse of our service, such as a spam message, please .