Skip to content

Commit

Permalink
Merge branch '1.0' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanjeev Papnoi committed Mar 17, 2020
2 parents 0a5219f + 5db9b17 commit 1ad09a7
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 43 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG-1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ CHANGELOG for 1.0.x

This changelog references any relevant changes introduced in 1.0 minor versions.

* 1.0.6 (2020-03-17)
* **Misc. Updates:**
* Added Missing Translations.

* 1.0.5 (2020-02-12)
* **Misc. Updates:**
* Included Github issue templates.
Expand Down
5 changes: 3 additions & 2 deletions Controller/MailboxChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function createMailboxConfiguration(Request $request)

file_put_contents($mailboxService->getPathToConfigurationFile(), (string) $mailboxConfiguration);

$this->addFlash('success', 'Mailbox successfully created.');
$this->addFlash('success', $this->get('translator')->trans('Mailbox successfully created.'));
return new RedirectResponse($this->generateUrl('helpdesk_member_mailbox_settings'));
}
}
Expand Down Expand Up @@ -129,7 +129,8 @@ public function updateMailboxConfiguration($id, Request $request)

file_put_contents($mailboxService->getPathToConfigurationFile(), (string) $mailboxConfiguration);

$this->addFlash('success', 'Mailbox successfully updated.');
$this->addFlash('success', $this->get('translator')->trans('Mailbox successfully updated.'));

return new RedirectResponse($this->generateUrl('helpdesk_member_mailbox_settings'));
}
}
Expand Down
2 changes: 1 addition & 1 deletion Controller/MailboxChannelXHR.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function removeMailboxConfiguration($id, Request $request)

return new JsonResponse([
'alertClass' => 'success',
'alertMessage' => 'Mailbox configuration removed successfully.',
'alertMessage' => $this->get('translator')->trans('Mailbox configuration removed successfully.'),
]);
}
}
4 changes: 2 additions & 2 deletions Resources/views/listConfigurations.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@
<div class="uv-view {% if app.request.cookies and app.request.cookies.get('uv-asideView') %}uv-aside-view{% endif %}">
<div class="uv-action-bar">
<div class="uv-action-bar-col-lt" style="vertical-align: middle;">
<h1>Mailbox Settings</h1>
<h1>{{ 'Mailbox Settings'|trans }}</h1>
</div>

<div class="uv-action-bar-col-rt" style="vertical-align: middle;">
<a href="{{ path('helpdesk_member_mailbox_create_configuration') }}" type="button" class="uv-btn-action" style="margin: unset;">New Mailbox</a>
<a href="{{ path('helpdesk_member_mailbox_create_configuration') }}" type="button" class="uv-btn-action" style="margin: unset;">{{ 'New Mailbox'|trans }}</a>
</div>
</div>

Expand Down
70 changes: 35 additions & 35 deletions Resources/views/manageConfigurations.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -34,36 +34,36 @@

<div class="uv-view {% if app.request.cookies and app.request.cookies.get('uv-asideView') %}uv-aside-view{% endif %}">
{% if mailbox is defined and mailbox.id is not empty %}
<h1>Update Mailbox</h1>
<h1>{{ 'Update Mailbox'|trans }}</h1>
{% else %}
<h1>New Mailbox</h1>
<h1>{{ 'Add Mailbox'|trans }}</h1>
{% endif %}

<div class="uv-hr"></div>

<form method="post" action="" id="mailbox-settings-view">
{# Mailer Id #}
<div class="uv-element-block">
<label class="uv-field-label">ID:</label>
<label class="uv-field-label">{{ 'ID'|trans }}</label>

<div class="uv-field-block">
{% if mailbox is defined and mailbox.id is not empty %}
<input type="text" name="id" class="uv-field" value="{{ mailbox.id }}" placeholder="Mailbox ID - Leave blank to automatically create id" />
<input type="text" name="id" class="uv-field" value="{{ mailbox.id }}" placeholder="{{ 'Mailbox ID - Leave blank to automatically create id'|trans }}" />
{% else %}
<input type="text" name="id" class="uv-field" value="" placeholder="Mailbox ID - Leave blank to automatically create id" />
<input type="text" name="id" class="uv-field" value="" placeholder="{{ 'Mailbox ID - Leave blank to automatically create id'|trans }}" />
{% endif %}
</div>
</div>

{# Mailer Name #}
<div class="uv-element-block">
<label class="uv-field-label">Name:</label>
<label class="uv-field-label">{{ 'Name'|trans }}</label>

<div class="uv-field-block">
{% if mailbox is defined and mailbox.name is not empty %}
<input type="text" name="name" class="uv-field" value="{{ mailbox.name }}" placeholder="Mailbox Name" />
<input type="text" name="name" class="uv-field" value="{{ mailbox.name }}" placeholder="{{ 'Mailbox Name'|trans }}" />
{% else %}
<input type="text" name="name" class="uv-field" value="" placeholder="Mailbox Name" />
<input type="text" name="name" class="uv-field" value="" placeholder="{{ 'Mailbox Name'|trans }}" />
{% endif %}
</div>
</div>
Expand All @@ -81,30 +81,30 @@
<span class="uv-checkbox-view"></span>
</div>

<span class="uv-checkbox-label">Enable Mailbox</span>
<span class="uv-checkbox-label">{{ 'Enable Mailbox'|trans }}</span>
</label>
</div>

<div class="uv-hr"></div>

{# IMAP Settings #}
<h3 class="section-heading">Incoming Mail (IMAP) Server</h3>
<p class="section-description">Configure your imap settings which will be used to fetch emails from your mailbox.</p>
<h3 class="section-heading">{{ 'Incoming Mail (IMAP) Server'|trans }}</h3>
<p class="section-description">{{ 'Configure your imap settings which will be used to fetch emails from your mailbox.'|trans }}</p>

<div class="uv-element-block">
<label class="uv-field-label">Transport:</label>
<label class="uv-field-label">{{ 'Transport'|trans }}</label>

{% if mailbox is defined %}
<select name="imap[transport]" id="cta-mailbox-imap-transport" class="uv-select">
<option value="custom" {% if mailbox.imapConfiguration.code == 'custom' %}selected{% endif %}>IMAP</option>
<option value="gmail" {% if mailbox.imapConfiguration.code == 'gmail' %}selected{% endif %}>Gmail</option>
<option value="yahoo" {% if mailbox.imapConfiguration.code == 'yahoo' %}selected{% endif %}>Yahoo Mail</option>
<option value="custom" {% if mailbox.imapConfiguration.code == 'custom' %}selected{% endif %}>{{ 'IMAP'|trans }}</option>
<option value="gmail" {% if mailbox.imapConfiguration.code == 'gmail' %}selected{% endif %}>{{ 'Gmail'|trans }}</option>
<option value="yahoo" {% if mailbox.imapConfiguration.code == 'yahoo' %}selected{% endif %}>{{ 'Yahoo'|trans }}</option>
</select>
{% else %}
<select name="imap[transport]" id="cta-mailbox-imap-transport" class="uv-select">
<option value="custom" selected>IMAP</option>
<option value="gmail">Gmail</option>
<option value="yahoo">Yahoo</option>
<option value="custom" selected>{{ 'IMAP'|trans }}</option>
<option value="gmail">{{ 'Gmail'|trans }}</option>
<option value="yahoo">{{ 'Yahoo'|trans }}</option>
</select>
{% endif %}
</div>
Expand All @@ -114,15 +114,15 @@
<div class="uv-hr"></div>

{# SwiftMailer Settings #}
<h3 class="section-heading">Outgoing Mail (SMTP) Server</h3>
<p class="section-description">Select a valid Swift Mailer configuration which will be used to send emails through your mailbox.</p>
<h3 class="section-heading">{{ 'Outgoing Mail (SMTP) Server'|trans }}</h3>
<p class="section-description">{{ 'Select a valid Swift Mailer configuration which will be used to send emails through your mailbox.'|trans }}</p>

<div class="uv-element-block">
<label class="uv-field-label">Swift Mailer ID:</label>
<label class="uv-field-label">{{ 'Swift Mailer ID'|trans }}</label>

{% if swiftmailerConfigurations is defined and swiftmailerConfigurations is not empty %}
<select name="swiftmailer_id" class="uv-select">
<option value="none">None Selected</option>
<option value="none">{{ 'None Selected'|trans }}</option>
{% for configuration in swiftmailerConfigurations %}
{% if mailbox is defined and mailbox.swiftmailerConfiguration and mailbox.swiftmailerConfiguration.id == configuration.id %}
<option value="{{ configuration.id }}" selected>{{ configuration.id }}</option>
Expand All @@ -133,7 +133,7 @@
</select>
{% else %}
<select name="swiftmailer_id" class="uv-select">
<option value="none">None Selected</option>
<option value="none">{{ 'None Selected'|trans }}</option>
</select>
{% endif %}
</div>
Expand All @@ -155,56 +155,56 @@

<script id="imap_conf_template_predefined" type="text/template">
<div class="uv-element-block">
<label class="uv-field-label">Username:</label>
<label class="uv-field-label">{{ 'Username' |trans }}</label>
<div class="uv-field-block">
<% if (typeof(username) != 'undefined' && username != '') { %>
<input class="uv-field" type="text" name="imap[username]" value="<%- username %>" placeholder="Email address">
<input class="uv-field" type="text" name="imap[username]" value="<%- username %>" placeholder="{{ 'Email address'|trans }}">
<% } else { %>
<input class="uv-field" type="text" name="imap[username]" value="" placeholder="Email address">
<input class="uv-field" type="text" name="imap[username]" value="" placeholder="{{ 'Email address'|trans }}">
<% } %>
</div>
</div>
<div class="uv-element-block">
<label class="uv-field-label">Password:</label>
<label class="uv-field-label">{{ 'Password' |trans }}</label>
<div class="uv-field-block">
<input class="uv-field" type="password" name="imap[password]" placeholder="Associated Password">
<input class="uv-field" type="password" name="imap[password]" placeholder="{{ 'Associated Password'|trans }}">
</div>
</div>
</script>

<script id="imap_conf_template_custom" type="text/template">
<div class="uv-element-block">
<label class="uv-field-label">Host:</label>
<label class="uv-field-label">{{ 'Host'|trans }}</label>
<div class="uv-field-block">
<% if (typeof(host) != 'undefined' && host != '') { %>
<input class="uv-field" type="text" name="imap[host]" value="<%- host %>" placeholder="<%- host %>">
<% } else { %>
<input class="uv-field" type="text" name="imap[host]" value="" placeholder="IMAP Host">
<input class="uv-field" type="text" name="imap[host]" value="" placeholder="{{'IMAP Host'|trans }}">
<% } %>
</div>
</div>
<div class="uv-element-block">
<label class="uv-field-label">Email:</label>
<label class="uv-field-label">{{ 'Email'|trans }}</label>
<div class="uv-field-block">
<% if (typeof(username) != 'undefined' && username != '') { %>
<input class="uv-field" type="text" name="imap[username]" value="<%- username %>" placeholder="Email address">
<input class="uv-field" type="text" name="imap[username]" value="<%- username %>" placeholder="{{'Email address'|trans }}">
<% } else { %>
<input class="uv-field" type="text" name="imap[username]" value="" placeholder="Email address">
<input class="uv-field" type="text" name="imap[username]" value="" placeholder="{{'Email address'|trans }}">
<% } %>
</div>
</div>
<div class="uv-element-block">
<label class="uv-field-label">Password:</label>
<label class="uv-field-label">{{'Password'|trans }}</label>
<div class="uv-field-block">
<input class="uv-field" type="password" name="imap[password]" placeholder="Associated Password">
<input class="uv-field" type="password" name="imap[password]" placeholder="{{'Associated Password'|trans }}">
</div>
</div>
</script>
Expand Down
2 changes: 1 addition & 1 deletion UIComponents/Dashboard/Homepage/Items/Mailbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static function getIcon() : string

public static function getTitle() : string
{
return "Mailbox";
return self::dynamicTranslation("Mailbox");
}

public static function getRouteName() : string
Expand Down
51 changes: 50 additions & 1 deletion UIComponents/Dashboard/Search/Mailbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
namespace Webkul\UVDesk\MailboxBundle\UIComponents\Dashboard\Search;

use Webkul\UVDesk\CoreFrameworkBundle\Dashboard\Segments\SearchItemInterface;
use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation\Loader\YamlFileLoader;
use Symfony\Component\HttpFoundation\Request;

class Mailbox implements SearchItemInterface
{
Expand All @@ -19,7 +22,7 @@ public static function getIcon() : string

public static function getTitle() : string
{
return "Mailbox";
return self::dynamicTranslation("Mailbox");
}

public static function getRouteName() : string
Expand All @@ -31,4 +34,50 @@ public function getChildrenRoutes() : array
{
return [];
}

public static function dynamicTranslation($data) : string
{
$request = Request::createFromGlobals();
$path = $request->getPathInfo();
$locale = explode("/", $path);
$translator = new Translator($locale[1]);

switch($locale[1])
{
case 'en':
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource('yaml',__DIR__."/../../../../../../translations/messages.en.yml", 'en');
break;
case 'es':
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource('yaml',__DIR__."/../../../../../../translations/messages.es.yml", 'es');
break;
case 'fr':
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource('yaml',__DIR__."/../../../../../../translations/messages.fr.yml", 'fr');
break;
case 'da':
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource('yaml',__DIR__."/../../../../../../translations/messages.da.yml", 'da');
break;
case 'de':
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource('yaml',__DIR__."/../../../../../../translations/messages.de.yml", 'de');
break;
case 'it':
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource('yaml',__DIR__."/../../../../../../translations/messages.it.yml", 'it');
break;
case 'ar':
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource('yaml',__DIR__."/../../../../../../translations/messages.ar.yml", 'ar');
break;
case 'tr':
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource('yaml',__DIR__."/../../../../../../translations/messages.tr.yml", 'tr');
break;
}

return $translator->trans($data);
}
}
51 changes: 50 additions & 1 deletion UIComponents/Dashboard/Search/SwiftMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
namespace Webkul\UVDesk\MailboxBundle\UIComponents\Dashboard\Search;

use Webkul\UVDesk\CoreFrameworkBundle\Dashboard\Segments\SearchItemInterface;
use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation\Loader\YamlFileLoader;
use Symfony\Component\HttpFoundation\Request;

class SwiftMailer implements SearchItemInterface
{
Expand All @@ -19,7 +22,7 @@ public static function getIcon() : string

public static function getTitle() : string
{
return "SwiftMailer";
return self::dynamicTranslation("SwiftMailer");
}

public static function getRouteName() : string
Expand All @@ -31,4 +34,50 @@ public function getChildrenRoutes() : array
{
return [];
}

public static function dynamicTranslation($data) : string
{
$request = Request::createFromGlobals();
$path = $request->getPathInfo();
$locale = explode("/", $path);
$translator = new Translator($locale[1]);

switch($locale[1])
{
case 'en':
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource('yaml',__DIR__."/../../../../../../translations/messages.en.yml", 'en');
break;
case 'es':
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource('yaml',__DIR__."/../../../../../../translations/messages.es.yml", 'es');
break;
case 'fr':
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource('yaml',__DIR__."/../../../../../../translations/messages.fr.yml", 'fr');
break;
case 'da':
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource('yaml',__DIR__."/../../../../../../translations/messages.da.yml", 'da');
break;
case 'de':
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource('yaml',__DIR__."/../../../../../../translations/messages.de.yml", 'de');
break;
case 'it':
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource('yaml',__DIR__."/../../../../../../translations/messages.it.yml", 'it');
break;
case 'ar':
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource('yaml',__DIR__."/../../../../../../translations/messages.ar.yml", 'ar');
break;
case 'tr':
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource('yaml',__DIR__."/../../../../../../translations/messages.tr.yml", 'tr');
break;
}

return $translator->trans($data);
}
}

0 comments on commit 1ad09a7

Please sign in to comment.