Announcement

#1 2010-11-12 19:05:51

Wallster
Translation Team
Skaftafell, Iceland
2010-10-22
48

[resolved] Move plugin language_switch to header

Hi everyone,

This is my first post, so im going to start with saying thank you for developing a great photo gallery!

I've been experimenting for a while now with customizing my own theme for my own gallery.
An important plugin for me is Language_Switch, to be able to have my gallery in different languages.

I've been looking through the documentation and the forum to see if I can find a solution to my problem. Could'nt find anything, but if it's out there and I missed it I apologize.

I would like to put the icon for switching lanugage up in the header like on the beautiful Piwigo page. :-) But I really havent managed to put it up there, tried and tried.
If someone have any suggestions, please bring them forth!

How do you specify on which page the plugin is supposed to appear? By page I mean the main content page, header, footer and so on.

Thanks.

Last edited by Wallster (2010-11-13 13:38:44)

Offline

 

#2 2010-11-15 22:50:01

Wallster
Translation Team
Skaftafell, Iceland
2010-10-22
48

Re: [resolved] Move plugin language_switch to header

Anyone?

Please tell me if im not clear enough when im explaining.

Offline

 

#3 2010-11-15 22:59:39

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: [resolved] Move plugin language_switch to header

Hi Wallster and welcome to Piwigo forums,

(sorry for the late reply, this request is not easy to answer but I fully agree with you, the language switch button should be in the header, not in the main block)

Can you share a link to your gallery in its current state? (or just a screenshot but the gallery URL is better because we have the HTML code)

Offline

 

#4 2010-11-15 23:36:55

Wallster
Translation Team
Skaftafell, Iceland
2010-10-22
48

Re: [resolved] Move plugin language_switch to header

Hi plg and thanks for helping out!

Here is the adress to the page in its current state http://wallstudio.se/myiceland/gallery/

Im no CSS expert, I might have messed the position of language_switch up in my desperation to get it to the header.

Offline

 

#5 2010-11-16 00:26:20

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: [resolved] Move plugin language_switch to header

OK, I see you have a nicely customized Piwigo gallery! Congratulations!

If you only have english+swedish, I advise you to simply add 2 flags in your #main-menu just after #mi-logo-gallery + adding a Personal Plugin to manage the switch when URL includes lang=... (I will give you the code if you're interested)

Unfortunately moving the language switch to your #main-menu requires to use additional jQuery or modifying the LanguageSwitch plugin.

Offline

 

#6 2010-11-16 00:31:52

Wallster
Translation Team
Skaftafell, Iceland
2010-10-22
48

Re: [resolved] Move plugin language_switch to header

Thank you!

At the moment it's only 2 languages, the plan is to have 3 or 4. Does it still work to do your method?

I would be very happy if you would like to help me with the code.

Offline

 

#7 2010-11-16 00:36:59

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: [resolved] Move plugin language_switch to header

How did you add the #theHeaderMenu? with a template file or with [Administration > Configuration > Options > Main]?

Offline

 

#8 2010-11-16 00:41:05

ddtddt
Piwigo Team
Quetigny - France
2007-07-27
7207

Re: [resolved] Move plugin language_switch to header

Wallster wrote:

At the moment it's only 2 languages, the plan is to have 3 or 4. Does it still work to do your method?

Can be soon in Icelander ?


You love Piwigo so don't hesitate to participate, learn more on the "Contribute to Piwigo" page. If you don't have much time for contribution, you can also help the project with a donation.

Offline

 

#9 2010-11-16 14:07:15

Wallster
Translation Team
Skaftafell, Iceland
2010-10-22
48

Re: [resolved] Move plugin language_switch to header

plg: It's added straight in to header.tpl

ddtddt: Yes the plan is to have it in Icelandic, would you be interested in having an Icelandic translation of Piwigo as well?

Offline

 

#10 2010-11-16 15:53:13

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: [resolved] Move plugin language_switch to header

What do think of something like this:

http://piwigo.org/forum/showimage.php?pid=116986&filename=myiceland_languageswitch.png

If you just have 2 or 3 languages I think it's a good "easy" solution.

Offline

 

#11 2010-11-16 16:08:48

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: [resolved] Move plugin language_switch to header

For your information, here is what I pasted in the HTML code, just after #mi-logo-gallery. This is not a good code, it's just for prototyping.

Code:

<div style="position: absolute; left: 875px; top: 5px; width: 60px; text-align: right; line-height: 20px;" id="mi-languageSwitch">
  <ul style="margin:0;padding:0">
    <li>Svenska <img style="margin-bottom: -3px;" src="http://wallstudio.se/myiceland/gallery/language/sv_SE/sv_SE.jpg"></li>
    <li style="color:#279AB2">English <img style="margin-bottom: -3px;" src="http://wallstudio.se/myiceland/gallery/language/en_UK/en_UK.jpg"></li>
    <li>Deutsch <img style="margin-bottom: -3px;" src="http://wallstudio.se/myiceland/gallery/language/de_DE/de_DE.jpg"></li>
  </ul>
</div>

Offline

 

#12 2010-11-16 16:26:44

Wallster
Translation Team
Skaftafell, Iceland
2010-10-22
48

Re: [resolved] Move plugin language_switch to header

I like it, will start off with 3 languages!

Offline

 

#13 2010-11-16 17:48:28

ddtddt
Piwigo Team
Quetigny - France
2007-07-27
7207

Re: [resolved] Move plugin language_switch to header

Wallster wrote:

ddtddt: Yes the plan is to have it in Icelandic, would you be interested in having an Icelandic translation of Piwigo as well?

oh yes :-) :-) :-)


You love Piwigo so don't hesitate to participate, learn more on the "Contribute to Piwigo" page. If you don't have much time for contribution, you can also help the project with a donation.

Offline

 

#14 2010-11-17 00:10:24

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: [resolved] Move plugin language_switch to header

OK, let's start with a solution to add 3 languages in your header, as shown in my previous screenshot.

You told me you had directly modified header.tpl. Please make sure you don't modify themes/simple/template/header.tpl : duplicate it as themes/myiceland/template/header.tpl (so that you won't loose your specific changes when you update the Simple theme).

Now in themes/myiceland/template/header.tpl just after <div id="mi-logo-gallery">...</div> insert :

Code:

<div id="mi-languageSwitch">
  <ul>
{foreach from=$languages item=language}
    <li class="{if $language.is_current}currentLanguage{/if}"><a href="{$language.url}">{$language.name} <img src="{$ROOT_URL}language/{$language.code}/{$language.code}.jpg"></a></li>
{/foreach}
  </ul>
</div>

Create a Personal Plugin :

1) activate the LocalFiles Editor plugin

2) go to [Administration > Plugins > LocalFiles Editor > Personal Plugin] and paste the following code:

Code:

<?php
/*
Plugin Name: Personal Plugin
Version: 1.0
Description: Personal Plugin
Plugin URI: http://piwigo.org
Author:
Author URI:
*/

add_event_handler('loading_lang', 'myiceland_language_switch');
// add_event_handler('init', 'myiceland_language_switch');
function myiceland_language_switch()
{
  global $user;
  
  $same = $user['language'];
  
  if (isset($_GET['lang']))
  {
    if (!empty($_GET['lang']) and file_exists(PHPWG_ROOT_PATH.'language/'.$_GET['lang'].'/common.lang.php'))
    {
      if (is_a_guest() or is_generic())
      {
        pwg_set_session_var( 'lang_switch', $_GET['lang'] );
      }
      else
      {
        $query = '
UPDATE '.USER_INFOS_TABLE.'
  SET language = \''.$_GET['lang'].'\'
  WHERE user_id = '.$user['id'].'
;';
        pwg_query($query);
      }
      $user['language'] = $_GET['lang'];
    }
  }
  elseif (is_a_guest() or is_generic())
  {
    $user['language'] = pwg_get_session_var('lang_switch', $user['language']);
  }

  // Reload language only if it isn't the same one
  if ($same !== $user['language'])
  {
    load_language('common.lang', '', array('language'=>$user['language']));
    load_language(
      'lang',
      PHPWG_ROOT_PATH.'local/',
      array(
        'language' => $user['language'],
        'no_fallback' => true,
        'local' => true,
        )
      );
    
    if (defined('IN_ADMIN') and IN_ADMIN) { // Never currently
      load_language('admin.lang', '', array('language'=>$user['language']) );
    }
  }
}

add_event_handler('loc_begin_page_header', 'myiceland_languages_in_header');
function myiceland_languages_in_header()
{ 
  global $template, $user;

  $language_code_to_name = get_languages();

  $base_url = duplicate_index_url();
  if (script_basename() == 'picture')
  {
    $base_url = duplicate_picture_url();
  }
  $base_url = add_url_params(
    $base_url,
    array('lang' => '')
    );
  
  $languages = array();
  $language_codes = array('sv_SE', 'en_UK', 'de_DE');
  foreach ($language_codes as $language_code)
  {
    $language = array(
      'name' => preg_replace('/\s\[.*\]$/', '', $language_code_to_name[$language_code]),
      'code' => $language_code,
      'url' => $base_url.$language_code,
      'is_current' => ($language_code == $user['language']),
      );
    array_push($languages, $language);
  }   
  
  $template->assign('languages', $languages);
}
?>

3) go to [Administration > Plugins > Manage], install and activate the "Personal Plugin"

If you want to change the list of languages in your header, in your Personal Plugin, function myiceland_languages_in_header() change the line:

Code:

$language_codes = array('sv_SE', 'en_UK', 'de_DE');

Last step is to set the correct CSS rules in themes/myiceland/theme.css for example in the screenshot I used:

Code:

#mi-languageSwitch {
  position: absolute;
  left: 875px;
  top: 5px;
  width: 60px;
  text-align: right;
  line-height: 20px;
}

#mi-languageSwitch ul {
  margin:0;
  padding:0
}

#mi-languageSwitch li.currentLanguage a {
  color:#279AB2;
}

#mi-languageSwitch li img {
  margin-bottom: -3px;
}

Offline

 

#15 2010-11-17 01:34:14

Wallster
Translation Team
Skaftafell, Iceland
2010-10-22
48

Re: [resolved] Move plugin language_switch to header

As soon as I tried to save "personal plugin" my gallery stopped working. Now I can't access it, can you?

http://wallstudio.se/myiceland/gallery

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact