Translation updates and UI improvements

This commit is contained in:
gamonoid
2018-03-17 19:09:52 +01:00
parent a0d77cb944
commit afc069afaa
38 changed files with 11401 additions and 14426 deletions

View File

@@ -1008,6 +1008,7 @@ IceHRMBase.method('save', function(callGetFunction, successCallback) {
}else{ }else{
$("#"+this.getTableName()+'Form .label').html(msg); $("#"+this.getTableName()+'Form .label').html(msg);
$("#"+this.getTableName()+'Form .label').show(); $("#"+this.getTableName()+'Form .label').show();
this.scrollToTop();
} }
} }
@@ -2142,11 +2143,6 @@ IceHRMBase.method('renderFormField', function(field) {
t = t.replace(/_filetypes_/g,'all'); t = t.replace(/_filetypes_/g,'all');
} }
/*
if(object != null && object != undefined && object[field[0]] != null && object[field[0]] != undefined && object[field[0]] != ""){
t = t.replace(/_id___rand_/g,field[0]);
}
*/
t = t.replace(/_rand_/g,this.generateRandom(14)); t = t.replace(/_rand_/g,this.generateRandom(14));
}else if(field[1].type == 'datagroup'){ }else if(field[1].type == 'datagroup'){
@@ -2163,16 +2159,24 @@ IceHRMBase.method('renderFormField', function(field) {
} }
if(field[1].validation != undefined && field[1].validation != null && field[1].validation != ""){ if(field[1].validation != undefined && field[1].validation != null && field[1].validation != "") {
t = t.replace(/_validation_/g,'validation="'+field[1].validation+'"'); t = t.replace(/_validation_/g,'validation="'+field[1].validation+'"');
}else{ }else{
t = t.replace(/_validation_/g,''); t = t.replace(/_validation_/g,'');
} }
if(field[1].help != undefined || field[1].help != null){ if(field[1].help !== undefined && field[1].help !== null){
t = t.replace(/_helpline_/g,field[1].help); t = t.replace(/_helpline_/g,field[1].help);
t = t.replace(/_hidden_class_help_/g,'');
}else{ }else{
t = t.replace(/_helpline_/g,''); t = t.replace(/_helpline_/g,'');
t = t.replace(/_hidden_class_help_/g,'hide');
}
if (field[1].placeholder !== undefined && field[1].placeholder !== null) {
t = t.replace(/_placeholder_/g,'placeholder="'+field[1].placeholder+'"');
}else{
t = t.replace(/_placeholder_/g,'');
} }
return t; return t;

View File

@@ -121,17 +121,17 @@ FormValidation.method('addError' , function(formInput, overrideMessage) {
var message = formInput.attr("validation"); var message = formInput.attr("validation");
$('#'+ this.formId +' #field_'+id).addClass('error'); $('#'+ this.formId +' #field_'+id).addClass('error');
if(message == undefined || message == null || message == ""){ if(message == undefined || message == null || message == ""){
$('#'+ this.formId +' #help_'+id).html(message); $('#'+ this.formId +' #help_err_'+id).html(message);
}else{ }else{
if(validation == undefined || validation == null || validation == ""){ if(validation == undefined || validation == null || validation == ""){
$('#'+ this.formId +' #help_'+id).html("Required"); $('#'+ this.formId +' #help_err_'+id).html("Required");
}else{ }else{
if(validation == "float" || validation == "number"){ if(validation == "float" || validation == "number"){
$('#'+ this.formId +' #help_'+id).html("Number required"); $('#'+ this.formId +' #help_err_'+id).html("Number required");
}else if(validation == "email"){ }else if(validation == "email"){
$('#'+ this.formId +' #help_'+id).html("Email required"); $('#'+ this.formId +' #help_err_'+id).html("Email required");
}else{ }else{
$('#'+ this.formId +' #help_'+id).html("Required"); $('#'+ this.formId +' #help_err_'+id).html("Required");
} }
} }
} }
@@ -278,7 +278,3 @@ FormValidation.method('getFormParameters' , function() {
FormValidation.method('alert', function (title,text,top) { FormValidation.method('alert', function (title,text,top) {
alert(text); alert(text);
}); });

View File

@@ -715,3 +715,22 @@ table.dataTable{
.small-box{ .small-box{
box-shadow: 0 2px 5px 0 rgba(0,0,0,.12), 0 2px 10px 0 rgba(0,0,0,.09); box-shadow: 0 2px 5px 0 rgba(0,0,0,.12), 0 2px 10px 0 rgba(0,0,0,.09);
} }
.help-info{
font-size: 25px;
color: #367fa9;
padding-top: 4px;
cursor: pointer;
}
.hide {
display: none;
}
.ice-form-error {
font-size: 1em;
}
.ice-form-error-control {
padding-bottom: 1rem;
}

View File

@@ -1,10 +0,0 @@
msgid ""
msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Language: English\n"
"Language-Team: IceHrm\n"
"Last-Translator: Thilina Hasantha\n"
"MIME-Version: 1.0\n"
"Project-Id-Version: 18.0\n"
"Report-Msgid-Bugs-To: https://icehrm.com\n"

View File

@@ -1,13 +1,15 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Language: German\n"
"Language-Team: IceHrm\n"
"Last-Translator: Patrick Geselbracht\n"
"MIME-Version: 1.0\n"
"Project-Id-Version: 18.0\n" "Project-Id-Version: 18.0\n"
"Report-Msgid-Bugs-To: https://icehrm.com\n" "Report-Msgid-Bugs-To: https://icehrm.com\n"
"Last-Translator: Patrick Geselbracht\n"
"Language-Team: IceHrm\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2018-03-05T05:26:33+05:30\n"
"PO-Revision-Date: 2018-03-05T05:26:33+05:30\n"
"Language: German\n"
msgid "Save" msgid "Save"
msgstr "Speichern" msgstr "Speichern"
@@ -88,7 +90,7 @@ msgid "Projects/Client Setup"
msgstr "Projekte/Client-Setup" msgstr "Projekte/Client-Setup"
msgid "Leave Settings" msgid "Leave Settings"
msgstr "Abwesenheitseinstellungen" msgstr "Abwesenheit"
msgid "Company Loans" msgid "Company Loans"
msgstr "Arbeitgeberdarlehen" msgstr "Arbeitgeberdarlehen"
@@ -1566,9 +1568,6 @@ msgstr "Kredite aufgenommen"
msgid "Change Leave Status" msgid "Change Leave Status"
msgstr "Urlaubsstatus ändern" msgstr "Urlaubsstatus ändern"
msgid "Leave Status"
msgstr "Urlaubsstatus"
msgid "Status Change Note" msgid "Status Change Note"
msgstr "Statusänderungshinweis" msgstr "Statusänderungshinweis"
@@ -1598,4 +1597,3 @@ msgstr "Anwenden"
msgid "Back" msgid "Back"
msgstr "Zurück" msgstr "Zurück"

View File

@@ -1,10 +0,0 @@
msgid ""
msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Language: English\n"
"Language-Team: IceHrm\n"
"Last-Translator: Thilina Hasantha\n"
"MIME-Version: 1.0\n"
"Project-Id-Version: 18.0\n"
"Report-Msgid-Bugs-To: https://icehrm.com\n"

View File

@@ -1,13 +1,15 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Language: English\n"
"Language-Team: IceHrm\n"
"Last-Translator: Thilina Hasantha\n"
"MIME-Version: 1.0\n"
"Project-Id-Version: 18.0\n" "Project-Id-Version: 18.0\n"
"Report-Msgid-Bugs-To: https://icehrm.com\n" "Report-Msgid-Bugs-To: https://icehrm.com\n"
"Last-Translator: Thilina Hasantha\n"
"Language-Team: IceHrm\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2018-03-05T05:26:33+05:30\n"
"PO-Revision-Date: 2018-03-05T05:26:33+05:30\n"
"Language: English\n"
msgid "Save" msgid "Save"
msgstr "Save" msgstr "Save"
@@ -1566,9 +1568,6 @@ msgstr "Loans Taken"
msgid "Change Leave Status" msgid "Change Leave Status"
msgstr "Change Leave Status" msgstr "Change Leave Status"
msgid "Leave Status"
msgstr "Leave Status"
msgid "Status Change Note" msgid "Status Change Note"
msgstr "Status Change Note" msgstr "Status Change Note"
@@ -1598,5 +1597,3 @@ msgstr "Apply"
msgid "Back" msgid "Back"
msgstr "Back" msgstr "Back"

View File

@@ -1,13 +1,15 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Language: Spanish\n"
"Language-Team: IceHrm\n"
"Last-Translator: Thilina Hasantha\n"
"MIME-Version: 1.0\n"
"Project-Id-Version: 18.0\n" "Project-Id-Version: 18.0\n"
"Report-Msgid-Bugs-To: https://icehrm.com\n" "Report-Msgid-Bugs-To: https://icehrm.com\n"
"Last-Translator: Thilina Hasantha\n"
"Language-Team: IceHrm\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2018-03-05T05:26:33+05:30\n"
"PO-Revision-Date: 2018-03-05T05:26:33+05:30\n"
"Language: Spanish\n"
msgid "Save" msgid "Save"
msgstr "Salvar" msgstr "Salvar"
@@ -1566,9 +1568,6 @@ msgstr "Los préstamos contraídos"
msgid "Change Leave Status" msgid "Change Leave Status"
msgstr "Dejar cambiar de estado" msgstr "Dejar cambiar de estado"
msgid "Leave Status"
msgstr "Deja Estado"
msgid "Status Change Note" msgid "Status Change Note"
msgstr "Cambio de Estado Nota" msgstr "Cambio de Estado Nota"
@@ -1598,4 +1597,3 @@ msgstr "Aplicar"
msgid "Back" msgid "Back"
msgstr "Espalda" msgstr "Espalda"

View File

@@ -1,13 +1,15 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Language: French\n"
"Language-Team: IceHrm\n"
"Last-Translator: Thilina Hasantha\n"
"MIME-Version: 1.0\n"
"Project-Id-Version: 18.0\n" "Project-Id-Version: 18.0\n"
"Report-Msgid-Bugs-To: https://icehrm.com\n" "Report-Msgid-Bugs-To: https://icehrm.com\n"
"Last-Translator: Thilina Hasantha\n"
"Language-Team: IceHrm\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2018-03-05T05:26:33+05:30\n"
"PO-Revision-Date: 2018-03-05T05:26:33+05:30\n"
"Language: French\n"
msgid "Save" msgid "Save"
msgstr "Sauvegarder" msgstr "Sauvegarder"
@@ -1566,9 +1568,6 @@ msgstr "Prêts Pris"
msgid "Change Leave Status" msgid "Change Leave Status"
msgstr "Changer congé Status" msgstr "Changer congé Status"
msgid "Leave Status"
msgstr "Laissez Status"
msgid "Status Change Note" msgid "Status Change Note"
msgstr "Changement d'état Remarque" msgstr "Changement d'état Remarque"
@@ -1598,4 +1597,3 @@ msgstr "Appliquer"
msgid "Back" msgid "Back"
msgstr "Arrière" msgstr "Arrière"

1601
lang/hi.po

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,15 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Language: Italian\n"
"Language-Team: IceHrm\n"
"Last-Translator: Thilina Hasantha\n"
"MIME-Version: 1.0\n"
"Project-Id-Version: 18.0\n" "Project-Id-Version: 18.0\n"
"Report-Msgid-Bugs-To: https://icehrm.com\n" "Report-Msgid-Bugs-To: https://icehrm.com\n"
"Last-Translator: Thilina Hasantha\n"
"Language-Team: IceHrm\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2018-03-05T05:26:33+05:30\n"
"PO-Revision-Date: 2018-03-05T05:26:33+05:30\n"
"Language: Italian\n"
msgid "Save" msgid "Save"
msgstr "Salvare" msgstr "Salvare"
@@ -1566,9 +1568,6 @@ msgstr "Prestiti contratti"
msgid "Change Leave Status" msgid "Change Leave Status"
msgstr "Cambiare Leave Stato" msgstr "Cambiare Leave Stato"
msgid "Leave Status"
msgstr "Lasciare Stato"
msgid "Status Change Note" msgid "Status Change Note"
msgstr "Modifica stato Nota" msgstr "Modifica stato Nota"
@@ -1598,4 +1597,3 @@ msgstr "Applicare"
msgid "Back" msgid "Back"
msgstr "Indietro" msgstr "Indietro"

View File

@@ -1,13 +1,15 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Language: Japanese\n"
"Language-Team: IceHrm\n"
"Last-Translator: Thilina Hasantha\n"
"MIME-Version: 1.0\n"
"Project-Id-Version: 18.0\n" "Project-Id-Version: 18.0\n"
"Report-Msgid-Bugs-To: https://icehrm.com\n" "Report-Msgid-Bugs-To: https://icehrm.com\n"
"Last-Translator: Thilina Hasantha\n"
"Language-Team: IceHrm\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2018-03-05T05:26:33+05:30\n"
"PO-Revision-Date: 2018-03-05T05:26:33+05:30\n"
"Language: Japanese\n"
msgid "Save" msgid "Save"
msgstr "セーブ" msgstr "セーブ"
@@ -1566,9 +1568,6 @@ msgstr "借入"
msgid "Change Leave Status" msgid "Change Leave Status"
msgstr "脱退ステータスを変更" msgstr "脱退ステータスを変更"
msgid "Leave Status"
msgstr "ステータスを残します"
msgid "Status Change Note" msgid "Status Change Note"
msgstr "ステータス変更(注)" msgstr "ステータス変更(注)"
@@ -1598,4 +1597,3 @@ msgstr "適用します"
msgid "Back" msgid "Back"
msgstr "バック" msgstr "バック"

View File

@@ -1,13 +1,15 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Language: Polish\n"
"Language-Team: IceHrm\n"
"Last-Translator: Thilina Hasantha\n"
"MIME-Version: 1.0\n"
"Project-Id-Version: 18.0\n" "Project-Id-Version: 18.0\n"
"Report-Msgid-Bugs-To: https://icehrm.com\n" "Report-Msgid-Bugs-To: https://icehrm.com\n"
"Last-Translator: Thilina Hasantha\n"
"Language-Team: IceHrm\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2018-03-05T05:26:33+05:30\n"
"PO-Revision-Date: 2018-03-05T05:26:33+05:30\n"
"Language: Polish\n"
msgid "Save" msgid "Save"
msgstr "Zapisać" msgstr "Zapisać"
@@ -1566,9 +1568,6 @@ msgstr "Pożyczki zaciągnięte"
msgid "Change Leave Status" msgid "Change Leave Status"
msgstr "Pozostawić zmiany statusu" msgstr "Pozostawić zmiany statusu"
msgid "Leave Status"
msgstr "Zostaw status"
msgid "Status Change Note" msgid "Status Change Note"
msgstr "Zmiana stanu Uwaga" msgstr "Zmiana stanu Uwaga"
@@ -1598,4 +1597,3 @@ msgstr "Zastosować"
msgid "Back" msgid "Back"
msgstr "Plecy" msgstr "Plecy"

1601
lang/si.po

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,15 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Language: Chinese\n"
"Language-Team: IceHrm\n"
"Last-Translator: Thilina Hasantha\n"
"MIME-Version: 1.0\n"
"Project-Id-Version: 18.0\n" "Project-Id-Version: 18.0\n"
"Report-Msgid-Bugs-To: https://icehrm.com\n" "Report-Msgid-Bugs-To: https://icehrm.com\n"
"Last-Translator: Thilina Hasantha\n"
"Language-Team: IceHrm\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2018-03-05T05:26:33+05:30\n"
"PO-Revision-Date: 2018-03-05T05:26:33+05:30\n"
"Language: Chinese\n"
msgid "Save" msgid "Save"
msgstr "保存" msgstr "保存"
@@ -1566,9 +1568,6 @@ msgstr "采取贷款"
msgid "Change Leave Status" msgid "Change Leave Status"
msgstr "更改休假状态" msgstr "更改休假状态"
msgid "Leave Status"
msgstr "离开状态"
msgid "Status Change Note" msgid "Status Change Note"
msgstr "状态更改注" msgstr "状态更改注"
@@ -1598,4 +1597,3 @@ msgstr "应用"
msgid "Back" msgid "Back"
msgstr "背部" msgstr "背部"

View File

@@ -1,5 +1,6 @@
<?php <?php
$migrationList = []; $migrationList = [];
$migrationList[] = 'v20180305_210100_drop_si_hi_languages';
$migrationList[] = 'v20171126_200303_swift_mail'; $migrationList[] = 'v20171126_200303_swift_mail';
$migrationList[] = 'v20171003_200302_payroll_meta_export'; $migrationList[] = 'v20171003_200302_payroll_meta_export';
$migrationList[] = 'v20171003_200301_add_deduction_group_payroll'; $migrationList[] = 'v20171003_200301_add_deduction_group_payroll';

View File

@@ -0,0 +1,35 @@
<?php
namespace Classes\Migration;
use Metadata\Common\Model\SupportedLanguage;
class v20180305_210100_drop_si_hi_languages extends AbstractMigration{
public function up(){
$supportedLanguage = new SupportedLanguage();
$supportedLanguage->Load('name = ?', array('si'));
$supportedLanguage->Delete();
$supportedLanguage = new SupportedLanguage();
$supportedLanguage->Load('name = ?', array('hi'));
$supportedLanguage->Delete();
return true;
}
public function down(){
$supportedLanguage = new SupportedLanguage();
$supportedLanguage->name = 'si';
$supportedLanguage->description = 'Sinhala';
$supportedLanguage->Save();
$supportedLanguage = new SupportedLanguage();
$supportedLanguage->name = 'hi';
$supportedLanguage->description = 'Hindi';
$supportedLanguage->Save();
return true;
}
}

View File

@@ -22,6 +22,59 @@ class RoboFile extends \Robo\Tasks
$this->say("Hello, " . implode(', ', $world)); $this->say("Hello, " . implode(', ', $world));
} }
function languageList($client) {
$this->includeCientConfig($client);
$this->say("Supported Languages for ". $client);
$language = new \Metadata\Common\Model\SupportedLanguage();
$langs = $language->Find('1 = 1');
$this->say(print_r(array_column($langs, 'name'), true));
}
function languageExport($client) {
$this->includeCientConfig($client);
$language = new \Metadata\Common\Model\SupportedLanguage();
$languages = $language->Find('1 = 1 order by id');
$data = [];
$data[0] = [];
$data[0][] = 'Key';
foreach ($languages as $lang) {
$data[0][] = $lang->name;
$trans = \Classes\LanguageManager::getTranslations($lang->name);
$trans = json_decode($trans, true)['messages'][''];
$count = 1;
foreach ($trans as $enVal => $langVal) {
if (!isset($data[$count])) {
$data[$count] = [];
$data[$count][] = $enVal;
}
$data[$count][] = $langVal[0];
$count += 1;
}
}
$fp = fopen(CLIENT_BASE_PATH.'data/translations.csv', 'w');
foreach ($data as $fields) {
fprintf($fp, chr(0xEF).chr(0xBB).chr(0xBF));
fputcsv($fp, $fields);
}
fclose($fp);
$this->say('File saved');
}
function languageImport($client, $file) {
$this->includeCientConfig($client);
$language = new \Metadata\Common\Model\SupportedLanguage();
$languages = $language->Find('1 = 1 order by id');
foreach ($languages as $language) {
$str = $this->getUpdatedTranslationString($language->name, $file);
file_put_contents(
__DIR__.'/../lang/'.$language->name.'.po',
$str);
$this->say('Updated :'.realpath(__DIR__.'/../lang/'.$language->name.'.po'));
}
}
function migrate($client, $action){ function migrate($client, $action){
$this->includeCientConfig($client); $this->includeCientConfig($client);
$this->say("DB Migrating " . $action . " for ". $client); $this->say("DB Migrating " . $action . " for ". $client);
@@ -50,4 +103,44 @@ class RoboFile extends \Robo\Tasks
} }
$this->say("DB Migration Completed !!!"); $this->say("DB Migration Completed !!!");
} }
/**
* @param $lang
* @param $file
* @return mixed
*/
protected function getUpdatedTranslationString($lang, $file)
{
$handle = fopen(CLIENT_BASE_PATH . 'data/' . $file, "r");
$langColumn = null;
/* @var \Gettext\Translations $trans */
$trans = \Classes\LanguageManager::getTranslationsObject($lang);
while (($data = fgetcsv($handle)) !== FALSE) {
if ($langColumn === null) {
$currentColumn = 0;
foreach ($data as $language) {
if ($language === $lang) {
$langColumn = $currentColumn;
break;
}
$currentColumn++;
}
if ($langColumn === null) {
$this->say('Invalid Language');
exit();
}
} else {
/* @var \Gettext\Translation $tran */
$tran = $trans->find('', $data[0]);
if ($tran !== false) {
$tran->setTranslation($data[$langColumn]);
} else {
$trans->insert($data[0], $data[$langColumn]);
}
}
}
return $trans->toPoString();
}
} }

View File

@@ -9,40 +9,45 @@ use Utils\LogManager;
class LanguageManager class LanguageManager
{ {
private static $me = null; private static $me = [];
/* @var \Gettext\Translator $translator */ /* @var \Gettext\Translator $translator */
private $translator = null; private $translator = null;
/* @var \Gettext\Translations $translations */
private $translations = null; private $translations = null;
private function __construct() private function __construct()
{ {
} }
private static function getInstance() private static function getInstance($lang = null)
{ {
if (empty(self::$me)) { if ($lang === null) {
self::$me = new LanguageManager(); $lang = self::getCurrentLang();
self::$me->loadLanguage(); }
if (empty(self::$me[$lang])) {
self::$me[$lang] = new LanguageManager();
self::$me[$lang]->initialize($lang);
} }
return self::$me; return self::$me[$lang];
} }
private function loadLanguage() private function initialize($lang)
{
$this->loadLanguage($lang);
}
public function loadLanguage($lang)
{ {
$lang = $this->getCurrentLang();
$this->translations = Translations::fromPoFile(APP_BASE_PATH.'lang/'.$lang.'.po'); $this->translations = Translations::fromPoFile(APP_BASE_PATH.'lang/'.$lang.'.po');
if (file_exists(APP_BASE_PATH.'lang/'.$lang.'-ext.po')) {
$this->translations->addFromPoFile(APP_BASE_PATH.'lang/'.$lang.'-ext.po');
}
$t = new Translator(); $t = new Translator();
$t->loadTranslations($this->translations); $t->loadTranslations($this->translations);
$t->register(); $t->register();
$this->translator = $t; $this->translator = $t;
} }
private function getCurrentLang() private static function getCurrentLang()
{ {
$user = BaseService::getInstance()->getCurrentUser(); $user = BaseService::getInstance()->getCurrentUser();
if (empty($user) || empty($user->lang) || $user->lang == "NULL") { if (empty($user) || empty($user->lang) || $user->lang == "NULL") {
@@ -56,16 +61,21 @@ class LanguageManager
if (empty($lang) || !file_exists(APP_BASE_PATH.'lang/'.$lang.'.po')) { if (empty($lang) || !file_exists(APP_BASE_PATH.'lang/'.$lang.'.po')) {
$lang = 'en'; $lang = 'en';
} }
LogManager::getInstance()->info("Current Language:".$lang);
return $lang; return $lang;
} }
public static function getTranslations() public static function getTranslations($lang = null)
{ {
$me = self::getInstance(); $me = self::getInstance($lang);
return Json::toString($me->translations); return Json::toString($me->translations);
} }
public static function getTranslationsObject($lang = null)
{
$me = self::getInstance($lang);
return $me->translations;
}
public static function tran($text) public static function tran($text)
{ {
$me = self::getInstance(); $me = self::getInstance();

View File

@@ -7,6 +7,8 @@
</div> </div>
</div> </div>
<div class="controls col-sm-3"> <div class="controls col-sm-3">
<span class="help-inline control-label" id="help__id_">_helpline_</span> <div id="help__id_" class="fa fa-info-circle help-info _hidden_class_help_"
onclick="modJs.showMessage('Tip','_helpline_')"></div>
<span id="help_err__id_"></span>
</div> </div>
</div> </div>

View File

@@ -9,6 +9,8 @@
</div> </div>
<div class="controls col-sm-3"> <div class="controls col-sm-3">
<span class="help-inline control-label" id="help__id_">_helpline_</span> <div id="help__id_" class="fa fa-info-circle help-info _hidden_class_help_"
onclick="modJs.showMessage('Tip','_helpline_')"></div>
<span id="help_err__id_"></span>
</div> </div>
</div> </div>

View File

@@ -8,6 +8,8 @@
</div> </div>
</div> </div>
<div class="controls col-sm-3"> <div class="controls col-sm-3">
<span class="help-inline control-label" id="help__id_">_helpline_</span> <div id="help__id_" class="fa fa-info-circle help-info _hidden_class_help_"
onclick="modJs.showMessage('Tip','_helpline_')"></div>
<span id="help_err__id_"></span>
</div> </div>
</div> </div>

View File

@@ -10,6 +10,8 @@
</div> </div>
</div> </div>
<div class="controls col-sm-3"> <div class="controls col-sm-3">
<span class="help-inline control-label" id="help__id_">_helpline_</span> <div id="help__id_" class="fa fa-info-circle help-info _hidden_class_help_"
onclick="modJs.showMessage('Tip','_helpline_')"></div>
<span id="help_err__id_"></span>
</div> </div>
</div> </div>

View File

@@ -7,6 +7,8 @@
<button id="_id__remove" onclick="$('#_id_').attr('val','');return false;" class="btn btn-mini btn-inverse" type="button" style="margin-left:30px;margin-top:3px;"><t>Remove</t></button> <button id="_id__remove" onclick="$('#_id_').attr('val','');return false;" class="btn btn-mini btn-inverse" type="button" style="margin-left:30px;margin-top:3px;"><t>Remove</t></button>
</div> </div>
<div class="controls col-sm-3"> <div class="controls col-sm-3">
<span class="help-inline control-label" id="help__id_">_helpline_</span> <div id="help__id_" class="fa fa-info-circle help-info _hidden_class_help_"
onclick="modJs.showMessage('Tip','_helpline_')"></div>
<span id="help_err__id_"></span>
</div> </div>
</div> </div>

View File

@@ -4,6 +4,8 @@
<input class="control-label" id="_id_"/> <input class="control-label" id="_id_"/>
</div> </div>
<div class="controls col-sm-3"> <div class="controls col-sm-3">
<span class="help-inline control-label" id="help__id_"></span> <div id="help__id_" class="fa fa-info-circle help-info _hidden_class_help_"
onclick="modJs.showMessage('Tip','_helpline_')"></div>
<span id="help_err__id_"></span>
</div> </div>
</div> </div>

View File

@@ -4,6 +4,8 @@
<label id="_id_" name="_id_" style="text-align: left;" class="control-label" _validation_></label> <label id="_id_" name="_id_" style="text-align: left;" class="control-label" _validation_></label>
</div> </div>
<div class="controls col-sm-3"> <div class="controls col-sm-3">
<span class="help-inline control-label" id="help__id_"></span> <div id="help__id_" class="fa fa-info-circle help-info _hidden_class_help_"
onclick="modJs.showMessage('Tip','_helpline_')"></div>
<span id="help_err__id_"></span>
</div> </div>
</div> </div>

View File

@@ -6,6 +6,8 @@
</select> </select>
</div> </div>
<div class="controls col-sm-3"> <div class="controls col-sm-3">
<span class="help-inline control-label" id="help__id_">_helpline_</span> <div id="help__id_" class="fa fa-info-circle help-info _hidden_class_help_"
onclick="modJs.showMessage('Tip','_helpline_')"></div>
<span id="help_err__id_"></span>
</div> </div>
</div> </div>

View File

@@ -6,6 +6,8 @@
</select> </select>
</div> </div>
<div class="controls col-sm-3"> <div class="controls col-sm-3">
<span class="help-inline control-label" id="help__id_">_helpline_</span> <div id="help__id_" class="fa fa-info-circle help-info _hidden_class_help_"
onclick="modJs.showMessage('Tip','_helpline_')"></div>
<span id="help_err__id_"></span>
</div> </div>
</div> </div>

View File

@@ -6,6 +6,8 @@
</select> </select>
</div> </div>
<div class="controls col-sm-3"> <div class="controls col-sm-3">
<span class="help-inline control-label" id="help__id_">_helpline_</span> <div id="help__id_" class="fa fa-info-circle help-info _hidden_class_help_"
onclick="modJs.showMessage('Tip','_helpline_')"></div>
<span id="help_err__id_"></span>
</div> </div>
</div> </div>

View File

@@ -4,6 +4,8 @@
<canvas class="form-control signatureField" type="signature" id="_id_" name="_id_" _validation_ style="height:120px;"></canvas> <canvas class="form-control signatureField" type="signature" id="_id_" name="_id_" _validation_ style="height:120px;"></canvas>
</div> </div>
<div class="controls col-sm-3"> <div class="controls col-sm-3">
<span class="help-inline control-label" id="help__id_">_helpline_</span> <div id="help__id_" class="fa fa-info-circle help-info _hidden_class_help_"
onclick="modJs.showMessage('Tip','_helpline_')"></div>
<span id="help_err__id_"></span>
</div> </div>
</div> </div>

View File

@@ -4,6 +4,8 @@
<textarea class="form-control simplemde" type="textarea" rows="4" id="_id_" name="_id_" _validation_></textarea> <textarea class="form-control simplemde" type="textarea" rows="4" id="_id_" name="_id_" _validation_></textarea>
</div> </div>
<div class="controls col-sm-3"> <div class="controls col-sm-3">
<span class="help-inline control-label" id="help__id_">_helpline_</span> <div id="help__id_" class="fa fa-info-circle help-info _hidden_class_help_"
onclick="modJs.showMessage('Tip','_helpline_')"></div>
<span id="help_err__id_"></span>
</div> </div>
</div> </div>

View File

@@ -1,9 +1,11 @@
<div class="row" id="field__id_"> <div class="row" id="field__id_">
<label class="col-sm-3 control-label" for="_id_">_label_</label> <label class="col-sm-3 control-label" for="_id_">_label_</label>
<div class="controls col-sm-6"> <div class="controls col-sm-6">
<input class="form-control" type="text" id="_id_" name="_id_" value="" _validation_/> <input class="form-control" type="text" id="_id_" name="_id_" value="" _validation_ _placeholder_/>
</div> </div>
<div class="controls col-sm-3"> <div class="controls col-sm-3">
<span class="help-inline control-label" id="help__id_">_helpline_</span> <div id="help__id_" class="fa fa-info-circle help-info _hidden_class_help_"
onclick="modJs.showMessage('Tip','_helpline_')"></div>
<span id="help_err__id_"></span>
</div> </div>
</div> </div>

View File

@@ -1,9 +1,11 @@
<div class="row" id="field__id_"> <div class="row" id="field__id_">
<label class="control-label col-sm-3" for="_id_">_label_</label> <label class="control-label col-sm-3" for="_id_">_label_</label>
<div class="controls col-sm-6"> <div class="controls col-sm-6">
<textarea class="form-control" type="textarea" rows="4" id="_id_" name="_id_" _validation_></textarea> <textarea class="form-control" type="textarea" rows="4" id="_id_" name="_id_" _validation_ _placeholder_></textarea>
</div> </div>
<div class="controls col-sm-3"> <div class="controls col-sm-3">
<span class="help-inline control-label" id="help__id_">_helpline_</span> <div id="help__id_" class="fa fa-info-circle help-info _hidden_class_help_"
onclick="modJs.showMessage('Tip','_helpline_')"></div>
<span id="help_err__id_"></span>
</div> </div>
</div> </div>

View File

@@ -10,6 +10,8 @@
</div> </div>
</div> </div>
<div class="controls col-sm-3"> <div class="controls col-sm-3">
<span class="help-inline control-label" id="help__id_">_helpline_</span> <div id="help__id_" class="fa fa-info-circle help-info _hidden_class_help_"
onclick="modJs.showMessage('Tip','_helpline_')"></div>
<span id="help_err__id_"></span>
</div> </div>
</div> </div>

View File

@@ -4,6 +4,8 @@
<textarea class="form-control tinymce" type="textarea" rows="4" id="_id_" name="_id_" _validation_></textarea> <textarea class="form-control tinymce" type="textarea" rows="4" id="_id_" name="_id_" _validation_></textarea>
</div> </div>
<div class="controls col-sm-3"> <div class="controls col-sm-3">
<span class="help-inline control-label" id="help__id_">_helpline_</span> <div id="help__id_" class="fa fa-info-circle help-info _hidden_class_help_"
onclick="modJs.showMessage('Tip','_helpline_')"></div>
<span id="help_err__id_"></span>
</div> </div>
</div> </div>

View File

@@ -2,8 +2,8 @@
<form class="form-horizontal" id="_id_" role="form"> <form class="form-horizontal" id="_id_" role="form">
<div class="box-body"> <div class="box-body">
<div class="control-group"> <div class="control-group">
<div class="controls"> <div class="controls ice-form-error-control">
<span class="label label-warning" id="_id__error" style="display:none;"></span> <span class="ice-form-error label label-danger" id="_id__error" style="display:none;"></span>
</div> </div>
</div> </div>
_fields_ _fields_

View File

@@ -1,8 +1,12 @@
<?php <?php
class PHPUnit_Framework_TestCase extends \PHPUnit\Framework\TestCase{ if (!class_exists('PHPUnit_Framework_TestCase')) {
class PHPUnit_Framework_TestCase extends \PHPUnit\Framework\TestCase
{
}
} }
class TestTemplate extends PHPUnit_Framework_TestCase class TestTemplate extends PHPUnit_Framework_TestCase
{ {

View File

@@ -2,6 +2,7 @@
namespace Test\Unit; namespace Test\Unit;
use Classes\LanguageManager; use Classes\LanguageManager;
use Gettext\Translations;
class LanguageManagerUnit extends \TestTemplate class LanguageManagerUnit extends \TestTemplate
{ {
@@ -20,4 +21,23 @@ class LanguageManagerUnit extends \TestTemplate
$this->assertEquals('User Logged In now', LanguageManager::translateTnrText('User <t>Logged In</t> now')); $this->assertEquals('User Logged In now', LanguageManager::translateTnrText('User <t>Logged In</t> now'));
fwrite(STDOUT, __METHOD__ . " End\n"); fwrite(STDOUT, __METHOD__ . " End\n");
} }
public function testGetTranslations() {
$enCount = $this->getTranslationCount('en');
$this->assertEquals($enCount, $this->getTranslationCount('de'));
$this->assertEquals($enCount, $this->getTranslationCount('es'));
$this->assertEquals($enCount, $this->getTranslationCount('fr'));
$this->assertEquals($enCount, $this->getTranslationCount('hi'));
$this->assertEquals($enCount, $this->getTranslationCount('it'));
$this->assertEquals($enCount, $this->getTranslationCount('ja'));
$this->assertEquals($enCount, $this->getTranslationCount('pl'));
$this->assertEquals($enCount, $this->getTranslationCount('zh'));
}
private function getTranslationCount($lang) {
$trans = json_decode(LanguageManager::getTranslations($lang), true);
$count = count(array_keys($trans['messages']['']));
}
} }