public function typeTitle() { if (\Lang::has('CMS::users.user_types.' . $this->type)) { return trans('CMS::users.user_types.' . $this->type); } return ucwords($this->type); }
public static function hasLang($string) { if (static::isLaravel()) { return \Lang::has($string); } return false; }
/** * Get the failed login message. * * @return string */ protected function getFailedLoginMessage($spec) { if ($spec == 'forCredentials') { return Lang::has('usersys.credentials') ? Lang::get('usersys.credentials') : 'These credentials do not match our records.'; } elseif ($spec == 'forActivation') { return Lang::has('usersys.inactive') ? Lang::get('usersys.inactive') : 'Your email id is not verified.'; } }
function translateAttribute($string) { $new = 'shapeshifter::attributes.' . $string; if (Lang::has($new)) { return ucfirst(Lang::get($new)); } return ucfirst($string); }
function get_trans($name) { if (Lang::has('all.' . $name)) { return trans('all.' . $name); } else { return $name; } }
public function show($id) { $permissionRole = $this->roles->rol($id); $role = $this->roles->getModelNew(); $nameRol = Lang::has('utils.roles.' . $role->name) ? Lang::get('utils.roles.' . $role->name) : $role->name; $permissions = $permissionRole->isEmpty() ? Permission::orderBy('name')->get() : Permission::whereNotIn('id', $permissionRole->lists('id'))->orderBy('name')->get(); return View::make('back.role', compact('permissionRole', 'role', 'permissions', 'nameRol')); }
public function buildLabel($name) { if (\Lang::has('validation.attributes.' . $name)) { $label = \Lang::get('validation.attributes.' . $name); } else { $label = str_replace('_', ' ', $name); } return ucfirst($label); }
/** * Get user friendly validation message. * * @return string */ public static function getValidationMessage($attribute, $rule, $data = [], $type = null) { $path = $rule; if ($type !== null) { $path .= '.' . $type; } if (\Lang::has('validation.custom.' . $attribute . '.' . $path)) { $path = 'custom.' . $attribute . '.' . $path; } $niceName = !\Lang::has('validation.attributes.' . $attribute) ? $attribute : \Lang::get('validation.attributes.' . $attribute); return \Lang::get('validation.' . $path, $data + ['attribute' => $niceName]); }
public function buildLabel($name, $attributes = null) { if (isset($attributes['label'])) { return $attributes['label']; } if (\Lang::has('validation.attributes.' . $name)) { $label = \Lang::get('validation.attributes.' . $name); } else { $label = str_replace('_', ' ', $name); } return ucfirst($label); }
function getUserTypesList() { $user_types = config('cms.user_types'); $result = []; foreach ($user_types as $type) { if (\Lang::has('CMS::core.user_types.' . $type)) { $result[$type] = trans('CMS::core.user_types.' . $type); } else { $result[$type] = ucwords($type); } } return $result; }
function l($string = NULL, $data = [], $langfile = NULL) { if ($langfile == NULL) { $langfile = \App\Context::getContext()->controller; } if (Lang::has($langfile . '.' . $string)) { return Lang::get($langfile . '.' . $string, $data); } else { foreach ($data as $key => $value) { $string = str_replace(':' . $key, $value, $string); } return $string; } }
public function postLogin() { try { // Set login credentials $credentials = array('email' => Input::get('email'), 'password' => Input::get('password')); // Try to authenticate the user Sentry::authenticate($credentials, Input::get('remember')); return Redirect::to('/'); } catch (Exception $e) { $exception = get_class($e); $msg = Lang::has("sentry.{$exception}") ? Lang::get("sentry.{$exception}") : $e->getMessage(); Session::flash('error', $msg); } return Redirect::to('/login'); }
/** * Получение спсика доступных прав из конфига * * @return array */ public static function getPermissions() { $permissions = []; foreach (config('permissions', []) as $module => $actions) { $langKey = $module . '::' . 'permissions.title'; if (\Lang::has($langKey)) { $title = trans($langKey); } else { $title = ucfirst($module); } foreach ($actions as $action) { $permissions[$title][$module . '::' . $action] = trans($module . '::permissions.' . $action); } } return $permissions; }
function tableBody($rows, $data, $buttons) { $keys = array_keys($data); $response = ""; $i = 1; foreach ($rows as $row) { $response .= "<tr><td>" . $i . "</td>"; foreach ($keys as $key) { if (strpos($key, '->') !== false) { $key = explode('->', $key); $response .= "<td>" . $row->{$key}[0]->{$key}[1] . "</td>"; } elseif (!is_array($row->{$key})) { $response .= "<td>"; if ($key == "created_at" || $key == "updated_at") { $response .= "<span class='datetime'>" . jDate::forge($row->{$key})->format('H:i:s %Y/%m/%d') . "</span>"; } elseif (strpos($key, 'date') !== false) { $response .= "<span class='datetime'>" . jDate::forge($row->{$key})->format('%Y/%m/%d') . "</span>"; } else { $response .= Lang::has('translate.' . $row->{$key}) ? trans('translate.' . $row->{$key}) : $row->{$key}; } $response .= "</td>"; } } $response .= '<td><div class="btn-group"> <button class="btn btn-default btn-xs" type="button">' . trans('translate.Actions') . '</button> <button data-toggle="dropdown" class="btn btn-xs btn-primary dropdown-toggle" type="button"> <span class="caret"></span><span class="sr-only">Toggle Dropdown</span> </button> <ul role="menu" class="dropdown-menu pull-right">'; foreach ($buttons as $button) { preg_match('/\\{(.*?)\\}/', $button['url'], $param); $url = preg_replace("/\\{[^)]+\\}/", $row->{$param}[1], $button['url']); $response .= '<li><a href="' . $url . '">'; if (Lang::has('translate.' . $button['label'])) { $response .= trans('translate.' . $button['label']); } else { $response .= $button['label']; } $response .= '</a></li>'; } $response .= '</ul> </div></td>'; $response .= "</tr>"; $i = $i + 1; } return $response; }
/** * Translate to chinese. * * @param $string * @param $string * * @return string */ function lang($target, $default) { return Lang::has($target) ? Lang::get($target) : $default; }
/** * Test the Lang::has method. * * @group laravel */ public function testHasMethodIndicatesIfLangaugeLineExists() { $this->assertTrue(Lang::has('validation')); $this->assertTrue(Lang::has('validation.required')); $this->assertFalse(Lang::has('validation.foo')); }
/** * helper for get field trans value * @param $name : field name * @return string : translate name */ function fieldName($name) { return \Lang::has("validation.attributes.{$name}") ? trans("validation.attributes.{$name}") : studly_case($name); }
function ac_trans_choice($id, $number, array $parameters = [], $domain = 'messages', $locale = null) { $namespace = null; // TODO: DRY conditions if (!Lang::has($id)) { $namespace = 'authority-controller::'; $id = $namespace . $id; if (!Lang::has($id)) { $defaultId = 'messages.unauthorized.default'; $id = $namespace . $defaultId; if (!Lang::has($id)) { $id = $defaultId; if (Lang::has($id, 'en')) { return trans_choice($id, $number, $parameters, $domain, 'en'); } return trans_choice($namespace . $id, $number, $parameters, $domain, 'en'); } } } return trans_choice($id, $number, $parameters, $domain, $locale); }
<?php Route::filter('logit.logs', function () { $logs = array(); if (!Lang::has('logit::logit.sapi')) { App::setLocale('en'); } foreach (Lang::get('logit::logit.sapi') as $sapi => $human) { $logs[$sapi]['sapi'] = $human; $dirs = Config::get('logit::log_dirs'); $files = array(); foreach ($dirs as $app => $dir) { $files[$app] = glob($dir . '/log-' . $sapi . '*', GLOB_BRACE); if (is_array($files[$app])) { $files[$app] = array_reverse($files[$app]); foreach ($files[$app] as &$file) { $file = preg_replace('/.*(\\d{4}-\\d{2}-\\d{2}).*/', '$1', basename($file)); } } else { $files[$app] = array(); } } $logs[$sapi]['logs'] = $files; } View::share('logs', $logs); }); Route::filter('logit.messages', function () { if (Session::has('success') || Session::has('error') || Session::has('info')) { View::share('has_messages', true); } else { View::share('has_messages', false);
public function getUnauthorizedMessage($action, $subject) { $keys = $this->getUnauthorizedMessageKeys($action, $subject); $variables = ['action' => $action]; $variables['subject'] = class_exists($subject) ? $subject : snake_case($subject, ' '); $transKey = null; foreach ($keys as $key) { if (\Lang::has('messages.unauthorized.' . $key)) { $transKey = "messages.unauthorized." . $key; break; } } $message = ac_trans($transKey, $variables); return $message ?: null; }
@extends("layouts.main") @section("page-title") @stop @section("content") <div class="col-sm-12 col-md-12"> <div class="row"> <div class="col-md-12"> <div class="block-flat"> <div class="header"> <h3><?php if (Lang::has("translate." . $title)) { echo trans("translate." . $title); } else { echo $title; } ?> </h3> </div> <div class="content"> <div class="table-responsive"> <table class="table table-bordered" id="datatable" > <thead> <tr> {!! tableHead($data) !!} </tr> </thead> <tbody> {!! tableBody($rows, $data, $buttons) !!} </tbody>
public function funcionesArea($id_area) { if (Lang::has('funciones.' . $id_area)) { return trans('funciones.' . $id_area); } else { return false; } }
/** * Get the failed login message. * * @return string */ protected function getFailedLoginMessage() { return Lang::has('auth.failed') ? Lang::get('auth.failed') : 'These credentials do not match our records.'; }
if (!isset($prefix)) { $prefix = ''; } if (!isset($values)) { $values = null; } // В некоторых исключительных ситуациях бывает необходимо вытащить номер текущего редактируемого объекта echo Form::hidden('data_item_id', $item->id); echo Form::token(); foreach ($fields as $name => $field) { if (!isset($field['attributes'])) { $field['attributes'] = []; } $input_name = $prefix . $name; $label = array_get($field, 'label'); if (Lang::has($label)) { $label = trans($label); } if ($field['tag'] == 'hidden') { echo Form::hidden($input_name, get_value($name, $item, $values), $field['attributes']); } else { $field_is_required = ''; if (isset($field['attributes']['data-validation']) and str_contains($field['attributes']['data-validation'], 'notempty')) { $field_is_required = '<span class="text-danger" title="' . trans('prettyforms::validation.field_is_required') . '"> *</span>'; } echo "<div class='form-group'>"; echo "<label for='field-{$input_name}' class='col-sm-2 control-label'>{$label}{$field_is_required}"; if (isset($field['desc'])) { echo "<br/><small class='text-muted' style='font-weight: normal'>{$field['desc']}</small>"; } echo '</label>';
/** * Get the login lockout error message. * * @param int $seconds * @return string */ protected function getLockoutErrorMessage($seconds) { $minutes = round($seconds / 60); return \Lang::has('auth.throttle') ? \Lang::get('auth.throttle', ['minutes' => $minutes]) : 'Too many login attempts. Please try again in ' . $seconds . ' seconds.'; }
/** * Contruir la etiqueta del input * * @param string $name Nombre del control input * @return string Etiqueta HTML del control input */ private function buildLabel($name) { //Averigua si la etiqueta está definida en el diccionario de Laravel. if (\Lang::has('validation.attributes.' . $name)) { //Contruir label a partir del texto definido en el diccionario. $label = \Lang::get('validation.attributes.' . $name); } else { //Construir label a partir del nombre de campo pasado por parámetro $label = str_replace('_', ' ', ucfirst($name)); } return $label; }
/** * Get the login lockout error message. * * @param int $seconds * @return string */ protected function getLockoutErrorMessage($seconds) { $minutes = round($seconds / 60); return \Lang::has('auth.throttle') ? \Lang::get('auth.throttle', ['minutes' => $minutes]) : 'Demaciados intentos fallidos, vuelve a intentar en ' . $seconds . ' segundos.'; }
<?php Route::filter('logviewer.logs', function () { $logs = array(); if (!Lang::has('logviewer::logviewer.sapi')) { App::setLocale('en'); } foreach (Lang::get('logviewer::logviewer.sapi') as $sapi => $human) { $logs[$sapi]['sapi'] = $human; $dirs = Config::get('logviewer::log_dirs'); $files = array(); foreach ($dirs as $app => $dir) { $files[$app] = glob($dir . '/log-' . $sapi . '*', GLOB_BRACE); if (is_array($files[$app])) { $files[$app] = array_reverse($files[$app]); foreach ($files[$app] as &$file) { $file = preg_replace('/.*(\\d{4}-\\d{2}-\\d{2}).*/', '$1', basename($file)); } } else { $files[$app] = array(); } } $logs[$sapi]['logs'] = $files; } View::share('logs', $logs); }); Route::filter('logviewer.messages', function () { if (Session::has('success') || Session::has('error') || Session::has('info')) { View::share('has_messages', true); } else { View::share('has_messages', false);
<th>Not set</th> </thead> <tbody> <?php foreach ($roles as $role) { ?> <tr data-id="<?php echo $role->id; ?> "> <?php $key = 'boomcms::roles.' . $role->name; ?> <td><?php echo Lang::has($key) ? trans($key) : ucfirst(preg_replace('/([A-Z])/', ' $1', $role->name)); ?> </td> <td> <input type="radio" id="allow-<?php echo $role->id; ?> " value="1" name="<?php echo $role->id; ?> " /> <label for="allow-<?php echo $role->id; ?> ">Allow</label>
<source src="{{ asset('motion_files/background.webm') }}"> <source src="{{ asset('motion_files/background.ogv') }}"> </video> </div> <div id="noise"> <div id="main"> <div id="frame"> <h1 id="errmsgKUU"></h1> </div> <div class="ui-video-background ui-widget ui-widget-content ui-corner-all"></div> <div class="ui-video-background ui-widget ui-widget-content ui-corner-all"></div> </div> <?php if (Lang::has('main.errors.' . $error_code)) { $error_mess = Lang::get('main.errors.' . $error_code); } else { $error_mess = Lang::get('main.errors.err', array('code' => $error_code)); } ?> <script type="text/javascript"> $('#errmsgKUU').html(" {{ $error_mess }} "); </script> <footer> <div id="wrapper"> <div id="me"> <h2>KeepUsUp</h2> <h3>{{ trans('main.pts') }}</h3>