The folder structure is correct for development. However, for a Marketplace upload, you should only package the module directory. Magento 2 extensions will be installed using the Component Manager, which uses Composer under the hood. The Component Manager and Composer will take care of extracting and installing your package to the correct location. Generally, this will be under the vendor/ directory. Based on the information in the registration.php and composer.json's "autoload" section, the module will be installed in the following structure:
magento2/
|+- app/
|+- bin/
|+- vendor/
|+- <Vendor name>
|+- <Module name>
|+- composer.json
|+- registration.php
|+- ...
|+- setup/
|+- ...
If your registration.php and composer.json files are set up correctly, then the Magento application will be able to identify and use that module. Furthermore, Composer will take care of any namespaces you have created and any namespaces you use in your module.
The aim of this tool is to validate your package structure in preparation for an upload to the Marketplace.
As you know you shouldn't touch the vendor folder because it will be overwritten.
You can do it the following way (which I think it is best practice):
Create path:
/app/i18n/magento/uk_ua/
In that folder create 4 files:
composer.json
{
"name": "magento/uk_ua",
"description": "Ukrainian",
"version": "100.0.1",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"require": {
"magento/framework": "100.0.*"
},
"type": "magento2-language",
"autoload": {
"files": [
"registration.php"
]
}
}
uk_UA.csv
"some newsletter text","changed newsletter text"
language.xml
<?xml version="1.0"?>
<language xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/Language/package.xsd">
<code>uk_UA</code>
<vendor>magento</vendor>
<package>uk_ua</package>
</language>
registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::LANGUAGE,
'magento_uk_ua',
__DIR__
);
?>
Bare in mind that it is case sensitive. Path, registration and vendor are uk_ua
, but csv and code is uk_UA
.
Best Answer
It seems like for language packs you cannot create separate CSV files per module anymore (which makes sense given that translations are not scoped by module anymore, see: How does translation scope work in Magento 2?)
From the documentation:
(highlight added)
Since language packs are the only way to provide core translations for a composer based installation, I don't see any way to do it differently.