Zen Cart Logo
Forums / All Other Contributions/Addons / Language set by browser gives wrong meta tag languages (with customization of addon)

Language set by browser gives wrong meta tag languages (with customization of addon)

Locked

Views: 2,163

Results 1 to 13 of 13
This thread is locked. New replies are disabled.
8 Jul 2009, 6:23 PM
#1
marksu avatar

marksu

Zen Follower

Join Date:
Nov 2007
Posts:
260
Plugin Contributions:
0

Language set by browser gives wrong meta tag languages (with customization of addon)

I have the default site language set by browser.
When comming to the site it displays the site in Finnish language which is OK.

Problem is that is uses english metatags.

I added facebook link to the store and it used meta tags.
This leads to english metatags when it should be Finnish.

Can somebody give a fix for the problem.

9 Jul 2009, 3:42 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Language set by browser gives wrong meta tag languages (with customization of addon)

If you want it to be using Finnish by default, I would suggest setting Finnish to be the default language in Admin->Localization->Languages, regardless of the browser-detection option.

Additionally, you might try the ideas posted here, as some of these concepts are incorporated with various language improvements in the upcoming v2.0 release. Making these changes to your own site now might work around some of the limitations of the current code and could fix the issue you're describing.

9 Jul 2009, 6:34 AM
#3
marksu avatar

marksu

Zen Follower

Join Date:
Nov 2007
Posts:
260
Plugin Contributions:
0

Re: Language set by browser gives wrong meta tag languages (with customization of addon)

Thank you DrByte. I will try them out.
I realy need the language by browser feature.

9 Jul 2009, 7:10 AM
#4
marksu avatar

marksu

Zen Follower

Join Date:
Nov 2007
Posts:
260
Plugin Contributions:
0

Re: Language set by browser gives wrong meta tag languages (with customization of addon)

Languge works in general OK only the meta tag dont seem to understand it or meta tag is set before the language?

Any tips on where to find the code that sets the meta tag content?

9 Jul 2009, 7:37 AM
#5
marksu avatar

marksu

Zen Follower

Join Date:
Nov 2007
Posts:
260
Plugin Contributions:
0

Re: Language set by browser gives wrong meta tag languages (with customization of addon)

I did the update but it did not help at all.

9 Jul 2009, 8:40 AM
#6
marksu avatar

marksu

Zen Follower

Join Date:
Nov 2007
Posts:
260
Plugin Contributions:
0

Re: Language set by browser gives wrong meta tag languages (with customization of addon)

Hmm the problem seems to be in the facebook link and not zen cart it self.

Problem is that the facebook link uses location.href to define the url and then the language paramether are missing.
When ser then cliks the link face book uses that link to get meta tags.

I would need to generate right language paramethers when location.href returns url without language paramethers.

9 Jul 2009, 8:53 AM
#7
marksu avatar

marksu

Zen Follower

Join Date:
Nov 2007
Posts:
260
Plugin Contributions:
0

Re: Language set by browser gives wrong meta tag languages (with customization of addon)

Is ther a function in ZC like getcurrentLanguage() or similar?

9 Jul 2009, 10:32 AM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Language set by browser gives wrong meta tag languages (with customization of addon)

The value of $_SESSION['languages_code'] is the 2-letter language code for the user's currently-selected language.

9 Jul 2009, 11:57 AM
#9
marksu avatar

marksu

Zen Follower

Join Date:
Nov 2007
Posts:
260
Plugin Contributions:
0

Re: Language set by browser gives wrong meta tag languages (with customization of addon)

Yes thank you again, even though I in the end found that out.
Propaply there is even easyer way to do it but at least it works.

Here is my solution if anyone interested.

Note I used the "Social Bookmarking - manual instructions" from download. If you are using this edit the http://www.breezy.biz/breezy.jpg picture to you own picture url.
Also rest of the code is in that download.

//** Row Code from http://www.bradino.com/php/get-current-url/
$URL = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
//**

if (array_key_exists('language', $_GET)) {
$params = '';
}
else
{$params = "language = " . $_SESSION['languages_code'];
if ( $_SERVER['QUERY_STRING'] == '')
{$URL = $URL . "?" . $params ;}
else
{$URL = $URL . "&" . $params ;}

}

if ( $_SERVER['QUERY_STRING'] == '')
{$URL = $URL ;}
else
{$URL = $URL . $params;}

$URL = "'".$URL."'"; // I need this cause it is echoed to javascript sting

<a rel="nofollow" style="text-decoration:none;" href="http://www.facebook.com/share.php?u=/" onclick="window.open('http://www.facebook.com/share.php?u='+encodeURIComponent(document.title)+'&d=&tag=&u='+encodeURIComponent(<?php echo $URL?>));return false;" title="Share this site with your facebook friends"><img src="http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif " rel="image_src" href="http://www.breezy.biz/breezy.jpg" width="20" height="20" border="0" style="padding-bottom:1px;" /></a>

9 Jul 2009, 12:24 PM
#10
marksu avatar

marksu

Zen Follower

Join Date:
Nov 2007
Posts:
260
Plugin Contributions:
0

Re: Language set by browser gives wrong meta tag languages (with customization of addon)

Auch still not working I got to do some checking.

9 Jul 2009, 12:41 PM
#11
marksu avatar

marksu

Zen Follower

Join Date:
Nov 2007
Posts:
260
Plugin Contributions:
0

Re: Language set by browser gives wrong meta tag languages (with customization of addon)

OK I had some silly mistakes.

Here is the new code.

<?php // Code from <http://www.bradino.com/php/get-current-url/> $URL = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; if (array_key_exists('language', $_GET)) { $params = ''; } else {$params = "language=" . $_SESSION['languages_code']; if ( $_SERVER['QUERY_STRING'] == '') {$URL = $URL . "?" . $params ;} else {$URL = $URL . "&" . $params ;} } $URL = "'".$URL."'"; // I need this cause it is echoed to javascript sting ?>

<a rel="nofollow" style="text-decoration:none;" href="http://www.facebook.com/share.php?u=/" onclick="window.open('http://www.facebook.com/share.php?u='+encodeURIComponent(document.title)+'&d=&tag=&u='+encodeURIComponent(<?php echo $URL?>));return false;" title="Share this site with your facebook friends"><img src="http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif " rel="image_src" href="http://www.breezy.biz/breezy.jpg" width="20" height="20" border="0" style="padding-bottom:1px;" /></a>

9 Jul 2009, 12:49 PM
#12
marksu avatar

marksu

Zen Follower

Join Date:
Nov 2007
Posts:
260
Plugin Contributions:
0

Re: Language set by browser gives wrong meta tag languages (with customization of addon)

What it does is following:

Instead of getting the url using javascript "location.href" php generates the url to a string.

Code checks if the current URL is missing language= tag and if so it appends it to the URL.