Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2008
    Posts
    35
    Plugin Contributions
    0

    help question actual language php variable ?

    Hi there,

    I am developping a english/french site and I want to customize a language selector in tpl_header.php

    If I am in french section, I want to display a link to english section with "English" label.
    Else, if I am in english section, I want to display a link to french section with "Français" label.

    I need to know how I can retrieve the actual language in use to built / display the appropriate link.

    I started with this code below, which display a flag for every language available. I observed that when I change language, I got a "language" attribute in the URL but this attribute dissapear when going to another page.

    PHP Code:
    <?php 
        
    if (!isset($lng) || (isset($lng) && !is_object($lng))) {
            
    $lng = new language;
        }   
        
    reset($lng->catalog_languages);     
        while (list(
    $key$value) = each($lng->catalog_languages)) {
            echo 
    '<a href="' zen_href_link($_GET['main_page'], zen_get_all_get_params(array('language''currency')) . 'language=' $key$request_type) . '">' zen_image(DIR_WS_LANGUAGES.$value['directory'].'/images/'.$value['image'], $value['name'], ''''' style="vertical-align:middle;"') . '</a>';
        }
    ?>
    Then my question is: Is there a global php variable from which I can retrieve the actual language in use ?

    Thank's a lot!

  2. #2
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: actual language php variable ?

    I believe $_SESSION['language'] will do what you want.

  3. #3
    Join Date
    Jun 2008
    Posts
    35
    Plugin Contributions
    0

    Default Re: actual language php variable ?

    You're right !

    Here's the code for anyone who needs it:

    PHP Code:
    <?php 
        
    if ($_SESSION['language'] == "english"){
            echo 
    '<a href="' zen_href_link($_GET['main_page'], zen_get_all_get_params(array('language''currency')) . 'language=' 'fr'$request_type) . '">Fran&ccedil;ais</a>';
        }
        else { 
    //$_SESSION['language'] == "french"
            
    echo '<a href="' zen_href_link($_GET['main_page'], zen_get_all_get_params(array('language''currency')) . 'language=' 'en'$request_type) . '">English</a>';
        }
    ?>
    Thank's a lot !
    François

 

 

Similar Threads

  1. v153 Base price as a PHP variable
    By Matt Staines in forum Templates, Stylesheets, Page Layout
    Replies: 6
    Last Post: 21 Mar 2015, 06:50 PM
  2. Replies: 1
    Last Post: 8 Feb 2011, 02:07 AM
  3. How to style a php variable??
    By DesignLessDesign in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 21 Sep 2010, 08:20 PM
  4. Display language variable un URL
    By cactusman in forum General Questions
    Replies: 7
    Last Post: 7 Jul 2010, 11:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg