11
Chado
Re: SOLVED - Making Xoops CONTENT Multilingual
  • 2003/7/17 2:17

  • Chado

  • Not too shy to talk

  • Posts: 113

  • Since: 2003/6/6 7


Thanks everyone,

You're right - the XOOPS code funtion changed my code! I edited my original post and changed it to a quote box and it seems to show up correctly. Basically the backslash was not showing up. I thought the code box would let us put anything in there, but not so....

If this doesn't work, PM me and I will be happy to email you my module.textsanitizer.php file.

Have fun!
Chad

12
niko11
Re: SOLVED - Making Xoops CONTENT Multilingual *Fixed Code Quote problem*
  • 2003/7/17 10:34

  • niko11

  • Just popping in

  • Posts: 4

  • Since: 2003/6/27


This hack works great but what's about translating the story title not just the body content . Maybe someone has found a way to translate the article title on-the-fly?

TIA
Niko

13
mvandam
Re: SOLVED - Making Xoops CONTENT Multilingual *Fixed Code Quote problem*
  • 2003/7/17 11:03

  • mvandam

  • Quite a regular

  • Posts: 253

  • Since: 2003/2/7 2


Hmmm, seems trickier. The title is stored in a relatively small fixed-length field. If you started adding:

[english]My Title[/english][gibberish]@#$SassdD#233[/gibberish]

you would soon run out of space for the real title. So I don't think the same approach would work easily unless title field was vastly extended in size.

Any ideas?

14
Chado
Re: SOLVED - Making Xoops CONTENT Multilingual *Fixed Code Quote problem*
  • 2003/7/17 15:59

  • Chado

  • Not too shy to talk

  • Posts: 113

  • Since: 2003/6/6 7


Quote:
This hack works great but what's about translating the story title not just the body content

Actually, it is also easy to make the Titles multilingual in much the same way as the content, with a simple hack to the same module.textsanitizer.php file. I did a quick look at how the tables are setup and most title fields are limited to 255 characters, so that probably is enough space most of the time for at least 2 languages.
I tested this real quickly here and it seems to work in at least the news, FAQ, Forum and WF-Sections. I don’t have a lot of other modules installed at the moment on my test site, so I couldn’t test too many others.
The only thing I found that didn't work was the comment titles. Someone might dig around and see if they can find how the comment title is produced.

Toward the bottom of the module.textsanitizer.php file in your class folder, there is a function called makeTboxData4Show and another one makeTboxData4Preview. In both of them just before the line:
return $text;
you need to add a new line like this:
$text =& $this->xoopsCodeDecode($text, 0);
That is it! This forces the titles to go through the XOOPS codedecoder where it will find your original language hack.

Hope this helps!
Chad

Here is what those two functions look like on my computer:
Quote:
function makeTboxData4Show($text, $smiley=0)
{
$text = $this->htmlSpecialChars($text);
$text =& $this->xoopsCodeDecode($text, 0);//added by chad
return $text;
}

function makeTboxData4Preview($text, $smiley=0)
{
$text = $this->stripSlashesGPC($text);
$text = $this->htmlSpecialChars($text);
$text =& $this->xoopsCodeDecode($text, 0);//added by chad
return $text;
}

15
mvandam
Re: SOLVED - Making Xoops CONTENT Multilingual *Fixed Code Quote problem*
  • 2003/7/17 18:17

  • mvandam

  • Quite a regular

  • Posts: 253

  • Since: 2003/2/7 2


Quote:

Toward the bottom of the module.textsanitizer.php file in your class folder,
[...]
This forces the titles to go through the XOOPS codedecoder where it will find your original language hack.


I haven't tried it, but looks like it should work. The only drawback is that if your users catch on, you might start getting all kinds of XOOPS codes in your titles, include changes of color/size, images, etc...

16
hsalazar
Re: SOLVED - Making Xoops CONTENT Multilingual *Fixed Code Quote problem*
  • 2003/7/17 18:36

  • hsalazar

  • Just popping in

  • Posts: 78

  • Since: 2003/2/6 1


Hi, all:

Two things. The first one is that after putting the correct code, I still had the message about some problem in the file. So I went and found this line:

return preg_replace(array("/>/i", "/", "<", "\"", "'"), $text);

I pondered a bit, and then changed it to:

return preg_replace(array("/>/i", "/\"/i", "/'/i"), array(">", "<", "\"", "'"), $text);

(notice the extra backslash)

... and I got rid of the error message and indeed the story part of the module worked allright.

The second thing is I tried the additional hacks for the story titles. And here are two issues. The first one is that even though the field in the database is 255 characters long, the form fills much faster, so I need to change the maximum number in the form creator (haven't done it yet).

The second issue is that even with short titles, the display has problems...

For instance. In the title field I write:

[spanish]Ejemplo de noticia[/spanish] [english]Sample news item[/english]

Then I go to my site and use the selector to choose Spanish. The idea is I should get:

Ejemplo de noticia

but instead I get:

Ejemplo de noticia [engli...

When I change to English, I should get:

Sample news item

but instead I get:

[engli...

I don't know if adding the backslash in the function &undoHtmlSpecialChars is affecting my results. What do you think?



LATE NIGHT EDITION: Here's another riddle: how to extend this hack to the main menu tags so that they also change with the language switch...

17
dawilby
Re: SOLVED - Making Xoops CONTENT Multilingual *Fixed Code Quote problem*
  • 2003/7/18 19:54

  • dawilby

  • Module Developer

  • Posts: 31

  • Since: 2002/1/3 0


Hi hsalazar,

This has to do with the title lenght. I mean, if a title is to long, the last bit will be replaced by '...' thus cutting off the closing [/english] tag.

The main title tags probably don't use the class in module.textsanitizer.php otherwise they would translated as the rest...


18
mvandam
Re: SOLVED - Making Xoops CONTENT Multilingual *Fixed Code Quote problem*
  • 2003/7/18 20:56

  • mvandam

  • Quite a regular

  • Posts: 253

  • Since: 2003/2/7 2


Ah, yes good point dawilby... In many places, the title is truncated, just in case someone puts in a really long title (i.e. so they don't mess up your page layout). This trucation happens to the original full string... it is not until afterwards that the language hack occurs. Thus for the english one, the truncated title is "[spanish]...[/spanish][engl"... and then after the language hack, the 'spanish' part is stripped out, leaving only [engl...

Maybe this indicates a bug... need to look into it

19
hsalazar
Re: SOLVED - Making Xoops CONTENT Multilingual *Fixed Code Quote problem*
  • 2003/7/18 21:13

  • hsalazar

  • Just popping in

  • Posts: 78

  • Since: 2003/2/6 1


mvandam, dawilby, all:

Thanks for your time and attention. I took the original sanitizer file, applied the hack and reuploaded the new file. Bang! It worked! You can see the results here.
For the moment, I've seen it work for the news, the forums, spotlight, and Tiny Content.
Still missing: a way to change titles in blocks (for the moment I'm using messages in both languages), and a way to change tags in the main menu.
But all in all, I'm very satisfied, and I hope I can build (with the help from everybody) a good site, a useful and "nutritious" site.
Thanks to you all!

20
Chado
Re: SOLVED - Making Xoops CONTENT Multilingual *Fixed Code Quote problem*
  • 2003/7/19 17:25

  • Chado

  • Not too shy to talk

  • Posts: 113

  • Since: 2003/6/6 7


Making Multi-lingual Menu items
Quote:
hsalazar wrote: Bang! It worked!...Still missing: a way to change titles in blocks,... and a way to change tags in the main menu.

Hsalazar, Glad to hear that the hacks are working out! Your site is looking great!

I have a couple ideas for how to make custom multi-lingual menus that I am experimenting with on my site. Right now these deal with the menu items only and not the menu title. Maybe one of them will help you with your site there.

Idea #1: Make a custom PHP block and put the following code in and obviously change it to fit your language and links.
Quote:
global $xoopsConfig;
$arr[key] = value;
//put as many Japanese links here as needed
if ($xoopsConfig['language'] == "japanese") {
$Mylink["ホーム"] = "{X_SITEURL}modules/wfsection/article.php?articleid=8";
$Mylink["CLCFamilyについて"] = "{X_SITEURL}";
$Mylink["セレブレーションサンデー!!"] = "{X_SITEURL}modules/wfsection/article.php?articleid=5";
$Mylink["ハウス チャーチ"] = "{X_SITEURL}";
$Mylink["聖書の英会話"] = "{X_SITEURL}";
$Mylink["FAQ"] = "{X_SITEURL}modules/xoopsfaq/";
$Mylink["FORUM"] = "{X_SITEURL}modules/newbb/";
//put English links here
} else {
$Mylink["Home"] = "{X_SITEURL}modules/wfsection/article.php?articleid=8";
$Mylink["About Us"] = "{X_SITEURL}";
$Mylink["Celebration Sunday!"] = "{X_SITEURL}modules/wfsection/article.php?articleid=5";
$Mylink["House Churches"] = "{X_SITEURL}";
$Mylink["English Bible Classes"] = "{X_SITEURL}";
$Mylink["FAQ"] = "{X_SITEURL}modules/xoopsfaq/";
$Mylink["Forum"] = "{X_SITEURL}modules/newbb/";
}
//build table based on links
echo "
";
foreach ($Mylink as $Show => $Link) {
echo "";
}
echo "
";


I don’t think too many of you will have the same Menu items as me! My site, clcfamily.net, for a church in Osaka, Japan is very much under contruction and there isn't too much content up, except the FAQ, but it would give you an idea of how all these multi-lingual hacks are working.

Using that idea you can make as many menus or other types of pages that you need…

Idea #2: Using the recently released iMenu 2 – in blocks/imenu.php file change line 30 to this:
Quote:
That will force the menu titles to go through to XOOPS decoder.

I hope that helps!
Chad
clcfamily.net

Login

Who's Online

380 user(s) are online (269 user(s) are browsing Support Forums)


Members: 0


Guests: 380


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits