In Magento 2, a static content URL looks like this


This includes a en_US locale portion. This strongly implies that either

  1. Magento 2 allows you to create different static content files per locale
  2. Magento 2 processes static content files for locale/gettext strings

Which of the above is true? Or are both true? Or neither?

How do I, as a Magento module developer, provide a static content files on a per locale basis? Would this be different if I was a theme developer?

2 Answers 2


Magento allows to provide static asset files per locale in the module or theme. To provide such localized files, put them under web/i18n/<locale> folder inside the module or a theme. These files have priority above non-localized files.

  • how we can do the changes in phtml ? is it possible, because in some case i need to add or remove some thing in phtml level in that case how to do it and also layout xml? Jan 6, 2016 at 5:06
  • and also few of my custom variable or less files also need to be changed in that case how to do it Jan 6, 2016 at 7:36
  • 3
    Same. Just phtml files should be located under templates and layouts under layout folders. For themes - this is first level of directories, for modules - it should be under view/<area>.
    – BuskaMuza
    Jan 6, 2016 at 15:58
  • @BuskaMuza I am sorry but I tried different variations for the XML and PHTML but it didn't. Say my local is ar_EG and I want to insert a new CSS file in default_head_blocks.xml. The file is called from theme\Magento_Theme\layout ... what exactly should be the URL of my override?
    – Ahmad Alfy
    Mar 17, 2016 at 13:58
  • 2
    default_head_blocks.xml should not know anything about locale. Paths to CSS should be referenced in XML as <module>::css/<file>.css (for modular file) or css/<file>.css (for theme file). If you put your localized CSS file in <modue>/view/<area>/web/i18n/ar_EG/css/<file>.css or in <theme>/web/i18n/ar_EG/css/<file>.css, it should be used automatically for a store with ar_EG chosen as locale.
    – BuskaMuza
    Mar 18, 2016 at 15:00

Instead of complete separate file for different language, you can extend the theme by overriding the default files. Either in extends.less or theme.less file. Below can be the structure to override.


For example :


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.