Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Multilanguage integration

 
Post new topic   Reply to topic    Smarty Forum Index -> Frameworks
View previous topic :: View next topic  
Author Message
Madness
Smarty n00b


Joined: 23 Apr 2013
Posts: 2

PostPosted: Tue Apr 23, 2013 1:49 pm    Post subject: Multilanguage integration Reply with quote

Hi, I have my own tiny MVC framework I've been working on since forever, now I have to make a site that doesn't just have multilingual content, but also multilingual paths.

I'm stumped tho on how to create a configuration structure that is flexible and allows both the routing component and smarty to access those parameters.

Any ideas?
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 4671
Location: Hamburg / Germany

PostPosted: Tue Apr 23, 2013 5:56 pm    Post subject: Reply with quote

If you have language dependent templates you could create for each language a subfolder to the main template folder.

If you set
Code:
$smarty->setTemplateDir(array('.' . DS . 'templates' . DS . $lang .DS, '.' . DS . 'templates' . DS));


Smarty would look for template first in the subfolder defined by variable $lang. If it does not find the template there it would fall back to the main template folder.

You will not need separate folders for the compiled and cache files.
Smarty will keep there the different languages separated automatically.

But to keep there a better overview by subfolders just set
Code:
$smarty->compile_id =$lang;
Back to top
View user's profile Send private message
Madness
Smarty n00b


Joined: 23 Apr 2013
Posts: 2

PostPosted: Wed Apr 24, 2013 11:58 am    Post subject: Reply with quote

But won't that require me creating multiple copies of every template for every different language?

I'd much rather just have one html structure and swap selected strings.

Also I was more looking for hints on how to create a configuration file that would ideally work both for smarty, for my routing component (hand made, so I can tinker with it as much as I want) and for other controller-based routines (like error messages in crud modules).

A gettext based solution would be nice except for the routing part. I have no idea how to set up translation tables that allow me to send /it/aiuto to the same controller as /en/help and /es/ayuda.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Frameworks 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