Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php bin/magento i18n:pack creates unwanted dir #6260

Closed
thomvanderboon opened this issue Aug 21, 2016 · 22 comments
Closed

php bin/magento i18n:pack creates unwanted dir #6260

thomvanderboon opened this issue Aug 21, 2016 · 22 comments
Labels
bug report Component: Setup Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@thomvanderboon
Copy link

If you run the php bin/magento i18n:pack to install a language pack a /i18n directory is created at system root. If you have no permission to write at system root you wil get a mkdir error

Tested on 2.1.0 and 2.2.0-dev (both same result)

Steps to reproduce

  1. From website root
  2. cd ./var
  3. wget http://107.170.242.99/var/2.1.0/source_nl_NL.csv
  4. cd ..
  5. php bin/magento i18n:pack --mode=replace -d var/source_nl_NL.csv nl_NL

Expected result

  1. Do not create i18n dir at / (system root)

Actual result

  1. Creates /i18n at system root
  2. Creates language file in /i18n at system root
@biojppm
Copy link

biojppm commented Aug 29, 2016

I get this too. This makes it impossible to install any language pack.

I traced this further and it seems that some but not all modules are unregistered. This causes their paths to be empty and thus when the /i18n dir is appended to their paths the result is a dir at the root level.

I found this by adding a print to setup/src/Magento/Setup/Module/I18n/Pack/Writer/File/AbstractFile.php at the method _buildPackFilesData():

$path = $this->_context->buildPathToLocaleDirectoryByContext($phrase->getContextType(), $context);
echo 'context='.$context."............path=".$path."\n";

... and this was the result (sorted, duplicates removed via piping sort -u):

context=frontend/Magento/blank............path=/home/user/magento/vendor/magento/theme-frontend-blank/i18n/
context=frontend/Magento/luma............path=/home/user/magento/vendor/magento/theme-frontend-luma/i18n/
context=Magento_AdminGws............path=/i18n/
context=Magento_AdminNotification............path=/home/user/magento/vendor/magento/module-admin-notification/i18n/
context=Magento_AdvancedCheckout............path=/i18n/
context=Magento_AdvancedPricingImportExport............path=/home/user/magento/vendor/magento/module-advanced-pricing-import-export/i18n/
context=Magento_AdvancedRule............path=/i18n/
context=Magento_AdvancedSalesRule............path=/i18n/
context=Magento_AdvancedSearch............path=/i18n/
context=Magento_Amqp............path=/i18n/
context=Magento_Authorization............path=/home/user/magento/vendor/magento/module-authorization/i18n/
context=Magento_Authorizenet............path=/home/user/magento/vendor/magento/module-authorizenet/i18n/
context=Magento_Backend............path=/home/user/magento/vendor/magento/module-backend/i18n/
context=Magento_Backup............path=/home/user/magento/vendor/magento/module-backup/i18n/
context=Magento_Banner............path=/i18n/
context=Magento_Braintree............path=/home/user/magento/vendor/magento/module-braintree/i18n/
context=Magento_Bundle............path=/home/user/magento/vendor/magento/module-bundle/i18n/
context=Magento_BundleStaging............path=/i18n/
context=Magento_Captcha............path=/home/user/magento/vendor/magento/module-captcha/i18n/
context=Magento_CatalogEvent............path=/i18n/
context=Magento_CatalogImportExport............path=/home/user/magento/vendor/magento/module-catalog-import-export/i18n/
context=Magento_CatalogInventory............path=/home/user/magento/vendor/magento/module-catalog-inventory/i18n/
context=Magento_Catalog............path=/home/user/magento/vendor/magento/module-catalog/i18n/
context=Magento_CatalogPermissions............path=/i18n/
context=Magento_CatalogRule............path=/home/user/magento/vendor/magento/module-catalog-rule/i18n/
context=Magento_CatalogRuleStaging............path=/i18n/
context=Magento_CatalogSearch............path=/home/user/magento/vendor/magento/module-catalog-search/i18n/
context=Magento_CatalogStaging............path=/i18n/
context=Magento_CatalogUrlRewrite............path=/home/user/magento/vendor/magento/module-catalog-url-rewrite/i18n/
context=Magento_CatalogUrlRewriteStaging............path=/i18n/
context=Magento_CatalogWidget............path=/home/user/magento/vendor/magento/module-catalog-widget/i18n/
context=Magento_CheckoutAgreements............path=/home/user/magento/vendor/magento/module-checkout-agreements/i18n/
context=Magento_Checkout............path=/home/user/magento/vendor/magento/module-checkout/i18n/
context=Magento_CheckoutStaging............path=/i18n/
context=Magento_Cms............path=/home/user/magento/vendor/magento/module-cms/i18n/
context=Magento_CmsStaging............path=/i18n/
context=Magento_Config............path=/home/user/magento/vendor/magento/module-config/i18n/
context=Magento_ConfigurableProduct............path=/home/user/magento/vendor/magento/module-configurable-product/i18n/
context=Magento_ConfigurableProductStaging............path=/i18n/
context=Magento_Contact............path=/home/user/magento/vendor/magento/module-contact/i18n/
context=Magento_Cookie............path=/home/user/magento/vendor/magento/module-cookie/i18n/
context=Magento_Cron............path=/home/user/magento/vendor/magento/module-cron/i18n/
context=Magento_CurrencySymbol............path=/home/user/magento/vendor/magento/module-currency-symbol/i18n/
context=Magento_CustomAttributeManagement............path=/i18n/
context=Magento_CustomerBalance............path=/i18n/
context=Magento_CustomerCustomAttributes............path=/i18n/
context=Magento_CustomerFinance............path=/i18n/
context=Magento_CustomerImportExport............path=/home/user/magento/vendor/magento/module-customer-import-export/i18n/
context=Magento_Customer............path=/home/user/magento/vendor/magento/module-customer/i18n/
context=Magento_CustomerSegment............path=/i18n/
context=Magento_Cybersource............path=/i18n/
context=Magento_Deploy............path=/home/user/magento/vendor/magento/module-deploy/i18n/
context=Magento_Developer............path=/home/user/magento/vendor/magento/module-developer/i18n/
context=Magento_Dhl............path=/home/user/magento/vendor/magento/module-dhl/i18n/
context=Magento_Directory............path=/home/user/magento/vendor/magento/module-directory/i18n/
context=Magento_Doc............path=/i18n/
context=Magento_DownloadableImportExport............path=/home/user/magento/vendor/magento/module-downloadable-import-export/i18n/
context=Magento_Downloadable............path=/home/user/magento/vendor/magento/module-downloadable/i18n/
context=Magento_Eav............path=/home/user/magento/vendor/magento/module-eav/i18n/
context=Magento_Elasticsearch............path=/i18n/
context=Magento_Email............path=/home/user/magento/vendor/magento/module-email/i18n/
context=Magento_EncryptionKey............path=/home/user/magento/vendor/magento/module-encryption-key/i18n/
context=Magento_Enterprise............path=/i18n/
context=Magento_Eway............path=/i18n/
context=Magento_Fedex............path=/home/user/magento/vendor/magento/module-fedex/i18n/
context=Magento_GiftCardAccount............path=/i18n/
context=Magento_GiftCard............path=/i18n/
context=Magento_GiftMessage............path=/home/user/magento/vendor/magento/module-gift-message/i18n/
context=Magento_GiftRegistry............path=/i18n/
context=Magento_GiftWrapping............path=/i18n/
context=Magento_GoogleAdwords............path=/home/user/magento/vendor/magento/module-google-adwords/i18n/
context=Magento_GoogleAnalytics............path=/home/user/magento/vendor/magento/module-google-analytics/i18n/
context=Magento_GoogleOptimizer............path=/home/user/magento/vendor/magento/module-google-optimizer/i18n/
context=Magento_GoogleTagManager............path=/i18n/
context=Magento_GroupedProduct............path=/home/user/magento/vendor/magento/module-grouped-product/i18n/
context=Magento_GroupedProductStaging............path=/i18n/
context=Magento_ImportExport............path=/home/user/magento/vendor/magento/module-import-export/i18n/
context=Magento_Indexer............path=/home/user/magento/vendor/magento/module-indexer/i18n/
context=Magento_Integration............path=/home/user/magento/vendor/magento/module-integration/i18n/
context=Magento_Invitation............path=/i18n/
context=Magento_LayeredNavigation............path=/home/user/magento/vendor/magento/module-layered-navigation/i18n/
context=Magento_Logging............path=/i18n/
context=Magento_Marketplace............path=/home/user/magento/vendor/magento/module-marketplace/i18n/
context=Magento_MediaStorage............path=/home/user/magento/vendor/magento/module-media-storage/i18n/
context=Magento_MessageQueue............path=/i18n/
context=Magento_Msrp............path=/home/user/magento/vendor/magento/module-msrp/i18n/
context=Magento_MultipleWishlist............path=/i18n/
context=Magento_Multishipping............path=/home/user/magento/vendor/magento/module-multishipping/i18n/
context=Magento_MysqlMq............path=/i18n/
context=Magento_NewRelicReporting............path=/home/user/magento/vendor/magento/module-new-relic-reporting/i18n/
context=Magento_Newsletter............path=/home/user/magento/vendor/magento/module-newsletter/i18n/
context=Magento_OfflinePayments............path=/home/user/magento/vendor/magento/module-offline-payments/i18n/
context=Magento_OfflineShipping............path=/home/user/magento/vendor/magento/module-offline-shipping/i18n/
context=Magento_PageCache............path=/home/user/magento/vendor/magento/module-page-cache/i18n/
context=Magento_Payment............path=/home/user/magento/vendor/magento/module-payment/i18n/
context=Magento_Paypal............path=/home/user/magento/vendor/magento/module-paypal/i18n/
context=Magento_PersistentHistory............path=/i18n/
context=Magento_Persistent............path=/home/user/magento/vendor/magento/module-persistent/i18n/
context=Magento_PricePermissions............path=/i18n/
context=Magento_ProductAlert............path=/home/user/magento/vendor/magento/module-product-alert/i18n/
context=Magento_ProductVideo............path=/home/user/magento/vendor/magento/module-product-video/i18n/
context=Magento_ProductVideoStaging............path=/i18n/
context=Magento_PromotionPermissions............path=/i18n/
context=Magento_Quote............path=/home/user/magento/vendor/magento/module-quote/i18n/
context=Magento_Reminder............path=/i18n/
context=Magento_Reports............path=/home/user/magento/vendor/magento/module-reports/i18n/
context=Magento_Review............path=/home/user/magento/vendor/magento/module-review/i18n/
context=Magento_ReviewStaging............path=/i18n/
context=Magento_Reward............path=/i18n/
context=Magento_Rma............path=/i18n/
context=Magento_Rss............path=/home/user/magento/vendor/magento/module-rss/i18n/
context=Magento_Rule............path=/home/user/magento/vendor/magento/module-rule/i18n/
context=Magento_SalesArchive............path=/i18n/
context=Magento_Sales............path=/home/user/magento/vendor/magento/module-sales/i18n/
context=Magento_SalesRule............path=/home/user/magento/vendor/magento/module-sales-rule/i18n/
context=Magento_SalesRuleStaging............path=/i18n/
context=Magento_SalesSequence............path=/home/user/magento/vendor/magento/module-sales-sequence/i18n/
context=Magento_ScalableCheckout............path=/i18n/
context=Magento_ScalableInventory............path=/i18n/
context=Magento_ScheduledImportExport............path=/i18n/
context=Magento_Search............path=/home/user/magento/vendor/magento/module-search/i18n/
context=Magento_SearchStaging............path=/i18n/
context=Magento_Security............path=/home/user/magento/vendor/magento/module-security/i18n/
context=Magento_SendFriend............path=/home/user/magento/vendor/magento/module-send-friend/i18n/
context=Magento_Shipping............path=/home/user/magento/vendor/magento/module-shipping/i18n/
context=Magento_Sitemap............path=/home/user/magento/vendor/magento/module-sitemap/i18n/
context=Magento_Solr............path=/i18n/
context=Magento_Staging............path=/i18n/
context=Magento_Store............path=/home/user/magento/vendor/magento/module-store/i18n/
context=Magento_Support............path=/i18n/
context=Magento_Swatches............path=/home/user/magento/vendor/magento/module-swatches/i18n/
context=Magento_TargetRule............path=/i18n/
context=Magento_TaxImportExport............path=/home/user/magento/vendor/magento/module-tax-import-export/i18n/
context=Magento_Tax............path=/home/user/magento/vendor/magento/module-tax/i18n/
context=Magento_Theme............path=/home/user/magento/vendor/magento/module-theme/i18n/
context=Magento_Translation............path=/home/user/magento/vendor/magento/module-translation/i18n/
context=Magento_Ui............path=/home/user/magento/vendor/magento/module-ui/i18n/
context=Magento_Ups............path=/home/user/magento/vendor/magento/module-ups/i18n/
context=Magento_UrlRewrite............path=/home/user/magento/vendor/magento/module-url-rewrite/i18n/
context=Magento_User............path=/home/user/magento/vendor/magento/module-user/i18n/
context=Magento_Usps............path=/home/user/magento/vendor/magento/module-usps/i18n/
context=Magento_Variable............path=/home/user/magento/vendor/magento/module-variable/i18n/
context=Magento_Vault............path=/home/user/magento/vendor/magento/module-vault/i18n/
context=Magento_VersionsCms............path=/i18n/
context=Magento_VisualMerchandiser............path=/i18n/
context=Magento_Webapi............path=/home/user/magento/vendor/magento/module-webapi/i18n/
context=Magento_WebapiSecurity............path=/home/user/magento/vendor/magento/module-webapi-security/i18n/
context=Magento_WebsiteRestriction............path=/i18n/
context=Magento_Weee............path=/home/user/magento/vendor/magento/module-weee/i18n/
context=Magento_Widget............path=/home/user/magento/vendor/magento/module-widget/i18n/
context=Magento_Wishlist............path=/home/user/magento/vendor/magento/module-wishlist/i18n/
context=Magento_Worldpay............path=/i18n/

If we look further, we find that the method buildPathToLocaleDirectoryByContext() is defined at setup/src/Magento/Setup/Module/I18n/Context.php:99:

    /**
     * Get paths by context
     *
     * @param string $type
     * @param array $value
     * @return string
     * @throws \InvalidArgumentException
     */
    public function buildPathToLocaleDirectoryByContext($type, $value)
    {
        switch ($type) {
            case self::CONTEXT_TYPE_MODULE:
                $path = $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, $value);
                break;
            case self::CONTEXT_TYPE_THEME:
                $path = $this->componentRegistrar->getPath(ComponentRegistrar::THEME, $value);
                break;
            case self::CONTEXT_TYPE_LIB:
                $path = BP . '/lib/web';
                break;
            default:
                throw new \InvalidArgumentException(sprintf('Invalid context given: "%s".', $type));
        }
        return $path . '/' . self::LOCALE_DIRECTORY . '/';
    }

In this case we're always hitting the first case, so looking further into componentRegistrar->getPath(), we have vendor/magento/framework/Component/ComponentRegistrar.php:72:

    public function getPath($type, $componentName)
    {
        self::validateType($type);
        return isset(self::$paths[$type][$componentName]) ? self::$paths[$type][$componentName] : null;
    }

which suggests that the modules have not been registered by calling the register() method.

@NadiyaS
Copy link
Contributor

NadiyaS commented Aug 30, 2016

Hi @thomvanderboon , @biojppm ,
thank you for reporting this issue. Internal tiket MAGETWO-57820 was created.

@NadiyaS NadiyaS removed their assignment Aug 30, 2016
@NadiyaS NadiyaS added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Aug 30, 2016
@piotrekkaminski
Copy link
Contributor

Increased priority as it is a blocker for translations.

@biojppm
Copy link

biojppm commented Sep 14, 2016

@piotrekkaminski ping
is there an ETA for this? or a quick fix which I can apply on my side?

mmansoor-magento pushed a commit that referenced this issue Sep 23, 2016
Fixed issues:
* MAGETWO-57820: [GITHUB] php bin/magento i18n:pack creates unwanted dir #6260
Bug - P1
* MAGETWO-58337: [Github] Duplicated & missing product rows in system product export #4531
* MAGETWO-58289: [Github] Product URL Key not automatically generating during import #5128
* MAGETWO-58134: [GitHub] Products became “out of stock” after update from 2.0.7 to 2.1.0 #5222
* MAGETWO-58132: [GitHub] module:uninstall can remove code it uses itself #5797
* MAGETWO-58236: Sync requirements of composer.json of Sample-data with mainline
@Ctucker9233
Copy link

I'd like to know if there is an ETA on delivering this in a patch, or how I should apply it if I need it now. Thanks.

@afavata
Copy link

afavata commented Oct 17, 2016

any news on this issue????

@NadiyaS
Copy link
Contributor

NadiyaS commented Oct 17, 2016

Hi,
this issue was fixed and delivered to develop branch. See commits cc5cd56, cd5bb2d.
The issue is closed as resolved.

@NadiyaS NadiyaS closed this as completed Oct 17, 2016
@Ctucker9233
Copy link

@NadiyaS do these commits work for 2.1.2 or is there a port coming?

@NadiyaS
Copy link
Contributor

NadiyaS commented Oct 19, 2016

Hi @Ctucker9233 ,
these commits are not in 2.1.2. But the fix is planned to be in 2.1.x. I do not know concrete version right now.

@afavata
Copy link

afavata commented Oct 20, 2016

Hi @NadiyaS
this issue is affecting many people wordwide... non permitting to be online in the proprer local language.
Is it possible to request a very urgent release for 2.1.2 to resolve this issue.
thanks

Alex

@NadiyaS
Copy link
Contributor

NadiyaS commented Oct 21, 2016

Hi @afavata ,
if this issue is very critical for you, you can use our fix for now (see commits cc5cd56 and cd5bb2d, so you need to do changes in 2 files: vendor/magento/magento2-base/setup/src/Magento/Setup/Module/I18n/Context.php and vendor/magento/magento2-base/setup/src/Magento/Setup/Module/I18n/Pack/Writer/File/AbstractFile.php).
The priority of this issue was estimated as very high, so we can expect this fix in one of the next port for 2.1 version.

@afavata
Copy link

afavata commented Oct 21, 2016

Hi @NadiyaS
thank you for your quick reply. I followed your suggestion changing the two files as follow:
I have copied the whole content of file Context.php and AbstractFile.php both at version cd5bb2d on Sep 7 and pasted respectively in

vendor/magento/magento2-base/setup/src/Magento/Setup/Module/I18n/Context.php
and 
vendor/magento/magento2-base/setup/src/Magento/Setup/Module/I18n/Pack/Writer/File/AbstractFile.php.

Then I submitted the command:
bin/magento i18n:pack -m replace -d source_it_IT.csv it_IT

Result... a folder i18n was created in the system root / with inside it_IT.csv. Obviously this is not what expected from the above procedure.

Any other suggestions? Thank you

Alex

@slackerzz
Copy link
Member

any news?

@afavata
Copy link

afavata commented Nov 29, 2016

Not yet!!!.....

@Ctucker9233
Copy link

Any chance the fix will be in 2.1.3?

@siliconalchemy
Copy link

"The priority of this issue was estimated as very high, so we can expect this fix in one of the next port for 2.1 version."

6 months later and several point releases later and this fix still isn't place. Guess the priority isn't that high..

@thomvanderboon
Copy link
Author

There is a workarround for this issue. Create the languagepack and keep the translation in one file

#2951 (comment)

Thom

@michel334
Copy link

this issue seems to be still present in 2.1.7 is there an ETA on the release?

@davidalger
Copy link
Member

@michel334 Fixed on develop means it will be included in the next feature release. I.e. Magento 2.2 should have the fix. If there are fixes you would like to see back ported to 2.1 (i.e. where Magento only fixes on develop), feel free to back port the fix and submit a PR to the 2.1-develop branch.

@korostii
Copy link
Contributor

korostii commented Jun 20, 2017

@davidalger, your answer raises yet another question: what's the ETA on the release of 2.2? :)

@michel334
Copy link

@davidalger thanks, live will be good in 2.2 :)

@rodrigowebjump
Copy link
Member

This issue is also generated when you use an invalid translate context or left an empty space after context

"Customer not found! Verify your data","Cliente no encontrado! Verifique sus datos",module,Webjump_FirstAccess <-- space

magento-team pushed a commit that referenced this issue Sep 27, 2017
magento-team pushed a commit that referenced this issue Sep 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Setup Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests