Skip to content

Translations export error [DomainException] Missed Phrase #6498

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

Closed
elelabdev opened this issue Sep 5, 2016 · 13 comments
Closed

Translations export error [DomainException] Missed Phrase #6498

elelabdev opened this issue Sep 5, 2016 · 13 comments

Comments

@elelabdev
Copy link

Preconditions

  1. Magento 2.1.0

Steps to reproduce

  1. Login to SSH
  2. Switch to user who own Magento directory rights
  3. cd /var/html/magento/bin
  4. php magento i18n:collect-phrases -o "/var/html/magento/translation_export.csv" -m

Expected result

  1. Export the CSV file with English base translations to allow me to translate them in my own language.

Actual result

  1. DomainException Missed Phrase

Unfortunately is really hard from the output to understand what file is blocking the export, I have also checked the log folder (var/log) but there is no trace of this error.

screen shot 2016-09-05 at 16 10 22

@sevos1984
Copy link
Contributor

I'm getting 'Dictionary successfully processed.' on clean magento. Problem must be in your language pack. Try add '-vvv' option to see broken file.

@elelabdev
Copy link
Author

@sevos1984 thanks for the suggestion, I tried adding -vvv and this is the result

[DomainException]
Missed phrase

Exception trace:
() at /var/html/magento/setup/src/Magento/Setup/Module/I18n/Dictionary/Phrase.php:90
Magento\Setup\Module\I18n\Dictionary\Phrase->setPhrase() at /var/html/magento/setup/src/Magento/Setup/Module/I18n/Dictionary/Phrase.php:73
Magento\Setup\Module\I18n\Dictionary\Phrase->__construct() at /var/html/magento/setup/src/Magento/Setup/Module/I18n/Factory.php:69
Magento\Setup\Module\I18n\Factory->createPhrase() at /var/html/magento/setup/src/Magento/Setup/Module/I18n/Parser/Contextual.php:79
Magento\Setup\Module\I18n\Parser\Contextual->_addPhrase() at /var/html/magento/setup/src/Magento/Setup/Module/I18n/Parser/Contextual.php:51
Magento\Setup\Module\I18n\Parser\Contextual->_parseByTypeOptions() at /var/html/magento/setup/src/Magento/Setup/Module/I18n/Parser/AbstractParser.php:75
Magento\Setup\Module\I18n\Parser\AbstractParser->parse() at /var/html/magento/setup/src/Magento/Setup/Module/I18n/Dictionary/Generator.php:83
Magento\Setup\Module\I18n\Dictionary\Generator->generate() at /var/html/magento/setup/src/Magento/Setup/Console/Command/I18nCollectPhrasesCommand.php:77
Magento\Setup\Console\Command\I18nCollectPhrasesCommand->execute() at /var/html/magento/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:257
Symfony\Component\Console\Command\Command->run() at /var/html/magento/vendor/symfony/console/Symfony/Component/Console/Application.php:874
Symfony\Component\Console\Application->doRunCommand() at /var/html/magento/vendor/symfony/console/Symfony/Component/Console/Application.php:195
Symfony\Component\Console\Application->doRun() at /var/html/magento/vendor/magento/framework/Console/Cli.php:96
Magento\Framework\Console\Cli->doRun() at /var/html/magento/vendor/symfony/console/Symfony/Component/Console/Application.php:126
Symfony\Component\Console\Application->run() at /var/html/magento/bin/magento:23

i18n:collect-phrases [-o|--output="..."] [-m|--magento] [directory]

@sevos1984
Copy link
Contributor

I've recreated your issue, it occurs when you have empty strings for translation (e.g 'note' => __('')).

@elelabdev
Copy link
Author

Ah, so perhaps somewhere in the template I have empty translation strings? There is a command to output the file containing empty strings? Thanks

@sevos1984
Copy link
Contributor

sevos1984 commented Sep 6, 2016

Yes, check your templates. No there is no such command.

@elelabdev
Copy link
Author

@sevos1984 thank you very much for the suggestion infact there was a missing translation that I found, now the export works correctly, I close this post as solved.

@gediminaskv
Copy link

Hello, I have the same issue. Where I can find "empty strings" ? No translations where done, so, from where those empty strings come?
Anyway, it's quite a strange thing because very first time when I ran collect-phrases everything was fine, but now it shows "missed phrase"...

@benheart
Copy link

benheart commented Jun 22, 2017

@gediminaskv Maybe you can modify setup/src/Magento/Setup/Module/I18n/Dictionary/Phrase.php file, and comment the DomainException in setPhrase() and setTranslation() methods like this:

    public function setPhrase($phrase)
    {
        if (!$phrase) {
//            throw new \DomainException('Missed phrase');
            $this->_phrase = 'Missed phrase';
        } else {
            $this->_phrase = $phrase;
        }
    }
    public function setTranslation($translation)
    {
        if (!$translation) {
//            throw new \DomainException('Missed translation');
            $this->_translation = 'Missed translation';
        } else {
            $this->_translation = $translation;
        }
    }

And this will create .csv successfully, what's more, you can find the module of the "empty strings".

@nei
Copy link

nei commented Jul 25, 2017

__('0'); also fails.

@webspeaks
Copy link

Magento should be able to handle empty phrases. I dont understand why do they not handle such small things.
Such issues cause developers to loose many hours.

@TimQSO
Copy link

TimQSO commented Aug 20, 2018

Agreed with @webspeaks tranlating is already a pain in M2, this makes it even worse.

@TimQSO
Copy link

TimQSO commented Aug 20, 2018

Err I did not unassign @sevos1984 ?

@c1gee
Copy link

c1gee commented Jan 15, 2020

Yes, check your templates. No there is no such command.

There is no such command but there is a search that works

Run this in your root folder to find all of the missing / empty strings

grep -rnw . -e "__('')" -e '__("")'

I have used this successfully several times.

I also like to email the plugin providers to let them know when they have missed a couple.

magento-engcom-team pushed a commit that referenced this issue Jan 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants