Skip to content

Commit

Permalink
Updated mail templates for OC v3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-vince committed Mar 7, 2024
1 parent b5f3286 commit 5970073
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 56 deletions.
109 changes: 54 additions & 55 deletions models/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,91 +367,90 @@ public static function getEnabledLocales() {
*/
public static function getTranslatedTemplates($defaultLocale = 'en', $locale = NULL, $templateType = NULL) {

$enabledLocales = Settings::getEnabledLocales();
$enabledLocales = Settings::getEnabledLocales();

/**
* Templates map
* [locale] => [templateType] => [template]
*/
$translatedTemplates = [
/**
* Templates map
* [locale] => [templateType] => [template]
*/
$translatedTemplates = [

'en' => [
'en' => [

'autoreply' => [
'janvince.smallcontactform::mail.autoreply' => 'janvince.smallcontactform::lang.mail.templates.autoreply',
],
'autoreply' => [
'janvince.smallcontactform::mail.autoreply',
],

'notification' => [
'janvince.smallcontactform::mail.notification' => 'janvince.smallcontactform::lang.mail.templates.notification',
],
'notification' => [
'janvince.smallcontactform::mail.notification',
],

],
],

'cs' => [
'cs' => [

'autoreply' => [
'janvince.smallcontactform::mail.autoreply_cs' => 'janvince.smallcontactform::lang.mail.templates.autoreply_cs',
],
'autoreply' => [
'janvince.smallcontactform::mail.autoreply_cs',
],

'notification' => [
'janvince.smallcontactform::mail.notification_cs' => 'janvince.smallcontactform::lang.mail.templates.notification_cs',
],
'notification' => [
'janvince.smallcontactform::mail.notification_cs',
],

],
],

'es' => [
'es' => [

'autoreply' => [
'janvince.smallcontactform::mail.autoreply_es' => 'janvince.smallcontactform::lang.mail.templates.autoreply_es',
],
'autoreply' => [
'janvince.smallcontactform::mail.autoreply_es',
],

'notification' => [
'janvince.smallcontactform::mail.notification_es' => 'janvince.smallcontactform::lang.mail.templates.notification_es',
],
'notification' => [
'janvince.smallcontactform::mail.notification_es',
],

],

];

if( $locale and $templateType ) {

if( !empty($translatedTemplates[$locale]) and !empty($translatedTemplates[$locale][$templateType]) ) {
return key($translatedTemplates[$locale][$templateType]);
} elseif ( $defaultLocale and !empty($translatedTemplates[$defaultLocale]) and !empty($translatedTemplates[$defaultLocale][$templateType]) ) {
return key($translatedTemplates[$defaultLocale][$templateType]);
} else {
return NULL;
}
],

];

if( $locale and $templateType ) {

if( !empty($translatedTemplates[$locale]) and !empty($translatedTemplates[$locale][$templateType]) ) {
return array_shift($translatedTemplates[$locale][$templateType]);
} elseif ( $defaultLocale and !empty($translatedTemplates[$defaultLocale]) and !empty($translatedTemplates[$defaultLocale][$templateType]) ) {
return array_shift($translatedTemplates[$defaultLocale][$templateType]);
} else {
return NULL;
}

} else {

$allEnabledTemplates = [];
$allEnabledTemplates = [];

foreach( $enabledLocales as $enabledLocaleKey => $enabledLocaleName ) {
foreach( $enabledLocales as $enabledLocaleKey => $enabledLocaleName ) {

if( !empty($translatedTemplates[$enabledLocaleKey]) ) {
if( !empty($translatedTemplates[$enabledLocaleKey]) ) {

foreach( $translatedTemplates[$enabledLocaleKey] as $type ) {
foreach( $translatedTemplates[$enabledLocaleKey] as $type ) {

foreach( $type as $key => $value ) {
$allEnabledTemplates[$key] = e(trans($value));
foreach( $type as $key => $value ) {

}
$allEnabledTemplates[] = e(trans($value));

}
}

}

}
}

return $allEnabledTemplates;
}

}
return $allEnabledTemplates;

return [];
}

}
return [];

}

}
4 changes: 3 additions & 1 deletion updates/version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -319,4 +319,6 @@
1.66.2:
- Added snippetAjax option (thanks @DenSit-be)
1.66.3:
- Fixed passive antispam validation (thanks @Quendi6)
- Fixed passive antispam validation (thanks @Quendi6)
1.67.0:
- Updated mail templates for OC v3.6

0 comments on commit 5970073

Please sign in to comment.