vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Switching the forum language by using flags [3.5] (https://vborg.vbsupport.ru/showthread.php?t=95866)

Bellinis 09-08-2005 03:34 PM

Switching the forum language by using flags [3.5]
 
On my board we use two official languages. Registered users can change their preferred language through the CP and guests can use the language drop-down menu on the bottom of the page.

Since the drop-down menu isn't very guest-friendly, I would like to add two (or more) language flags somewhere on my page (probably in the menu). Does such hack already excist ? (@ vbulletin.com they told me a hack probably already excists here, but I couldn't find it :disappointed: )
Can anyone point me in the right direction?

Thanks a lot!

Marco van Herwaarden 09-08-2005 08:54 PM

Can't remember seeing one.

Bellinis 10-01-2005 10:05 PM

It's been some time ago since I did my posting above....

I think it can't be too difficult to replace the drop-down-language-selection-box with a few country flags somewhere on the forum, only I can not do it :(

Anyone willing to help me out on this one ?

Thanks! :rolleyes:

derfelix 03-21-2006 05:02 AM

well I was looking for the same solution...
What i did
i placed a flag on the page and

linked it with the following code:
PHP Code:

<a href="javascript:switch_lang(1);"><img src="images/flag_english.gif" border=/></a


in switch_lang(1) the 1 is your language id corresponding to the language..
you have to change it for the language corresponding to the flag !!!!!


then open forum/clientscript/vbulletin_global.js
in there find:
PHP Code:

function switch_id(selectobjtype

and ABOVE add:
PHP Code:

function switch_lang(language)
{
    var 
id language;

    if (
id == '')
    {
        return;
    }

    var 
url = new String(window.location);
    var 
fragment = new String('');

    
// get rid of fragment
    
url url.split('#');

    
// deal with the fragment first
    
if (url[1])
    {
        
fragment '#' url[1];
    }

    
// deal with the main url
    
url url[0];

    
// remove id=x& from main bit
    
if (url.indexOf('langid=') != -&& is_regexp)
    {
        
re = new RegExp("langid=\\d+&?");
        
url url.replace(re'');
    }

    
// add the ? to the url if needed
    
if (url.indexOf('?') == -1)
    {
        
url += '?';
    }
    else
    {
        
// make sure that we have a valid character to join our id bit
        
lastchar url.substr(url.length 1);
        if (
lastchar != '&' && lastchar != '?')
        {
            
url += '&';
        }
    }

    
window.location url 'langid=' id fragment;


I hope that helps

Felix

Ramsesx 03-21-2006 07:09 AM

@ Felix, I only made a link to http://www.mysite.de/index.php?langid=3
What is the advantage to make it with javascript?

derfelix 03-21-2006 04:24 PM

the advantage is.. that you stay on the page were you were..

example:
you are on https://vborg.vbsupport.ru/showthread.php?p=930702

and you have the flags in the header on every page...

you will after clickin the flag be on:
https://vborg.vbsupport.ru/showthrea...30702&langid=4

with the hard linked method you will be back on the index.php
thats the difference... but in principle both methods work

Felix

Bellinis 03-21-2006 05:01 PM

Thank you so much derfelix!
I didn't expect a reply anymore, 6 months after I asked my question... hehe :D

Those subscriptions do work fine ;)

Ghostt 03-31-2011 08:14 PM

can this code also be added as plugin?
seems not to work...


All times are GMT. The time now is 03:55 PM.

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.01344 seconds
  • Memory Usage 1,742KB
  • 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
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete