vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.5 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=113)
-   -   Set forum-language automatic to browser-language for first-visitors (https://vborg.vbsupport.ru/showthread.php?t=97261)

JoergZ 09-30-2005 10:00 PM

Set forum-language automatic to browser-language for first-visitors
 
Originally I have not planned to bring my Hack "Language Selection for Guests" 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

Quote:

Originally Posted by Fenriz
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

Quote:

Originally Posted by JoergZ
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:


PHP Code:

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:(

Quote:

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

Quote:

Originally Posted by GrendelKhan{TSU
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 ?

Quote:

Originally Posted by GrendelKhan{TSU
...and my board is down

Did you not tested it on a test-installaton ?

Quote:

Originally Posted by GrendelKhan{TSU
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

Quote:

Originally Posted by JoergZ
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

Quote:

Originally Posted by JoergZ
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

Quote:

Originally Posted by JoergZ
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

Quote:

Originally Posted by JoergZ
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

Quote:

Originally Posted by Totti
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

Quote:

Originally Posted by JoergZ
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

Quote:

Originally Posted by Eagle Creek
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


All times are GMT. The time now is 06:32 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01402 seconds
  • Memory Usage 1,840KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (13)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete