1
This hack will work with
news, forum, wf-sections, tinycontent or any module that uses the textsanitizer.
After searching the boards and posting a couple questions that never were answered, I had a go at this myself and well…necessity is the mother of invention….I discovered the module.textsanitizer.php file and messed with it till I got it to work. I am not a coder, so I am sure that someone can improve on this. (More on that later)
First things first:This hack assumes that you are using the multi-lingual hack that can be downloaded
here from ModsCentral.
To install it on Xoops2.x, follow the instructions I posted
here.
That will get your XOOPS to be multilingual.
Now to make your content multilingual:1. Open the module.textsanitizer.php file in the class folder. Around line 145 is the function “&xoopsCodeDecode” After the line
Quote:
and before the line
Quote:
$patterns[] = "/\[ code](.*)\\[\/ code\]/esU";
Place this code:
Quote:
//multi-lingual hack by chad--if japanese show japanese else show nothing
global $xoopsConfig;
$patterns[] = "/\[japanese](.*)\[\/japanese\]/sU";
if ($xoopsConfig['language'] == "japanese") {
$replacements[] = '\\1';
} else {
$replacements[] ="" ;
}
//if english show english else show nothing
$patterns[] = "/\[english](.*)\[\/english\]/sU";
if ($xoopsConfig['language'] == "english") {
$replacements[] = '\\1';
} else {
$replacements[] = "";
}
//end multi-lingual hack
Of course you will change the language ('english','japanese') to reflect the languages that you are targeting. The name in the brackets has to match the name of your language pack that you downloaded (or created). You could add more if you are targeting more than 2 languages.
To use this: When you add your article just enclose the section you want shown in a particular language in brackets with that language name. This is very similar to adding a url or code to an article. For example: Quote:
[english]This is my English text.[/english][japanese]kore ha nihongo desu.[/japanese] This text (not enclosed in brackets) will show up in both (all) languages.
If you are just targeting European languages, you may not have to worry about this, but if you are targeting multi-byte languages like Japanese you may have to manually change the character encoding of your English global.php file to match your japanese one.
That’s it! Basically very simple – If you are having problems with the layout, you probably are putting spaces between the codes.
I hope this helps!
Chad