View Full Version : Set forum-language automatic to browser-language for first-visitors
JoergZ
09-30-2005, 10:00 PM
Originally I have not planned to bring my Hack "Language Selection for Guests (https://vborg.vbsupport.ru/showthread.php?t=59564)" to vB 3.5, because in 3.5 the language can be selected with the drop-down menu at the bottom.
But I was asked to make the automatic language-detection in 3.5 available. In case others are maybe interested in that too, I bring it here as new hack for vB 3.5
Short-description
This Hack detects the browser-language automatic and shows the board in the language of the user, if the user has never been at your board before or has no cookie for your board.
The automatic-detection of the browser-language was realised by WildChild
Requirements
vB 3.5 Gold (Tested up to 3.5.1)
Of course more than one installed and selectable language, otherwise this modification makes no sens ;)
Installation-time
about 1 minutes
PLEASE CLICK THE INSTALL BUTTON IF INSTALLED! :)
Updates
01.10.2005 Thanks to the help of KirbyDE, now a standard-hook is used, so no code-modification is necessary
------------------------------------------------------------------------
If you want to test the hack after installing, do it like this:
- Log out of your forum. Dont klick any of the displayed links after logging out !
- Close your browser-window
- Open a new browser-window
- Set your language preferences in the browser
- Go to your forum homepage
Andreas
10-01-2005, 04:11 AM
Optimization suggest: get rid of the File edit :)
Hook init_startup, and use $_REQUEST['langid'] instead of $vbulletin->GPC['langid'] in the Code
JoergZ
10-01-2005, 09:04 AM
Thanks for the hint KirbyDE, but what is with $vbulletin->GPC[COOKIE_PREFIX . 'languageid'] ? How to replace that ?
Just replacing the GPC['langid'] is not working.
Jörg
Andreas
10-01-2005, 10:01 AM
$_COOKIE[COOKIE_PREFIX . 'languageid']
GrendelKhan{TSU
10-01-2005, 10:05 AM
question...
does the use have the option to change the language after its "autodectected"? or is it "stuck" on the one it detects? (I HATE that.)
aside: Hate when sites do that....can't change it back to english once its detected im in Korea or Japan or whereever). Sorry just had to vent. ;) :p
sounds cool as long as user can freely change and it only affects first time (non-cookied) visitors.
JoergZ
10-01-2005, 10:32 AM
No, of course the user can change it.
This automatic detected language is only used, as long the user don't select another one or he has a cookie from an earlier vist. So it is really for users, that come the first time to your site, or has logged out, so the cookies were deleted.
When the users select another language, the selected language is taken and is not switched back to the automatic detected, because then there is an entry in the cookie.
Currently I am trying to use the standard-hooks, so no code-changes are needed at all. Maybe this evening there is an update for my hack.
Jörg
EDIT: I have updated the hack, so no more code-modification is necessary. Thanks very much to KirbyDE for his help.
Fenriz
10-02-2005, 11:27 PM
J?rg, your hack works great, as well as the old version with new hook. You can check it on the my test forum http://temp.ulver.com
Just one thing to do. When you logg-in with one language (for example norwegian) and then change this language to another (for example swedish), after logg-out you lost your norwegian and return to swedish. But could we stay with swedish anyway, even after logg-out?
JoergZ
10-02-2005, 11:44 PM
When you logg-in with one language (for example norwegian) and then change this language to another (for example swedish), after logg-out you lost your norwegian and return to swedish. But could we stay with swedish anyway, even after logg-out?
Hm.. your description is a little bit mixed up.. isn't it ? :D
Probably you mean:
- Arriving at the forum, it is Norwegian, log in
- Changing as logged-in-user to Swedish
- Logging out
--> You have again norwegian, but you want to keep Swedish
Unfortunally this is not possible, because the language-information is stored in the cookie. When you log out, the cookie is removed. So coming back to the forum without cookie, will start the auto-detection process again.
The only way to keep the language, is not to log out, so the cookie remains. Then you will have the same language, as you left the forum.
But usually this should not be an issue, because users probably have their preferred language in the IE-Settings. If the language, they have defined in the IE, is not installed in your board, then the default-language of the board is shown.
Best regards and hej d? :)
J?rg
berberber
10-03-2005, 01:49 PM
Hello, wouldnt it here possible to add the possibility to set language depending of forumid ?
(by the way, thanks a lot... that will make more members)
JoergZ
10-03-2005, 02:32 PM
Hi berberber,
I don't know if this would make sense... At least the user has one language, he preferes, and that is the language, that is set in the IE. So why the language should change, when I change the forum ?
Moreover, I think this must be hacked at another point of the code, not where my hack is placed.
Jörg
berberber
10-03-2005, 04:19 PM
yes, but Search engines, have no language set, and some Browsers not as well, so it would make sense for me, that in first place, it would depend on users choice, but then, on forum admins choice.
For example on my forums, i Have a french area, I would like to be seen like french as default. KirbyDE already said its not possible via plugins, I tried, but did not get it.
Bernhard
GrendelKhan{TSU
10-03-2005, 08:02 PM
No, of course the user can change it.
This automatic detected language is only used, as long the user don't select another one or he has a cookie from an earlier vist. So it is really for users, that come the first time to your site, or has logged out, so the cookies were deleted.
When the users select another language, the selected language is taken and is not switched back to the automatic detected, because then there is an entry in the cookie.
Currently I am trying to use the standard-hooks, so no code-changes are needed at all. Maybe this evening there is an update for my hack.
J?rg
EDIT: I have updated the hack, so no more code-modification is necessary. Thanks very much to KirbyDE for his help.
cool!!
<< installed. thanks!! ^^
betablue
10-05-2005, 05:01 AM
Thank you, great idea. I just installed this, however it seems to have a glitch:
My Borwser language is set to EN-US & En (in Firefox) and to En-Ca in IE.
When i go to the forum without a cookie set (logged out), then the forum language auto-sets to Spanish - Mexico. The forums' Default Language is EN-US and it has following language packs installed: Chinese, Chinese-TW, German (Du & Sie), English-US (Default), Spanish - MX and Polish - PL
Any ideas?
berberber
10-05-2005, 05:43 AM
Hello, are you sure you set it correctly up, just edit the plugin, in the plugin manager, to make sure you set the right languageids.
JoergZ
10-06-2005, 08:44 PM
@betablue: Did you checked the code in the plugin, that all language-assignments are correct as berberber wrote ?
For detecting EN-US, you need e.g. an entry like this:
case 'en-us':
$_REQUEST['langid'] = X;
break;
X must be replacced by the language-id in your forum.
The same you must do for all other languages that you want to have detected and assigned to an installed language.
I will test it with en-us setting in Explorer at the weekend, when I am back at home.
J?rg
GrendelKhan{TSU
10-13-2005, 03:22 PM
AHHHHH....
I upgrade vb, then tried reinstall this.....
now I get huge error and my board is down:(
Fatal error: Cannot redeclare rk_getenvvar() (previously declared in /home/MYSITE/public_html/forums/includes/init.php(273) : eval()'d code:54) in /home/MYSITE/public_html/forums/includes/init.php(273) : eval()'d code on line 185
any ideas? HALPP!!!
JoergZ
10-13-2005, 03:34 PM
I upgrade vb, then tried reinstall this.....
From which vB-version to which vB-version did you upgraded your board ?
Why have you re-installed the hack after you upgraded your board ? When you had the first version of the hack installed, did you removed it before ?
...and my board is down
Did you not tested it on a test-installaton ?
any ideas?
At the moment not, sorry, because I just re-installed the hack in a test-board, and it works.
Did you changed by mistake something in the plugin-code except in the area where you define your language-id's ?
J?rg
GrendelKhan{TSU
10-13-2005, 03:34 PM
oh no!! can't even log into my admin cp!!!
how do i fix this??!?!!?!? +_+
JoergZ
10-13-2005, 03:39 PM
Oh man.. what have you done ?
Deactivate the plugin via phpMyAdmin.
Select the table "plugin" and select the record with the title "Set automatic forumlanguage to browserlanguage" for edit.
Then set the value for the field "active" to 0 (see screenshot)
Then the plugin is deactivated.
Jörg
GrendelKhan{TSU
10-13-2005, 03:40 PM
I'm on 3.5.0 Gold .
well... I thought I had installed it before....but didn't seem to be working.... and so I wasn't sure as its late and I'm pretty tired and stupid. :(
so after looking through the plug-in manager, I didn't see it, so thought it was safe to just install again. didn't back up first. +_+
I ddin't change ANYTHING just downloaded the file and installed via PLUGIN upload/download.
man..I was so about to go to sleep...but now my board is COMPLETELY down so I'm freakin out. o_0
any other help would be very very appricated.
JoergZ
10-13-2005, 03:50 PM
O.k., I have just tried the following at my test-board:
I have installed the hack a second time, and I got exactly the same error as you wrote. So you definetely installed the hack twice !!
How to get rid of this:
Deactivate both plugin-installations as I wrote in my posting before.
Moreover you must go to the table "datastore" and look there for the record named "pluginlist". Delete this record.
Then you can login to your board again.
Login into admin-cp, go to the plugin-manager, and click on "Save Active Status", to rebuild the entry in the datastore.
That's it.
And next time don't do any changes, when you already fell to sleep ;)
BR
J?rg
GrendelKhan{TSU
10-13-2005, 04:06 PM
Moreover you must go to the table "datastore" and look there for the record named "pluginlist". Delete this record.
I don't know how to do this. :( I'm a n00b.
JoergZ
10-13-2005, 04:15 PM
Send me via PN your ICQ-number, and I will try to help you
GrendelKhan{TSU
10-14-2005, 10:34 AM
Send me via PN your ICQ-number, and I will try to help you
just pm-ed you. I'm still down :( +_+
Yorixz
10-14-2005, 11:57 AM
Very interesting plugin since I'm also running a multi-langual forum, thanks for sharing!
I'm just wondering; are there any places you can share languagefiles with other users; I'm quite sure there are many users who got localized/multilangual forums, sadly I'm not able to do all language files myself and it's a huge load of work, even for just a single set.
JoergZ
10-14-2005, 12:01 PM
Yes, there is a forum at vb.com: http://www.vbulletin.com/forum/forumdisplay.php?f=87
There you find language-files for several languages. But watch out.. Packs for 3.0 and 3.5 are both offered in this forum, so you must take the correct version.
J?rg
Yorixz
10-14-2005, 12:07 PM
Yes, there is a forum at vb.com: http://www.vbulletin.com/forum/forumdisplay.php?f=87
There you find language-files for several languages. But watch out.. Packs for 3.0 and 3.5 are both offered in this forum, so you must take the correct version.
J?rg
Ok, thanks a lot - never noticed it, I'm nearly always at vB.org ;)
GrendelKhan{TSU
10-14-2005, 12:54 PM
Send me via PN your ICQ-number, and I will try to help you
YAY!! FIXED!!
A BBBIIGGG thank you to joergZ for all your support help. I know it was a pain and you didn't have to go above and beyond with the extra lesson.
thank you again!!! :D
<< now I'm gunna take your advice and get some sleep now before I break something again. :P
Totti
01-16-2006, 03:23 PM
gro?artig j?rg, vielen dank :)
it'd be cool to let the code copy the first 2 or 3 chars of the browserlanguage,
so that you can set all en-xx langs easy to english,
instead of making 12 cases :)
JoergZ
01-22-2006, 06:55 PM
it'd be cool to let the code copy the first 2 or 3 chars of the browserlanguage,
so that you can set all en-xx langs easy to english,
instead of making 12 cases :)
At the moment I have very little time due to much work, but I will keep it in mind. :)
Best Regards
J?rg
Eagle Creek
02-08-2006, 08:29 PM
At the moment I have very little time due to much work, but I will keep it in mind. :)
Best Regards
J?rg
Does it work at 3.5.3?
Nj?rd Eriksson
03-02-2006, 08:12 AM
Does it work at 3.5.3?
I installed it on 3.5.4 and it works.
JoergZ
03-02-2006, 08:26 AM
Thanks for this confirmation.
I had no time yet to test it on the new 3.5.4 version.
Best regards
Jörg
ConKien
05-19-2006, 07:16 PM
Can we use the plugin to make some sort of button to let users switch back n forth between 2,3 or 4 languages? Like
[English][Chinese][Japanese]
Thanks!
JoergZ
05-19-2006, 07:27 PM
This Hack detects only automatic the browser-language. For changing the language, there is for 3.5.x no separate hack necessary, because the function is available through the drop-down menu in the footer.
Changing the language with a button, was only possible with the old version of this hack for vB 3.0.x. (In vB 3.0.x it was not possible in the standard to let guests changing the language)
Due to my limited time at the moment, there is no way, that I can extend the hack with this option.
Best regards
Jörg
ThomasR
09-23-2006, 07:23 PM
Does it works on 3.6.1 ? Thanks !
ThomasR
09-23-2006, 07:39 PM
seems to works on 3.6.1 ;)
JoergZ
09-24-2006, 04:14 PM
Sorry, had no time to test it yet.
But as I see you tried it ;)
I will have a look probably next weekend at it.
Best regards
J?rg
Brandon Sheley
10-11-2006, 06:33 PM
aww.. tried to add this to 3.6.x and we get a fatal error and the site is done :|
Fatal error: Cannot redeclare rk_getenvvar() (previously declared in /home/xxx/public_html/includes/init.php(317) : eval()'d code:50) in /home/xxx/public_html/includes/init.php(317) : eval()'d code on line 180
how can we fix this ?
thank you
JoergZ
10-11-2006, 06:36 PM
I will try to update the hack on the weekend, so it can be used with 3.6.x
Jörg
Brandon Sheley
10-11-2006, 06:48 PM
:( my client is going to kill me :(
do you know how I can remove this ? I tried going into myphpadmin and deleting the plugin..
can you post what all to remove from this plugin ?
thank you
Brandon Sheley
10-11-2006, 06:58 PM
okay, got it working again.. whew.. hope they didn't see that..lol
I'll wait till next week,, but we'll be cutting the time close.. this was one they Really want.. I can throw some $ in if that helps :)
JoergZ
10-11-2006, 07:42 PM
Hi Loco !
Sorry to hear that your site was down.
But also sorry to say, that
1.) You can see in the thread, that it is not prove from me, that the hack is working with 3.6.x
2.) I can't understand why people install hacks in their productive environment before testing any change in a local test-installation. If someone has a private fun-board and don't want to do that, o.k. but honestly, doing that with a page, that brings money, I have no understanding.
As I said, I will try to prepare it for 3.6.2 as soon, as RL give me a little bit time.
Best regards
Jörg
O.k. that was easier than I thought: The plugin is working as it is for 3.6.2 (So probalby it works also for 3.6.0 and 3.6.1 but have not tested the other 3.6 versions.)
That mean, you probably have done something wrong, when you modified to plugin to set it to the correct languages. Please read again the instruction in the xml-file and do only the modification as it is described there.
I will publish the hack on the weekend in the 3.6 area with a exact description in the text-file, so no one can miss it what and how to change.
Brandon Sheley
10-11-2006, 08:24 PM
Thank you for the time in updating this hack :)
and ya, I know I should have used it on a test board first..
tomawebdev
07-19-2008, 10:01 PM
ُThank you, i am using 3.7 and it work fine for me, what i want to add, is the redirection to a specific forum! if language is French it will change language to French and go to forum (forumdisplay.php?f=31)
JoergZ
07-21-2008, 01:54 PM
Feel free to make this modification for you board.. :-) Or do you want to know how to do that ?
If your post is a question how to do that, I must tell you, that I don't know it. If I have a chance to check this, I will give you an info.
Br
Joerg
can this be made to work with 3.8
Charlie98902
01-21-2009, 10:14 PM
can this be made to work with 3.8
I second this as it would be nice that VB does this for users around the world.
I tried it in 3.8 and had to edit the config.php to disable plugins so I can remove it.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.