3
  • I am working with Magento version 2.0.7. I set up the de_DE.csv file in my own theme and put all the translation text for email into this CSV file.

  • However, when I try to create a new order and receive an email. The order email is always in English text.

  • Other emails (new account, forgot password ..) are still in correct German text.

Does anyone have the same problem like me and already found the solution. Can you give some advises?

1
  • Did you find any solution to this? Thanks in advance.
    – Fancyman
    Apr 30, 2017 at 19:41

3 Answers 3

5

When an email is sent via cron or from CLI - need to make sure that the Translate Area Part is loaded. For me the following piece of code has helped (I used it right before the email message template content is prepared):

//do not use object manager directly. this is only for the demonstrating purpose.
$o = \Magento\Framework\App\ObjectManager::getInstance();

/** @var \Magento\Framework\App\AreaList $areaList */
$areaList = $o->get(\Magento\Framework\App\AreaList::class);
$areaList->getArea(\Magento\Framework\App\Area::AREA_FRONTEND)
        ->load(\Magento\Framework\App\Area::PART_TRANSLATE);`
3

This seems to be a Magento 2 bug, we have experienced a lot of localization issue in Magento 2. Especially for translating inside Javascript components and inside e-mails. Even if you do the correct thing according to documentation it often doesn't work. Please say if {{ trans }} worked for you.

Other options are:

  • Translating strings in theme and in language packages
  • Make sure you clean all caches and rebuild everything
  • Creating email templates that doesn't use localization features

To install language-pack do this:

  • curl -o source_de_DE.csv http://107.170.242.99/var/Head/source_de_DE.csv
  • bin/magento i18n:pack -m replace -d source_de_DE.csv de_DE (I need to run this as root and then run permissions scripts to fix permissions again)

This is my permissions script that I run as root inside magento 2 root folder: (replace MY_WEB_SERVER_USER with your value)

#!/usr/bin/env bash
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
find ./var -type d -exec chmod 777 {} \;
find ./pub/media -type d -exec chmod 777 {} \;
find ./pub/static -type d -exec chmod 777 {} \;
chmod 777 ./app/etc
chmod 644 ./app/etc/*.xml
chown -R :MY_WEB_SERVER_USER .
chmod u+x bin/magento

Make sure you have executed this before testing:

  • bin/magento setup:static-content:deploy -l de_DE (or your language)
  • bin/magento indexer:reindex
  • bin/magento cache:clean
  • bin/magento cache:flush
  • Restart cache systems like Varnish and Redis
0

I'm not sure about your email string. However, the string should be inside {{trans}} directive.

For example:

{{trans "Thank you for your order from %store_name." store_name=$store.getFrontendName()}}

Read more: http://devdocs.magento.com/guides/v2.1/frontend-dev-guide/templates/template-email.html#localization

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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