Language support for blog templates

Posted by fmon 
Language support for blog templates
May 28, 2007 06:10PM
I have several blog templates that I would like to post after I finish some details. Would including language support be good? No problem for words and phrases that are already used by Phorum. New ones would make it necessary to copy some date to the language file in the lang directory in order to use the templates, they would not work if the file dose not include some new data. So, no support, only support existing words/phrases or support everything? The Phorum blog template has some language support.

Frank
Re: Language support for blog templates
May 28, 2007 06:13PM
Language support is good.
Someone posted a module which makes it possible to put a language file in the template directory too. Maybe you could use that. It's also possible to write a simple module with only a lang hook, to provide extra language strings. The template would then consist of template files + the module for providing language strings.

Editing the core language files isn't really a good solution, because that would mean continous editing on upgrades, which is pretty error prone.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Language support for blog templates
May 31, 2007 09:38PM
This works without using a mod.

Put this near the top of the header.tpl file:

<?php   
if( is_readable("./templates/TestBlogTemplate/lang/$PHORUM[language].php")) {
    include_once("./templates/TestBlogTemplate/lang/$PHORUM[language].php");
    $PHORUM["DATA"]["LANG"] = array_merge( $PHORUM["DATA"]["LANG"], $BlogTemplateLang);
}
elseif( is_readable("./templates/TestBlogTemplate/lang/english.php")) {
    include_once("./templates/TestBlogTemplate/lang/english.php");
    $PHORUM["DATA"]["LANG"] = array_merge( $PHORUM["DATA"]["LANG"], $BlogTemplateLang);
}
?>

In this example the template directory is TestBlogTemplate, it contains a lang directory which contains the language files such as english.php. The language file has the array $BlogTemplateLang which is formated like the $PHORUM['DATA']['LANG'] array and contains the additional strings needed by the template, they are merged with the standard language file, any duplicates in the template file overwriting the standard lang strings.

Is there anything wrong with this approach?
Re: Language support for blog templates
June 01, 2007 01:20AM
No, this perfectly okay. You are allowed to use as much PHP in your templates as you like. That's the reason why the template system was setup like this in the first place.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Your IP address, domain or ISP has been blocked. Please contact the forum administrators.
Sorry, only registered users may post in this forum.

Click here to login