WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • Snippet: Language Switcher
  • Print
Pages: [1] 2   Go Down

Author Topic: Snippet: Language Switcher  (Read 46236 times)

doc

  • Guest
Snippet: Language Switcher
« on: June 01, 2009, 12:25:46 AM »
If you search for similar ones, please have a look at Language Matrix or the language switcher module from the authors Iceat and Luisehahne.

Regards Christian

Removed outdated version.
« Last Edit: July 21, 2009, 10:05:53 PM by doc »
Logged

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: Snippet: Language Switcher
« Reply #1 on: June 01, 2009, 01:38:50 PM »
Hello Christian.

The new features works great!

There is only a problem if you have some alterations in the page trees of the different (tested with 2) languages.

Example:

DE
- Start
- mein Test
-- erster Test
-- zweiter Test

- meine Ergebnise
-- bestes Ergebnnis
-- mittleres Ergebnis

- Preise und Ehrungen
       
EN
- Welcome
- my Test
-- firstTest

- my Results
-- best Result

- Awards


Up to firstTest/ersterTest everythig is going fine.

It means the snippet works only good if you have the same structure in all your languages.

 :|

The same Problem appears if you have the same structure and then you switch one of your pages to "hidden".

Regards,
Stefek
Logged
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: Snippet: Language Switcher
« Reply #2 on: June 01, 2009, 03:13:17 PM »
Hello Doc.

I like (and will use) your snippet anyway.

It's very handy so far.

Thank you for your efforts!

Regards,
Stefek
Logged
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

doc

  • Guest
Snippet: Language Switcher (v0.30)
« Reply #3 on: July 20, 2009, 09:15:55 PM »
Hi,

Martin (mr-fan) has send me a German and English README file for the code snippet: "Language Switcher". Therefore I decided to release the latest version in this thread.

Basics:
This snippets allows you to switch the current displayed page to another language. The snippets requires the same amount and order of pages in the page tree for each supported language (e.g. EN, DE).

For each language, one has to set-up an identical page tree (amount + order of pages). If a page does not exists in English, but in German, one needs to create a "dummy-page" for that missing English page. A "dummy-page" is a page without content and the visibility set to "NONE".

Example (from the README file):
Code: [Select]
(Container - German)    (Container - English)
DE.php                    EN.php (page name as you like, recommended: EN, DE, NL ...)
  - Startseite             - Home
  - Seite 1                - site 1
  - Seite 2                - no "site 2" exists (create dummy-page; visibility:= "NONE")

Using the Snippets:
Install the snippet via the backend. Then invoke the new function switchLanguage from the index.php file of your template (or a page/section of type code).
Code: [Select]
<?php
if (function_exists(&#39;switchLanguage&#39;)) {
   
switchLanguage(array(&#39;EN&#39; => 12, &#39;DE&#39; => 14));
}
?>
The example assumes that the English container page has the page_id 12, the German one 14.

Further information can be found in the Germand and English READM files located in the moduel folder: /modules/switch_language/help/.

Pros and Cons of the module:
 + does not need any further information to switch pages (e.g. tags, page_id)
 + function needs to be invoked once, thats it (invoke with ALL container pages like DE, EN, ...)
 + flag icons are created automatically
 - page tree (amount and order of pages) must be identical for ALL languages
 - if no page exists for a certain language, you have to create a dummy-page (no content, visibility: NONE)

Martin, thank you very much for the READMDE files.

Link to German forum thread: click here

Regards Doc

P.S.: There exists another interesting solution worked out by the forum member FrankH: Easy Multilanguage Link which requires some smaller core file modifications.

Note: Download removed as a newer version is available in this thread.
« Last Edit: August 29, 2009, 08:15:57 AM by doc »
Logged

doc

  • Guest
Snippet: Language Switcher v0.40
« Reply #4 on: August 29, 2009, 08:12:21 AM »
Hi,

as requested by the forum member mr-fan, I added IDs to the language flag icons created by the code snippet for better access and styling with CSS. The default flag output is as follows:

Code: [Select]
<a href="page.php" target="_self" title="DE">
<img id="flag_icon_de" class="flag_icon" src=".../images/DE.gif" alt="DE" />DE
</a>

Regards Doc

[gelöscht durch Administrator]
Logged

Offline mylesk42

  • Posts: 131
  • Gender: Male
    • Creation site internet
Re: Snippet: Language Switcher
« Reply #5 on: June 26, 2010, 11:34:35 AM »
  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
Logged

Offline mylesk42

  • Posts: 131
  • Gender: Male
    • Creation site internet
Re: Snippet: Language Switcher
« Reply #6 on: June 26, 2010, 05:42:27 PM »
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
Logged

Offline mylesk42

  • Posts: 131
  • Gender: Male
    • Creation site internet
Re: Snippet: Language Switcher
« Reply #7 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
Logged

Offline kweitzel

  • WebsiteBaker Org e.V.
  • **
  • Posts: 6983
  • Gender: Male
Re: Snippet: Language Switcher
« Reply #8 on: January 26, 2011, 10:11:57 AM »
It seems to me nobody is actively interested in this Module.

cheers

Klaus
Logged

Offline mylesk42

  • Posts: 131
  • Gender: Male
    • Creation site internet
Re: Snippet: Language Switcher
« Reply #9 on: January 27, 2011, 06:19:22 PM »
It's weirf because it's used. And 'Doc' isn't part of ths forum anymore ?
Regards
Logged

Offline kweitzel

  • WebsiteBaker Org e.V.
  • **
  • Posts: 6983
  • Gender: Male
Re: Snippet: Language Switcher
« Reply #10 on: January 27, 2011, 07:44:44 PM »
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
Logged

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: Snippet: Language Switcher
« Reply #11 on: January 27, 2011, 08:37:34 PM »
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
Logged
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

Offline mylesk42

  • Posts: 131
  • Gender: Male
    • Creation site internet
Re: Snippet: Language Switcher
« Reply #12 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
Logged

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: Snippet: Language Switcher
« Reply #13 on: January 28, 2011, 12:04:27 AM »
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
Logged
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

Offline mylesk42

  • Posts: 131
  • Gender: Male
    • Creation site internet
Re: Snippet: Language Switcher
« Reply #14 on: January 28, 2011, 09:38:35 AM »
If you know where to change the code to show a combo box (without flags), you're welcome !

Regards
Logged

Offline D72

  • Posts: 295
  • Gender: Male
Re: Snippet: Language Switcher
« Reply #15 on: July 05, 2012, 09:31:03 AM »
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:
Code: [Select]
<?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.
Logged

Offline marmot

  • Posts: 1103
Re: Snippet: Language Switcher
« Reply #16 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
Code: [Select]
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
Logged

Offline D72

  • Posts: 295
  • Gender: Male
Re: Snippet: Language Switcher
« Reply #17 on: July 05, 2012, 09:22:29 PM »
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
Code: [Select]
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
Logged

Offline D72

  • Posts: 295
  • Gender: Male
Re: Snippet: Language Switcher
« Reply #18 on: July 06, 2012, 09:12:49 AM »
Sorry Marmot, the snippet doesn't work. Thanks though for your contribution!
Logged

Offline marmot

  • Posts: 1103
Re: Snippet: Language Switcher
« Reply #19 on: July 06, 2012, 10:00:48 PM »
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:
Code: [Select]
// 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
Logged

Offline D72

  • Posts: 295
  • Gender: Male
Re: Snippet: Language Switcher
« Reply #20 on: July 09, 2012, 09:48:37 AM »
ah, that is just great. Thanks in a million Marmot!
Logged

Offline dfens

  • Posts: 1
bugfix
« Reply #21 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:

in include.php line 140

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

Code: [Select]
$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
« Last Edit: January 11, 2013, 02:15:46 PM by dfens »
Logged

Offline CodeALot

  • Posts: 579
  • Gender: Male
Re: Snippet: Language Switcher
« Reply #22 on: July 15, 2014, 11:51:28 AM »
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?
Logged

Offline CodeALot

  • Posts: 579
  • Gender: Male
Re: bugfix
« Reply #23 on: July 15, 2014, 01:37:27 PM »
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!
Logged

Offline CodeALot

  • Posts: 579
  • Gender: Male
Re: bugfix
« Reply #24 on: July 17, 2014, 05:33:43 PM »
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.
Logged

  • Print
Pages: [1] 2   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • Snippet: Language Switcher
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2