PDA

View Full Version : mutliple language support on the fly


05-14-2000, 02:51 AM
Oh it's a hack but it works. Suport multiple languages with one template set. Put links on your page that when clicked chance all the vB text like username, pwd, etc to spanish, german etc. Uses dictionary libraries that get importated by the PHP scripts. Goign live tonite on my site. Reply here if you are curious.

J

05-14-2000, 03:12 AM
This sounds nice, keep us updated..

-Brian

05-24-2000, 10:20 AM
We've been live on this one for over a week now. We set a cookie variable 'Eng' or 'Ita' and global.php imports a dictinary file based upon that setting. In our templates, all text is replaced with $variables which are cross referenced in the aforementioned included file from global.php.

We'll be adding Italian and French support this week. That brings this hack to six langs (Eng, Spa, Port, Germ), and switching the language of the vB on the fly.

The links are at the top of every page of our site.

Best,

H

[Edited by Huss on 05-24-2000 at 07:22 PM]

06-15-2000, 03:25 AM
Any change you'd share this hack? :)

08-24-2000, 11:35 AM
We've been live on this one for over a week now. We set a cookie variable 'Eng' or 'Ita' and global.php imports a dictinary file based upon that setting. In our templates, all text is replaced with $variables which are cross referenced in the aforementioned included file from global.php.
[Edited by Huss on 05-24-2000 at 07:22 PM] [/QUOTE]

I've been using this method to implement multi-language support too, and mostly succesful. However, there seems to be a problem with the forumjump template.

Using this code in forumjump (which is the standard code except for the variables $forumjumpmessage, $selectone and $gobutton that are introduced.

<FONT SIZE="2" FACE="arial, helvetica"><FORM ACTION="forumdisplay.php" METHOD="GET"><B>$forumjumpmessage</B>
<SELECT NAME="forumid">
<option $defaultselected>$selectone</option>
$jumpforumbits
</SELECT>
<input type="hidden" name="daysprune" value="$daysprune">
<INPUT TYPE="SUBMIT" VALUE=$gobutton></FORM></font>

However, the variable-content is not added to the page, resulting in empty strings. I only have this problem with the forumjump template, and the variables are correctly defined in the language files. If I copy this code exactly to the forumdisplay template, there is no problem, and everything works perfectly. I could off course do that for every form that uses the forumjump template, but that's a far-from-nice approach.

Can anybody here please tell me what I'm doing wrong or why the forumjumptemplate is so special. How can I fix this problem?

Thank you in advance

Yves

08-24-2000, 01:34 PM
Are you including the variable definitions via global.php or where?

H

08-24-2000, 02:15 PM
Originally posted by Huss
Are you including the variable definitions via global.php or where?

H

Yes... In global.php I have included following code:

if (!(isset($language)))
$language = "Eng";

if ($language == "Eng") include ("English.php");
if ($language == "Ned") include ("Dutch.php");
if ($language == "Fra") include ("French.php");

08-28-2000, 03:32 PM
Any ideas?

Anyone?

Otherwise I'll have to start copying the "Forumjump" template code into the other templates :(

08-31-2000, 10:52 AM
One last question, and then I'll be of your back :)

Does anyone have an Idea how to accomplish this without using cookies? I want to be able to switch the language even if the user has the usage of cookies turned of in his browser.

How can I keep the $language variable set during the entire visit of the user?

Thanks!

09-08-2000, 06:54 AM
Any chance of this being released....please. :)

Thanks.

09-08-2000, 08:31 AM
Well...

The standard language hack is probably already explained in the messages above, so unless you have a question about it, I won't elaborate on that...

The forumjump template is different because it's evaluation code can be found in a function. PHP functions don't know the content of variables declared outside the function (in this case the variables that are loaded from the language files...)

Solution... You must include the variables that you use in the forumjump template as global in the beginning of that function.

In my particular case this means adding following rule to the declaration of variables in the makeforum() function of global.php
global $bobexforumjump,$bobexgobutton,$bobexselectone;

When it comes to remembering the language without cookies, this is a little harder. I first implemented this by adding a language field to the user-table so that when cookies were disabled, It could read the default language for that user. However, without cookies, vBulletin doesn't keep you logged-in all the time, and you loose your language variable again.

This leaves only passing the language variable everywhere through the URL. However, I haven't implemented that yet, and probably won't :) since it means changing links in virtually every template.

If you have any more questions, just ask!

Greetings

stcham

09-08-2000, 08:54 AM
Did I miss something? I don't see the hack.

I see talk about it. Are there any language files I need plus instructions on how to use this?

09-08-2000, 09:33 AM
I don't see the problem actually?

On top of your page you set a couple of links that will set a cookievariable language based on the link that is pressed. (for instance... you set the language cookie to 'Fra' if the link 'French' is clicked)

In global.php you set something like:

if (!(isset($language)))
$language = "Eng";

if ($language == "Eng") include ("English.php");
if ($language == "Ned") include ("Dutch.php");
if ($language == "Fra") include ("French.php");

Then you make the language files you want... For instance (a very short version of) english.php might look like:

<?php
$bobexthread = "Thread";
$bobexbulletinpower = "powered by vBulletin";
$bobexalltimes = "All times are ";
$bobexselectlanguage = "Select a language";
$bobexcontactusmesssage = "Contact Us";
$bobexgobutton = "Go";
$bobexfdpostnewthread = "Post New Thread";
$bobexforumrules = "Forum Rules";
$bobexadminoptions = "Admin Options";
$bobexregistered = "Registered";
$bobexpoststitle = "Posts";
?>

In short: include a variable for every piece of textual information that is present in the templates. The reason bobex is in front of all the variables is that you definitely want to make sure you have unique variable names that aren't used somewhere else in the code (and bobex is the name of the company I'm adjusting vbulletin for)

You make a language file for every language defining the same variables but assigning different values to it (obviously)

Then in your templates, you change the string "Forum Rules" by "$bobexforumrules" and you're done.

Well.. Mostly that is, because, as I already mentioned, some templates give troubles (forumjump for instance)

All clear now?

stcham

09-08-2000, 10:08 AM
ok....I was hoping someone had already done the language files. I do not know any other language besides English. Maybe a little Spanish.

Can I have your language files?

09-08-2000, 10:32 AM
Well...

My language files aren't done yet. It's a hell of a lot of work :(

Also, my language files are not exact translations of the original site, since some things were changed (for instance: the faq contains different answers for our site than for the standard vbulletin)

If you are still interested, I don't see why not (when they're ready)

Remember that you'll have to adjust all your templates to work with my variables...

Let me know.

stcham

09-10-2000, 10:30 AM
When I try to change the language to Italian on Big Soccer, I keep getting the following error:

Warning: Cannot add header information - headers already sent by (output started at italian.php:88) in global.php on line 753

The hack looks cool - I like to bug John, so lets request that he add this to a future version. He would only have to do the translation once and it would be good to go. Maybe this would even fit in with the "Skins" idea that had been floating around...

09-13-2000, 04:15 AM
Originally posted by VirtueTech
Can I have your language files?

Ok. My language files (english/dutch) are finished. So is french (but that one needs serious correcting so it's not really ready :))

If you still want them, I'll post them, however the templates need a LOT of work. On top of that, most PHP files need to be edited. The hack seems extremely easy, and indeed, it's not that hard, but you need to add globals on many different places in order for your variables to be recognised.

Also, some templates are just inserted without being evaluated through PHP. For instance, most error_templates contain only text. Since they don't contain variables, it's not necessary to evaluate them. However, if you use multilangsupport, you introduce variables, and therefore you DO need to evaluate them...

To be more exact, you need to replace

echo standarderror($bbtitle,gettemplate("whatever",0));

in

eval("echo standarderror(\$bbtitle,\"".gettemplate("whatever")."\",\"\");");

in a lot of different places. I hope I'm making myself a little clear?

If that's not a problem for you, the languagefiles are yours.

Greetings,
stcham

09-13-2000, 08:56 AM
If you still want them, I'll post them, however the templates need a LOT of work.

Can I have a copy ?

09-13-2000, 08:58 AM
Me too please :)

09-13-2000, 03:16 PM
hmmm...what browser? i'll take a look...


Originally posted by UserName
When I try to change the language to Italian on Big Soccer, I keep getting the following error:

Warning: Cannot add header information - headers already sent by (output started at italian.php:88) in global.php on line 753

The hack looks cool - I like to bug John, so lets request that he add this to a future version. He would only have to do the translation once and it would be good to go. Maybe this would even fit in with the "Skins" idea that had been floating around...

09-13-2000, 03:21 PM
I would assume Netscape as that warning often doesn't appear in explorer (but is still there).

It results from you somehow causing php to output text before you have php setting a cookie. The cookie needs to send teh header but you have already done it by sending text. a common cause is having a space before the <?php at the top of the file.

09-14-2000, 07:41 PM
Can I have a copy ?


Ok. Can you tell me how to get it up here?

It's a little large just to copy paste it. (For example: the dutch.php file is 60kb. 500 lines if no linewrap is used)

Also, you don't want a hard linewrap, since variablefiles are rather sensitive to that!

Greetings,
stcham

PS: I don't have serverspace available to link it to :(

09-14-2000, 11:33 PM
Originally posted by stcham

Can I have a copy ?


Ok. Can you tell me how to get it up here?


WOuld you mind sending it to me?
Here's my email: acidburn@mail2000.com.tw

TIA,
Danny

09-15-2000, 04:03 AM
Originally posted by acidburn
Originally posted by stcham
[B][QUOTE]
Can I have a copy ?


Ok. Can you tell me how to get it up here?


Thanks stcham. You really did a big job. :-)
Hope the language definition feature would be added to the next version of vB.

09-21-2000, 09:46 AM
stcham

Could you please email me it as well:
info@virtuetech.com

10-13-2000, 02:44 PM
Any chance you could email the Dutch translations to me too?
zief@pandora.be

Thank you very much

10-13-2000, 03:24 PM
Originally posted by stcham
One last question, and then I'll be of your back :)

Does anyone have an Idea how to accomplish this without using cookies? I want to be able to switch the language even if the user has the usage of cookies turned of in his browser.

How can I keep the $language variable set during the entire visit of the user?

Thanks!



Simple... Read the Language set in the User's Browser. It is located in the HTTP Header, HTTP_ACCEPT_LANGUAGE

Match these to your language files and you won't need cookies.

02-13-2001, 08:44 AM
Originally posted by wluke


Simple... Read the Language set in the User's Browser. It is located in the HTTP Header, HTTP_ACCEPT_LANGUAGE

Match these to your language files and you won't need cookies. ?r, put an extra field with the user's table. that way the visitors will only see the standard language, and when they are registered they can choose their preferred language.

02-13-2001, 09:01 AM
I've been running this hack on my board for a month.

Here's a discussion thread:
http://www.vbulletin.com/forum/showthread.php?s=&threadid=7256

If interested I can release it as soon as vB 2.0 will become final.

KiaX
02-27-2002, 03:49 PM
Hey... i want to install the Vb in spanish... how can i do these?

Thanks