Hello all,
I'm running a gallery (1.42) that is using two languages:
English + Hebrew (LTR/RTL)
Maintaining such a gallery in both RTL/LTR directions can be a real pain.
You can't use the same theme for both English and Hebrew because the RTL/LTR differences are making the image files show wrongly and distort the design. This happens when you have an image frame that distiniguishes the right and left border, such as the Transmission theme and others.
I wanted to create a fast and simple solution to make one theme support multiple languages so when you switch a language, the design shows properly.
This MOD involves creating a new theme for each language you use. Please note that you must create a theme for EVERY LANGUAGE. If you don't use a language from the big languages list, you will have to remove the file from the \lang directory. When you switch a language, the theme will automatically switch to a theme with the same name as the language. If you're not concerened with RTL/LTR directions, this MOD is not for you.
Before you change anything, backup your files and verify that you understand what this MOD is doing !
The idea is very simple and include two small changes to the file "include/functions.inc.php"
First we will link the name of the language with a name of a theme, so when we change a language, the theme will be changed as well.
Find this line in functions.inc.php:
$return.= '<select name="cpgLanguageSelect" class="listbox_lang" onchange="if (this.options[this.selectedIndex].value) window.location.href=\'' . $cpgChangeUrl . '\' + this.options[this.selectedIndex].value;">' . $lineBreak;
Replace with this line:
$return.= '<select name="cpgLanguageSelect" class="listbox_lang" onchange="if (this.options[this.selectedIndex].value) window.location.href=\'' . $cpgChangeUrl . '\' + this.options[this.selectedIndex].value + \'&theme=\' + this.options[this.selectedIndex].value;">' . $lineBreak;
To complete the change, we have to change the way coppermine deals with languages and add support for theme as well:
Find this line in functions.inc.php
if ($key!="lang"){$cpgChangeUrl.= $key . "=" . $value . "&";}
Replace with this line:
if ($key!="lang" && $key!="theme")$cpgChangeUrl.= $key . "=" . $value . "&";
To make it work, you have to take the directory of your favorite theme, create a new directory under the /themes directory and call it with the name of the language.
For example:
english
hebrew
Copy all the files to each directory, and now is the tricky part: You have to replace all references to the theme's name with the name of the language. The best is to use a mass replace application such as Ultra-Edit.
For example: Replace all occurences of "transmission" to "hebrew".
Please remember, that when you do a mass replace, the image file-names will also be changed so you'll have to change the file-names under the images directory as well.
The last thing to do is to fix the RTL problem with the images: Switch an image which is supposed to be located on the right to the left, and vice-versa. This can be done by renaming the files.
That's it, you're done !
Final notes: although this sounds a little bit clumsy, this MOD works very well with two languages and you can even use it to put static text inside the theme files so the titles will be in different languages. The only two changes that you make are to the file functions.inc.php. All the rest is simply manipulating two new themes.
Of course, the real solution for this problem will be to deal with image file like phpBB (images directory per langauge), but until it happens you can use this one.
Edit: To hide the default language from the languages list, comment the following lines in functions.inc.php:
//if ($CONFIG['language_reset'] == 1){
// $return.= '<option value="xxx">' . $lang_language_selection['reset_language'] . '</option>' . $lineBreak;
//}
Amir W.