Snippet: Language Switcher

CodeALot

Quote from: jacobi22 on July 18, 2014, 12:29:25 PM

english is your main language, you have a page tree like your post (1, 1A, 2, 2A, 3, 3A, 4, 4A) in all languages. sub languages are german, french etc
open your german page 3A, go there to the pages setting and select your english target page (main language page 3A). do the same for the other sub languages and for every page in your page tree

Thanks, I'm on it. :) 216 pages to do.... Bweeh! LOL But at least it's possible. Now let's hope WB will behave... It is known to have some problems handling large amounts of pages....

Thanks again!

Gast

QuoteDoes that mean I can 'only' use two languages?
there are no limits, i use it with 8 different languages in one project, no problems

for example

english is your main language, you have a page tree like your post (1, 1A, 2, 2A, 3, 3A, 4, 4A) in all languages. sub languages are german, french etc
open your german page 3A, go there to the pages setting and select your english target page (main language page 3A). do the same for the other sub languages and for every page in your page tree

use this code in your template index.php for the flag menu
Quote<div id="lang_menu"><?php if(function_exists('language_menu')){ language_menu('png'); } ?>
</div>

this code build a menu like this
<div id="langmenu">
        <a href ="page_link" title="lang_name" >
        <span><img class="default" src="page_lang.gif" alt="lang_name" title="lang_name" />
        </span></a>
        <a href ="page_link" title="" >
        <span><img class="default" src="page_lang.gif" alt="lang_name" title="lang_name" />
        </span></a>
        <a href ="page_link" title="" >
        <span><img class="current" src="current_lang.gif" alt="lang_name" title="lang_name" />
</span></a>
</div>


it builds a menu with flags for every language. a language tree must have (minimum) 1 page to show the flag in your flag menu. if you not select a target page, the flag link goes to the start page from this language


CodeALot

Quote from: jacobi22 on July 17, 2014, 06:03:21 PM
i use the multi_linguale module from here
http://www.websitebaker.org/forum/index.php/topic,27345.msg188623.html#msg188623

works without problems
Step 1:  build your page tree in the main language
Step 2: build a page tree or a part of the page tree from the sub languages
Step 3: select your "target" page (from the main language)  in the select field "page code"

works without problems for me with a flaggs menu

Thanks for the pointer, but I can't find anywhere how to use it...  :-D

I installed it, in the page settings screen I now see a new option to set a Page code, should that point to the same page but in the other language?
Does that mean I can 'only' use two languages?

Your help is much appreciated!

cwsoft

#27
Hi,

Quote from: CodeALot on July 17, 2014, 05:33:43 PM
But as with so many things about WB, the author has left the building, and nobody seems to give a @#$#@ anymore.
Well the author is still around, but indeed doesn't give a @#$#@ anymore, as a WB core replacement and a similar module exists, which makes this snippet obsolete. No big user base, no further development :wink:

Cheers cwsoft

Gast

i use the multi_linguale module from here
http://www.websitebaker.org/forum/index.php/topic,27345.msg188623.html#msg188623

works without problems
Step 1:  build your page tree in the main language
Step 2: build a page tree or a part of the page tree from the sub languages
Step 3: select your "target" page (from the main language)  in the select field "page code"

works without problems for me with a flaggs menu

CodeALot

Quote from: dfens on January 11, 2013, 02:13:20 PM
here is a bugfix which really fckd me up , randomly loosing pages in the tree after moving them around: :evil:

Seems I replied too soon... It still isn't working right. Let's say I have 4 main pages, each with a subpage.
(1, 1A, 2, 2A, 3, 3A, 4, 4A)

I'm on 1A. I click the language switch, and I'm sent off to 3A in the other language. As if the Switch Language is ignoring Page-position.

All structures are exactly the same, all the same pages, same order etc. And still... it's not working.

But as with so many things about WB, the author has left the building, and nobody seems to give a @#$#@ anymore. Guess I'll change my language switch to a dumb "go the homepage of that other language" option. :-((

I'll leave the light on, in case someone walks by who has a clue how to fix my little problem. There's beer in the fridge. Make yourself at home.

CodeALot

Quote from: dfens on January 11, 2013, 02:13:20 PM
here is a bugfix which really fckd me up , randomly loosing pages in the tree after moving them around: :evil:

You rock. Thanks!

CodeALot

Quote from: mylesk42 on January 27, 2011, 11:48:32 PM
Hello Stefek and thanks for your response.

Yes, I'd like a combo box (with the flags why not), but don't know what php code to assign and where.

Regards


I too would like to use this snippet with a drop-down-menu. No need for flags, no need to show the current language (I mean... that would be obvious looking at the page itself, right? :) ) - Anyone?

dfens

#22
here is a bugfix which really fckd me up , randomly loosing pages in the tree after moving them around: :evil:

in include.php line 140

replace
$temp[$row['root_parent']]['sub'][] = str_replace($row['root_parent'] . ',', '', $row['page_trail']);

with

$temp[$row['root_parent']]['sub'][] = preg_replace('/^' . $row['root_parent'] . ',/', '', $row['page_trail']);

so a page trail like 6,126,140 won't be 12140 but 126,140

have fun

D72

ah, that is just great. Thanks in a million Marmot!

marmot

Hi,

sorry that first try didn't work.
Maybe you want to give this one an other chance and make lines 76 - 84 look like this:
// build image link if exists
$img = '';
$curr_lang = '';
if (stristr($page_tree[$root_parent][0]['link'],PAGES_DIRECTORY.'/'.$lang_id.'/') !== false) $curr_lang = ' curr_lang';
if (file_exists(dirname(__FILE__) . '/images/' . $lang_id . '.gif')) {
$img = '<img id="flag_icon_' . strtolower($lang_id) . '"' .
' class="flag_icon'.$curr_lang.'" src="' . WB_URL . '/modules/switch_language/images/'
. $lang_id . '.gif" alt="' . $lang_id . '" />';
}
this adds class "curr_lang" to the <img> tag instead of the <a> tag. Thought this makes more sense. This time I made a fast test and it worked for me.

regards

D72

Sorry Marmot, the snippet doesn't work. Thanks though for your contribution!

D72

Holy crap
Thats fast. I thought no one would read or respond hah
Ill test it tomorrow at the office. Looks promissing.
Thanks marmot so far.

Quote from: marmot on July 05, 2012, 09:18:19 PM
Hi,

Quote from: D72 on July 05, 2012, 09:31:03 AM
Hope someone has a clue.
This ist not tested:
Insert code at line 83 of include.php so it looks like if ($root_parent == $lang_id) $url.= '" class="curr_lang';
// create image or text links for the language switcher
This should add the class "curr_lang" to the link of the active language.

regards

marmot

Hi,

Quote from: D72 on July 05, 2012, 09:31:03 AM
Hope someone has a clue.
This ist not tested:
Insert code at line 83 of include.php so it looks like if ($root_parent == $lang_id) $url.= '" class="curr_lang';
// create image or text links for the language switcher
This should add the class "curr_lang" to the link of the active language.

regards

D72

I know, it's been a long time people actually used this topic.
But as the module is still working nicely, i do have a "simple" question about this module.
Language snippet
How can i add a unique class/id to create a current menu item?
The code in my index is like:
<?php
    
if (function_exists('switchLanguage')) {
       
switchLanguage(array('EN' => 1'NL' => 2'CN' => 46), 
        
'<a href="[url]" target="_self" title="[lang_id]">[img] <!--[lang_id]--></a>');
 }
?>

I really would like to make use of it so people can see straight away which language is active.
Sure, they can see it in the content... but giving the current flag a class would be nice though.
Hope someone has a clue.

mylesk42

If you know where to change the code to show a combo box (without flags), you're welcome !

Regards

Stefek

Quote from: mylesk42 on January 27, 2011, 11:48:32 PM
(with the flags why not)
Hello,
the problem with flags is, that some browsers doesn't support hem.

Regards,
Stefek
[i]"Gemeinsam schafft man mehr."[/i]

[b][url=http://duden.de/rechtschreibung/gemeinsam#Bedeutung1]gemeinsam[/url][/b]
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

mylesk42

Hello Stefek and thanks for your response.

Yes, I'd like a combo box (with the flags why not), but don't know what php code to assign and where.

Regards

Stefek

Quote from: mylesk42 on January 23, 2011, 12:47:02 PM
Hello,

I'm using language switcher and the by default showing, I mean the flags.

How could I use this module to show the langusges in a drop down menu ?

Regards


Hello, you want to have the switcher with a combobox of HTML Element "select->option"?, like here?:
http://www.w3schools.com/tags/tag_select.asp
Without images?

Regards,
Stefek
[i]"Gemeinsam schafft man mehr."[/i]

[b][url=http://duden.de/rechtschreibung/gemeinsam#Bedeutung1]gemeinsam[/url][/b]
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

kweitzel

The fact that it is in use does not mean, that anybody is interested in developing it anymore (unfortunately). And DOC decided not to participate.

cheers

Klaus

mylesk42

It's weirf because it's used. And 'Doc' isn't part of ths forum anymore ?
Regards

kweitzel

It seems to me nobody is actively interested in this Module.

cheers

Klaus

mylesk42

Hello,

I'm using language switcher and the by default showing, I mean the flags.

How could I use this module to show the langusges in a drop down menu ?

Regards

mylesk42

I've updated the php code in the index.php (commented and then uncommented the php coe) and now it works like before.
Weird, but

mylesk42

  Php Error with switch_language modul
« on: June 25, 2010, 05:03:19 PM »     

--------------------------------------------------------------------------------
I've already posted this topic in the modul forum but think it's more specific here

Hello,
I've just encoutereed a problem with the switch_language modul :

Notice: Undefined index: 692 in /home/xxxx/public_html/xxxxxx/xxxxx/modules/switch_language/include.php on line 170

This line is repeated 6 times from index 687 to index 692.

I have other multi languages websites wit non problem. There was no problem until (I suppose) I've installed calendar-v2 + calendar month + calendar month link. I deleted the 3 moduls + the swtich language then re installed the switch language but I have the same errors. The EN and FR pages are creaed equal.

An idea ?

Regards