Can someone indicate me where I can find the code that the lang attribute for the html tag determines? I'd like to make the lang attribute to show <html lang="en-US"> instead of <html lang="en">


The Source code you are looking for is located in vendor/magento/module-theme/view/base/templates/root.phtml.

To change this behavior copy the above file to your current theme directory.

For Example:- app/design/frontend/YOURVENDORNAME/YOURTHEME/Magento_Theme/templates/root.phtml

Around line 11 Change the below line

<html <?= /* @escapeNotVerified */ $htmlAttributes ?>>


<html <?= /* @escapeNotVerified */ "lang=en-US"; ?>>      
  • Thanks for reacting. Given the fact that i have different store views, i’d like to have it by means of php variables instead of a harcoded value – Julian Murillo Nov 18 '18 at 10:11
  • Yes it is possible to have it in php variable, you can add a condition to check the current store view by either store id or storename. Base on the store you can set the value in a php variable. – mydons Nov 19 '18 at 6:48

You can either check with store name or store id and assign the lang attribute

$objectManager =  \Magento\Framework\App\ObjectManager::getInstance();        
$storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface');
$storeID       = $storeManager->getStore()->getStoreId(); 
$storeName     = $storeManager->getStore()->getName();

$lang = "lang=en-US"; //Default value for lang attribute
 $lang = "lang=en-US";
else if($storeID==2) {
 $lang = "lang=en-GB";

<html <?= /* @escapeNotVerified */ $lang ?>>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.