|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Madness Smarty n00b
Joined: 23 Apr 2013 Posts: 2
|
Posted: Tue Apr 23, 2013 1:49 pm Post subject: Multilanguage integration |
|
|
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 |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue Apr 23, 2013 5:56 pm Post subject: |
|
|
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 |
|
Madness Smarty n00b
Joined: 23 Apr 2013 Posts: 2
|
Posted: Wed Apr 24, 2013 11:58 am Post subject: |
|
|
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 |
|
|
|
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
|