From 27df6a2b88557718c440ae1d2b360631dc592928 Mon Sep 17 00:00:00 2001 From: "florian.azizian" <florian.azizian@maarch.org> Date: Thu, 12 Sep 2019 15:56:06 +0100 Subject: [PATCH] FEAT #11487 TIME 3 custom front label v2 --- src/core/controllers/CoreController.php | 9 +++++---- src/core/models/CoreConfigModel.php | 17 ++++++++++++++++- src/frontend/app/translate.component.ts | 4 ++++ src/frontend/lang/lang-en.ts | 20 ++++++++++---------- src/frontend/lang/lang-fr.ts | 20 ++++++++++---------- src/frontend/lang/lang-nl.ts | 6 +++--- 6 files changed, 48 insertions(+), 28 deletions(-) diff --git a/src/core/controllers/CoreController.php b/src/core/controllers/CoreController.php index 2b62830883f..38ace5ddefe 100755 --- a/src/core/controllers/CoreController.php +++ b/src/core/controllers/CoreController.php @@ -29,11 +29,12 @@ class CoreController public function initialize(Request $request, Response $response) { $aInit = []; - $aInit['coreUrl'] = str_replace('rest/', '', \Url::coreurl()); - $aInit['applicationName'] = CoreConfigModel::getApplicationName(); + $aInit['coreUrl'] = str_replace('rest/', '', \Url::coreurl()); + $aInit['applicationName'] = CoreConfigModel::getApplicationName(); $aInit['applicationVersion'] = CoreConfigModel::getApplicationVersion(); - $aInit['lang'] = CoreConfigModel::getLanguage(); - $aInit['user'] = UserModel::getByLogin(['login' => $GLOBALS['userId'], 'select' => ['id', 'user_id', 'firstname', 'lastname']]); + $aInit['lang'] = CoreConfigModel::getLanguage(); + $aInit['user'] = UserModel::getByLogin(['login' => $GLOBALS['userId'], 'select' => ['id', 'user_id', 'firstname', 'lastname']]); + $aInit['customLanguage'] = CoreConfigModel::getCustomLanguage(['lang' => $aInit['lang']]); $aInit['scriptsToinject'] = []; $aInit['scriptsInjected'] = []; diff --git a/src/core/models/CoreConfigModel.php b/src/core/models/CoreConfigModel.php index e0ad1fe4786..299c1ce9b51 100755 --- a/src/core/models/CoreConfigModel.php +++ b/src/core/models/CoreConfigModel.php @@ -106,6 +106,21 @@ class CoreConfigModel return 'en'; } + public static function getCustomLanguage($aArgs = []) + { + $customId = CoreConfigModel::getCustomId(); + if (file_exists('custom/' . $customId . '/lang/lang-'.$aArgs['lang'].'.ts')) { + $fileContent = file_get_contents('custom/' . $customId . '/lang/lang-'.$aArgs['lang'].'.ts'); + $fileContent = str_replace("\n", "", $fileContent); + + $strpos = strpos($fileContent, "="); + $substr = substr(trim($fileContent), $strpos + 2, -1); + return json_decode($substr); + } + + return ''; + } + /** * Get the timezone * @@ -204,7 +219,7 @@ class CoreConfigModel { ValidatorModel::stringType($aArgs, ['customId']); - $customId = CoreConfigModel::getCustomId(); + $customId = CoreConfigModel::getCustomId(); if (empty($aArgs['customId'])) { } else { $customId = $aArgs['customId']; diff --git a/src/frontend/app/translate.component.ts b/src/frontend/app/translate.component.ts index c9d860571b3..c9df5cd26aa 100755 --- a/src/frontend/app/translate.component.ts +++ b/src/frontend/app/translate.component.ts @@ -13,4 +13,8 @@ if (angularGlobals.lang == "en") { dictionary = LANG_NL; } +if (angularGlobals.customLanguage != null) { + dictionary = {...dictionary, ...angularGlobals.customLanguage}; +} + export const LANG = dictionary; \ No newline at end of file diff --git a/src/frontend/lang/lang-en.ts b/src/frontend/lang/lang-en.ts index aae78a9b034..d14206164bf 100755 --- a/src/frontend/lang/lang-en.ts +++ b/src/frontend/lang/lang-en.ts @@ -1,14 +1,14 @@ export const LANG_EN = { - 'actives' : 'Active(s)', - 'ARsimple' : 'AR simple', - 'ARsva' : 'AR SVA', - 'ARsvr' : 'AR SVR', - 'contactsGroups' : 'Contact(s) group(s)', - 'inactives' : 'Inactive(s)', - 'myContactsGroups' : 'My contacts groups', - 'myContactsGroupsDesc' : 'Manage my contacts lists', - 'quota' : 'Quota', - 'quotaExceeded' : 'Quota exceeded', + "actives" : "Active(s)", + "ARsimple" : "AR simple", + "ARsva" : "AR SVA", + "ARsvr" : "AR SVR", + "contactsGroups" : "Contact(s) group(s)", + "inactives" : "Inactive(s)", + "myContactsGroups" : "My contacts groups", + "myContactsGroupsDesc" : "Manage my contacts lists", + "quota" : "Quota", + "quotaExceeded" : "Quota exceeded", "aboutUs" : "About Maarch Courrier", "abs" : "Absent", "makeUpdate" : "Update", diff --git a/src/frontend/lang/lang-fr.ts b/src/frontend/lang/lang-fr.ts index e5ea87d078e..0628cb7dfda 100755 --- a/src/frontend/lang/lang-fr.ts +++ b/src/frontend/lang/lang-fr.ts @@ -1,14 +1,14 @@ export const LANG_FR = { - 'actives' : 'Actif(s)', - 'ARsimple' : 'AR simple', - 'ARsva' : 'AR SVA', - 'ARsvr' : 'AR SVR', - 'contactsGroups' : 'Groupement(s) de contact(s)', - 'inactives' : 'Inactif(s)', - 'myContactsGroups' : 'Mes groupements de contacts', - 'myContactsGroupsDesc' : 'Gérer mes listes de contacts', - 'quota' : 'Quota', - 'quotaExceeded' : 'Quota dépassé', + "actives" : "Actif(s)", + "ARsimple" : "AR simple", + "ARsva" : "AR SVA", + "ARsvr" : "AR SVR", + "contactsGroups" : "Groupement(s) de contact(s)", + "inactives" : "Inactif(s)", + "myContactsGroups" : "Mes groupements de contacts", + "myContactsGroupsDesc" : "Gérer mes listes de contacts", + "quota" : "Quota", + "quotaExceeded" : "Quota dépassé", "aboutUs" : "A propos de Maarch Courrier", "abs" : "Absent", "absOff" : "Absence désactivée", diff --git a/src/frontend/lang/lang-nl.ts b/src/frontend/lang/lang-nl.ts index 613e4c2bf8a..d3cf727d3aa 100755 --- a/src/frontend/lang/lang-nl.ts +++ b/src/frontend/lang/lang-nl.ts @@ -1,7 +1,7 @@ export const LANG_NL = { - 'ARsimple' : 'AR simple', //_TO_TRANSLATE - 'ARsva' : 'AR SVA', //_TO_TRANSLATE - 'ARsvr' : 'AR SVR', //_TO_TRANSLATE + "ARsimple" : "AR simple", //_TO_TRANSLATE + "ARsva" : "AR SVA", //_TO_TRANSLATE + "ARsvr" : "AR SVR", //_TO_TRANSLATE "aboutUs" : "Over Maarch Courrier", "abs" : "Afwezig", "absOff" : "Afwezigheid uitgeschakeld", -- GitLab