Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Changing lang="en” to the language in <html> tags
 
SeL_
Magento Team
 
Avatar
Total Posts:  1140
Joined:  2007-10-10
Paris, France
 

In phtml files, the <html> tag always has lang="en", even if french or other language is used for the store.
@Magento guys: Would it be possible to make it dynamic so thats it reflects the language in use ?
Thanks in advance.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

Great idea, will be in next release.

If you wish to experiment, add this method:

public function getLang()
    
{
        
if (!$this->hasData('lang')) {
            $this
->setData('lang'substr(Mage::app()->getLocale()->getLocaleCode(), 02));
        
}
        
return $this->getData('lang');
    
}
to both Mage_Page_Block_Html and Mage_Adminhtml_Block_Page, and update:
* app/design/frontend/default/default/template/page/*.phtml
* app/design/adminhtml/default/defeault/template/page.phtml
to have it referenced in <html> tag:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?=$this->getLang()?>" lang="<?=$this->getLang()?>">
 
Magento Community Magento Community
Magento Community
Magento Community
 
ptz0n
Jr. Member
 
Avatar
Total Posts:  2
Joined:  2012-01-22
Stockholm, Sweden
 

This is what we use when getting the store language/country code in Magento CE 1.6+.

<html lang="<?php echo strtolower(Mage::getStoreConfig('general/country/default')); ?>">
 
Magento Community Magento Community
Magento Community
Magento Community
 
AttilaB
Jr. Member
 
Avatar
Total Posts:  2
Joined:  2013-04-17
 

You can also try this one:

<html lang="<?php echo $this->getLang() ?>">

As it is provided by page.phtml by default

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top