<commit_before>Swiftmailer Translator
======================

Extend decorator plugin with option to modify subject and body with given translated templates

Installation
------------

Install via composer

```
composer require clippings/swiftmailer-translator
```

Usage
-----

 $users = [['email' => '<EMAIL>', 'firstName' => 'Иван', 'lastName' => 'Петров'],
           ['email' => '<EMAIL>', 'firstName' => 'Наташа', 'lastName' => 'Романова', 'lang' => 'ru'],
           ['email' => '<EMAIL>', 'firstName' => 'Jon', 'lastName' => 'Doe']];
 $replacements = [];
 
 foreach ($users as $user) {
     $replacements[$user['email']] = ['{FirstName}' => $user['firstName'], '{LastName}' => $user['lastName']];
        if (isset($user['lang'])){
            $replacements[$user['email']]['lang'] = $user['lang'];
            }
        }
        
 $translates = ['bg' => ['subject' => 'Важно съобщение за {FirstName} {LastName}',
                    'body'=>'Здравейте {FirstName}, искаме да ви се информираме за новия продукт който предлагаме'],
                'ru'=>['subject' => 'Важное сообщение {FirstName} {LastName}',
                    'body'=>'Здравствуйте {FirstName}, мы хотим получить информацию о новом продукте, который мы предлагаем.']];
                    
$transport = Swift_SmtpTransport::newInstance('smtp.example.com', 465, 'ssl')->setUsername('username')->setPassword('password');
$mailer = Swift_Mailer::newInstance($transport);
$decorator = new Swift_Plugins_TranslateDecoratorPlugin($translates, $replacements);
$mailer->registerPlugin($decorator);

$message = Swift_Message::newInstance()
	->setSubject('Important message for  {FirstName}')
	->setBody(
		'Hello {FirstName}, we want to  inform you about new product that we offer.');

$failedRecipients = [];
foreach ($users as $address => $name) {
	if (is_int($address)) {
		$message->setTo($name['email']);
	} else {
		$message->setTo(array($address['email'] => $name));
	}
	$mailer->send($message, $failedRecipients);
} 

License
-------

Copyright (c) 2016, root Developed by <NAME>

Under BSD-3-Clause license, read LICENSE file.<commit_msg>editing README.md<commit_after>Swiftmailer Translator
======================

Extend decorator plugin with option to modify subject and body with given translated templates

Installation
------------

Install via composer

```
composer require clippings/swiftmailer-translator
```

Usage
-----
<code>
 $users = [['email' => '<EMAIL>', 'firstName' => 'Иван', 'lastName' => 'Петров'],
           ['email' => '<EMAIL>', 'firstName' => 'Наташа', 'lastName' => 'Романова', 'lang' => 'ru'],
           ['email' => '<EMAIL>', 'firstName' => 'Jon', 'lastName' => 'Doe']];
 $replacements = [];
 
 foreach ($users as $user) {
     $replacements[$user['email']] = ['{FirstName}' => $user['firstName'], '{LastName}' => $user['lastName']];
        if (isset($user['lang'])){
            $replacements[$user['email']]['lang'] = $user['lang'];
            }
        }
        
 $translates = ['bg' => ['subject' => 'Важно съобщение за {FirstName} {LastName}',
                    'body'=>'Здравейте {FirstName}, искаме да ви се информираме за новия продукт който предлагаме'],
                'ru'=>['subject' => 'Важное сообщение {FirstName} {LastName}',
                    'body'=>'Здравствуйте {FirstName}, мы хотим получить информацию о новом продукте, который мы предлагаем.']];
                    
$transport = Swift_SmtpTransport::newInstance('smtp.example.com', 465, 'ssl')->setUsername('username')->setPassword('password');
$mailer = Swift_Mailer::newInstance($transport);
$decorator = new Swift_Plugins_TranslateDecoratorPlugin($translates, $replacements);
$mailer->registerPlugin($decorator);

$message = Swift_Message::newInstance()
	->setSubject('Important message for  {FirstName}')
	->setBody(
		'Hello {FirstName}, we want to  inform you about new product that we offer.');

$failedRecipients = [];
foreach ($users as $address => $name) {
	if (is_int($address)) {
		$message->setTo($name['email']);
	} else {
		$message->setTo(array($address['email'] => $name));
	}
	$mailer->send($message, $failedRecipients);
} 
</code>
License
-------

Copyright (c) 2016, root Developed by <NAME>

Under BSD-3-Clause license, read LICENSE file.
{'fraction_non_alphanumeric': 0.19995295224653023, 'fraction_numerical': 0.0037638202775817455, 'mean_word_length': 3.9906103286384975, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 69, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '579956', 'n_tokens_mistral': 1395, 'n_tokens_neox': 1382, 'n_words': 312}