Fix for module column headers

This commit is contained in:
Hillel Coren 2016-12-19 13:22:03 +02:00
parent 82e2331e73
commit 989d55d692
3 changed files with 15 additions and 6 deletions

View File

@ -923,11 +923,16 @@ if (!defined('CONTACT_EMAIL')) {
$text = $entityType;
}
// check if this has been translated in a module language file
if ( ! Utils::isNinjaProd() && $module = Module::find($entityType)) {
return trans("{$module->getLowerName()}::texts.{$text}");
} else {
return trans("texts.{$text}");
$key = "{$module->getLowerName()}::texts.{$text}";
$value = trans($key);
if ($key != $value) {
return $value;
}
}
return trans("texts.{$text}");
}
}

View File

@ -266,7 +266,7 @@ class Utils
return substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/') + 1);
}
public static function trans($input)
public static function trans($input, $module = false)
{
$data = [];
@ -274,7 +274,11 @@ class Utils
if ($field == 'checkbox') {
$data[] = $field;
} elseif ($field) {
$data[] = trans("texts.$field");
if ($module) {
$data[] = mtrans($module, $field);
} else {
$data[] = trans("texts.$field");
}
} else {
$data[] = '';
}

View File

@ -63,7 +63,7 @@
{!! Datatable::table()
->addColumn(Utils::trans($datatable->columnFields()))
->addColumn(Utils::trans($datatable->columnFields(), $datatable->entityType))
->setUrl(url('api/' . Utils::pluralizeEntityType($entityType) . '/' . (isset($clientId) ? $clientId : (isset($vendorId) ? $vendorId : ''))))
->setCustomValues('rightAlign', isset($rightAlign) ? $rightAlign : [])
->setCustomValues('entityType', Utils::pluralizeEntityType($entityType))