oroinc / platform

Main OroPlatform package with core functionality.
Other
627 stars 351 forks source link

Add translatable email templates fixture #1023

Closed klas closed 4 years ago

klas commented 4 years ago

Add a missing functionality to load translated email templates.

Localizations are derived from the file names following localization .ini files convention template_name.locale_code.format e.g. customer_user_confirmation_email.en.html customer_user_confirmation_email.de_DE.html

Can be used in the same way as existing fixture to load templates from the directory e.g.

class DataFixtureEmails extends AbstractTranslatableEmailFixture implements VersionedFixtureInterface
{
    /**
     * {@inheritdoc}
     */
    public function getVersion()
    {
        return '1.1';
    }

    /**
     * {@inheritdoc}
     */
    public function getEmailsDir()
    {
        return $this->container
            ->get('kernel')
            ->locateResource('@SomeBundle/Migrations/Data/ORM/emails');
    }
}
mbessolov commented 4 years ago

@klas, thank you for the pull request.

Considering that this abstract fixture is not used anywhere in OroPlatform, it should be covered with automated tests, or else we won't be able to track if it works or breaks in the future versions.

This fixture seems to silently ignore templates for non-active localizations.

There also seems to be a problem with filenames that have more than 2 dots (e.g. some.custom.template.de_DE.html).

klas commented 4 years ago

As we are unable to invest more work time into this we are closing this pull request.