The templates in app/code/Magento/Ui/view/base/web/templates
are not translatable despite of bind-attr
i18n
usage.
This is because of 2 Magento core bugs.
Bug №1
The templates resides in the templates
folder, but Magento 2 core (the \Magento\Framework\App\Utility\Files::getStaticHtmlFiles()
method) does not look into folders names templates
folders, it looks into template
folders:
To fix the first bug, just add a new globbing pattern:
"{$this->_path}/app/code/{$namespace}/{$module}/view/{$area}/web/templates",
Bug №2
There is the second bug: Magento 2 core (the \Magento\Translation\Model\Js\DataProvider::getData()
method) does not look into base
area folder:
As you can see it looks only to the current design area: frontend
or adminthml
, but not base
.
To fix it add the code:
$staticHtmlFilesFromBase = $this->filesUtility->getStaticHtmlFiles('base', $themePath);
if (is_array($staticHtmlFilesFromBase)) {
$files = array_merge($files, $staticHtmlFilesFromBase);
}
Place it just after the line:
GitHub issue 1791.
After 2 months the bug is not fixed yet, but the core code has been changed significantly so here is my new fix for the current core code:
Step 1
Add after:
$moduleTemplatePaths[] = $moduleDir . "/view/{$area}/web/templates";
Step 2
Replace the line with the following code:
$themePaths = array_merge(
$this->getThemePaths($area, $namespace . '_' . $module, '/web/template')
,$this->getThemePaths($area, $namespace . '_' . $module, '/web/templates')
);
My latest fix was for October 2015 pre-prelease code.
You can test it yourself whether the fix works with the latest code.