将hreflang添加到magento语言切换器
I am trying to add hreflang="ca-fr" or "ca-en" my code is below
<?php if ($_lang->getId() != $this->getCurrentStoreId()): ?>
<li class="language-<?php echo $this->htmlEscape($_lang->getCode()); ?>">
<a href="#" onclick="changeLang('<?php echo $_lang->getCurrentUrl() ?>')"
hreflang="<?php echo $this->htmlEscape($_lang->getCode()); ?>"
id="link-<?php echo $_lang->getId() ?>"><?php echo $frontendNameAssign[$_lang->getId()]; ?></a>
</li>
<?php endif; ?>
I added the 4th line to the file but this displays as "ca_us_english", is there a way to amend this?
I have also tried amending Miscellaneous Scripts with no joy, any help would be grateful.
thanks Mel
我正在尝试添加hreflang =“ca-fr”或“ca-en”我的代码在下面 p>
&lt;?php if($ _lang-&gt; getId()!= $ this-&gt; getCurrentStoreId()):?&gt;
&lt; li class =“language - &lt;?php echo $ this-&gt; htmlEscape($ _ lang-&gt; getCode());?&gt;“&gt;
&lt; a href =”#“onclick =”changeLang('&lt;?php echo $ _lang-&gt; getCurrentUrl()?&gt;')“
hreflang =”&lt;?php echo $ this-&gt; htmlEscape($ _ lang-&gt; getCode());?&gt;“
id =” link-&lt;?php echo $ _lang-&gt; getId()?&gt;“&gt;&lt;?php echo $ frontendNameAssign [$ _ lang-&gt; getId()]; ?&gt;&lt; / a&gt;
&lt; / li&gt;
&lt;?php endif; ?&gt;
code> pre>
我在文件中添加了第4行,但显示为“ca_us_english”,有没有办法修改它? p>
我也试过修改杂项脚本没有任何乐趣,任何帮助都会感激不尽。 p>
谢谢
Mel p>
div>
Well in this case you are "right" and Magento is "wrong".
What Magento is actually presenting you as $_lang
is not really the lang, but one of your store.
So ca_us_english
is the code of your english candian store in your backend (you can have a look at it in the admin under System > Manage Stores)
To get the actual local set for this store you have to use this line of code :
Mage::getStoreConfig('general/locale/code', $_lang->getId())