diff --git a/app/Http/routes.php b/app/Http/routes.php index fd326be1a194..4acd05d9c1ed 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -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}"); } } diff --git a/app/Libraries/Utils.php b/app/Libraries/Utils.php index c869cce10d3f..1a57630131d6 100644 --- a/app/Libraries/Utils.php +++ b/app/Libraries/Utils.php @@ -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[] = ''; } diff --git a/resources/views/list.blade.php b/resources/views/list.blade.php index 5848cf8fafd2..b320690752c3 100644 --- a/resources/views/list.blade.php +++ b/resources/views/list.blade.php @@ -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))