Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Jun 2007
    Location
    Cymru
    Posts
    124
    Plugin Contributions
    0

    Default Open language depending on browser setting

    Hi, I was wondering if anyone can help.

    I have a bilingual website in English and Welsh (I translated the Welsh version myself). The code for English is 'en' and Welsh (Cymraeg) is 'cy'.

    I have set the English language as 'default' in admin, and have also got English 1st order wise, but what I want to happen is for th Welsh language version to show automatically if somone is using a Welsh language browser. Firefox and IE are available in Welsh, and some others.

    I use a Welsh language browser, and the Welsh version of other sites do open when I visit, without me needing to do anything (for example Google), but unfortunately the same is not true for our Zen Cart site (1.3.7).

    The English language ALWAYS opens, it doesn't matter what the browser settings are, and the user has to click on the change language link in the sidebar.

    Is there a way of having the Welsh language version to open automatically, if the user is using a Welsh language browser, and for the English language browser to open if the user is using a web browser in any other language?

  2. #2
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Open language depending on browaer setting

    Admin->Configuration->My Store->Language Selector
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Jun 2007
    Location
    Cymru
    Posts
    124
    Plugin Contributions
    0

    Default Re: Open language depending on browser setting

    Thank you very much for the above info 'DrByte'. I hadn't noticed that little switch! I've changed from 'Default' to 'Browser' but for some reason it doesn'tseem to make any difference.

    I've got a computer running Windows XP with Welsh language Pack (all interface is in Welsh) and am using the Welsh language version of Firefox, but the English version of my site still shows.

    http://www.cadwyngifts.com/

    I've checked under Tools>Options>Advanced>Languages and in the list I have:

    Welsh [cy]
    [cy-GB]
    [en-GB]
    English [en]

    Shouldn't the Welsh version appear therefore?
    Last edited by bonheddwr; 9 Sep 2008 at 09:09 AM.

  4. #4
    Join Date
    Jun 2007
    Location
    Cymru
    Posts
    124
    Plugin Contributions
    0

    Default Re: Open language depending on browser setting

    I've just used 'cy' as the Welsh language version and 'en' for English, not 'cy-GB' or en-GB' i.e. the language selection for homepage is as follows:

    http://www.cadwyngifts.com/?language=en
    http://www.cadwyngifts.com/?language=cy

  5. #5
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Open language depending on browser setting

    You may need to add your language code to the language class /includes/classes/languages.php
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  6. #6
    Join Date
    Jun 2007
    Location
    Cymru
    Posts
    124
    Plugin Contributions
    0

    Default Re: Open language depending on browser setting

    Quote Originally Posted by DrByte View Post
    You may need to add your language code to the language class /includes/classes/languages.php
    Many thanks. I accessed that file, and you ar right, the Welsh language is not included. I tried to follow the strings for other languages and added the following, but after doing so the website wouldn'tload, and therefore I've pulled them out:

    PHP Code:
        'cy' => array('cy|welsh''welsh''cy'));
        
    'cy-gb' => array('cy[-_]gb|great britain welsh''greatbritain_welsh''cy-GB'), 
    This is the content of the file by the way, I would be very grateful if anybody could advise me on where I am going wrong.

    PHP Code:
    <?php
    /**
     * language Class.
     *
     * @package classes
     * @copyright Copyright 2003-2006 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: language.php 3041 2006-02-15 21:56:45Z wilt $
     */
    if (!defined('IS_ADMIN_FLAG')) {
      die(
    'Illegal Access');
    }
    /**
     * language Class.
     * Class to handle language settings for customer viewing
     *
     * @package classes
     */
    class language extends base {
      var 
    $languages$catalog_languages$browser_languages$language;

      function 
    language($lng '') {
        global 
    $db;
        
    $this->languages = array('ar' => array('ar([-_][[:alpha:]]{2})?|arabic''arabic''ar'),
        
    'bg-win1251' => array('bg|bulgarian''bulgarian-win1251''bg'),
        
    'bg-koi8r' => array('bg|bulgarian''bulgarian-koi8''bg'),
        
    'ca' => array('ca|catalan''catala''ca'),
        
    'cs-iso' => array('cs|czech''czech-iso''cs'),
        
    'cs-win1250' => array('cs|czech''czech-win1250''cs'),
        
    'da' => array('da|danish''danish''da'),
        
    'de' => array('de([-_][[:alpha:]]{2})?|german''german''de'),
        
    'el' => array('el|greek',  'greek''el'),
        
    'en' => array('en([-_][[:alpha:]]{2})?|english''english''en'),
        
    'es' => array('es([-_][[:alpha:]]{2})?|spanish''spanish''es'),
        
    'et' => array('et|estonian''estonian''et'),
        
    'fi' => array('fi|finnish''finnish''fi'),
        
    'fr' => array('fr([-_][[:alpha:]]{2})?|french''french''fr'),
        
    'gl' => array('gl|galician''galician''gl'),
        
    'he' => array('he|hebrew''hebrew''he'),
        
    'hu' => array('hu|hungarian''hungarian''hu'),
        
    'id' => array('id|indonesian''indonesian''id'),
        
    'it' => array('it|italian''italian''it'),
        
    'ja-euc' => array('ja|japanese''japanese-euc''ja'),
        
    'ja-sjis' => array('ja|japanese''japanese-sjis''ja'),
        
    'ko' => array('ko|korean''korean''ko'),
        
    'ka' => array('ka|georgian''georgian''ka'),
        
    'lt' => array('lt|lithuanian''lithuanian''lt'),
        
    'lv' => array('lv|latvian''latvian''lv'),
        
    'nl' => array('nl([-_][[:alpha:]]{2})?|dutch''dutch''nl'),
        
    'no' => array('no|norwegian''norwegian''no'),
        
    'pl' => array('pl|polish''polish''pl'),
        
    'pt-br' => array('pt[-_]br|brazilian portuguese''brazilian_portuguese''pt-BR'),
        
    'pt' => array('pt([-_][[:alpha:]]{2})?|portuguese''portuguese''pt'),
        
    'ro' => array('ro|romanian''romanian''ro'),
        
    'ru-koi8r' => array('ru|russian''russian-koi8''ru'),
        
    'ru-win1251' => array('ru|russian''russian-win1251''ru'),
        
    'sk' => array('sk|slovak''slovak-iso''sk'),
        
    'sk-win1250' => array('sk|slovak''slovak-win1250''sk'),
        
    'sr-win1250' => array('sr|serbian''serbian-win1250''sr'),
        
    'sv' => array('sv|swedish''swedish''sv'),
        
    'th' => array('th|thai''thai''th'),
        
    'tr' => array('tr|turkish''turkish''tr'),
        
    'uk-win1251' => array('uk|ukrainian''ukrainian-win1251''uk'),
        
    'zh-tw' => array('zh[-_]tw|chinese traditional''chinese_big5''zh-TW'),
        
    'zh' => array('zh|chinese simplified''chinese_gb''zh'));

        
    $this->catalog_languages = array();
        
    $languages_query "select languages_id, name, code, image, directory
                              from " 
    TABLE_LANGUAGES 
                              order by sort_order"
    ;

        
    $languages $db->Execute($languages_query);

        while (!
    $languages->EOF) {
          
    $this->catalog_languages[$languages->fields['code']] = array('id' => $languages->fields['languages_id'],
          
    'name' => $languages->fields['name'],
          
    'image' => $languages->fields['image'],
          
    'code' => $languages->fields['code'],
          
    'directory' => $languages->fields['directory']);
          
    $languages->MoveNext();
        }
        
    $this->browser_languages '';
        
    $this->language '';

        
    $this->set_language($lng);
      }

      function 
    set_language($language) {
        if ( (
    zen_not_null($language)) && (isset($this->catalog_languages[$language])) ) {
          
    $this->language $this->catalog_languages[$language];
        } else {
          
    $this->language $this->catalog_languages[DEFAULT_LANGUAGE];
        }
      }

      function 
    get_browser_language() {
        
    $this->browser_languages explode(','$_SERVER['HTTP_ACCEPT_LANGUAGE']);

        for (
    $i=0$n=sizeof($this->browser_languages); $i<$n$i++) {
          
    reset($this->languages);
          while (list(
    $key$value) = each($this->languages)) {
            if (
    eregi('^(' $value[0] . ')(;q=[0-9]\\.[0-9])?$'$this->browser_languages[$i]) && isset($this->catalog_languages[$key])) {
              
    $this->language $this->catalog_languages[$key];
              break 
    2;
            }
          }
        }
      }
    }
    ?>

 

 

Similar Threads

  1. Open secure payment page in a new browser?
    By cygnus in forum General Questions
    Replies: 7
    Last Post: 1 Dec 2010, 07:01 PM
  2. images are not consistent depending on browser and pc
    By wagnerguy in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 1 Apr 2010, 04:19 PM
  3. Switching currency automatically depending on language?
    By kazie in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 2
    Last Post: 28 Jan 2010, 02:29 PM
  4. Mp3 wont download instead of open in IE browser
    By cashewbsc in forum General Questions
    Replies: 2
    Last Post: 7 Jan 2010, 09:26 AM
  5. Hide items of info depending on language
    By joomoo79 in forum General Questions
    Replies: 3
    Last Post: 22 Feb 2009, 05:02 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