ImpressCMS has the Multilanguage feature, but it is referred to the use in the core or in the modules. If you like to use multilenguage for the themes you must make some changes in them. Of course, you could modify the ImpressCMS code too but it is more easy this possibility Smarty bassed. An ImpressCMS_theme is basically a html document with instructions specially make for Smarty and it has two main sections: HTML code and Smarty Code. This changes automatically according site content; however the HTML code stay without modifications and normally the images, links and texts that are not to generate by ImpressCMS (they are not dynamic) stay thus in all sections. It do a few more difficult to work in environments multi-language. Imagine that you have a theme with internal links supported by images; if an user request the site in English and the images look with Spanish text, although all site are translated the images will not change. It is the utility of this way that you will read.

The "theme.html" file

In this file we take the control of the functionality required and I tell to you that I had used this way a lot of times with success. Open the file theme.html and in the section add this code:
<{php}> global $xoopsConfig; $this->assign(‘xoops_language’, $xoopsConfig[‘language’]): <{/php}>
Explanation: the tags “<{php}> … <{/php}>” tell Smarty to interpret the code as PHP code and it will be perform in the server. The expression “$this->assign(..)” tells Smarty to store a new variable called “xoops_language” which contains the language name that the user is updating at the moment. This variable will be useful forwards. Now we can make our multi-language theme and we can dynamically change the text or the images in the page according to the user's language.

Preparing several languages

We'd suppose that the theme header contains a welcome text and we want prepare this text in the adequate language. It is very easy! You can start making different folders or files inside the theme folder, one for each language. Make (in the becoming folder) a file: welcome.html, for example. It only contains the text that you want to show in the right language, then in your file theme.html, just where you want to show the text you change the text to this code:
<{include file=”yourtheme/<{$xoops_language}>/welcome.html”}>
ImpressCMS automatically will load the correct file (located in the folder that contains the select language) and show it. You can repeat this way for anything that you would want to change depending which is the necessary language. About the images you only must to use a code as this:
images/<{$xoops_language}>/imagen.jpg” />
Remember: you must change the path for the adequate and you can make inside your images folder another folder for each image group in the language matching. This suggest to you another ways to use this smarty functionalities. Additional note: TemasWeb offers multi-language themes ready with these possibilities.

This little tutorial is an adaptation to ImpressCMS of the work published in Xoops-México. You can read the original tutorial (in spanish) here Credits: BITC3R0 Category: Themes Category: Getting Started <[Languages ]>

Last modified on 2010/11/13 by Anonymous
The comments are owned by the poster. We aren't responsible for their content.