示例#1
1
 protected function makeResponse(Request $request)
 {
     $message = $this->translator->get('c::auth.login-required');
     if ($request->ajax() || $request->isJson() || $request->wantsJson()) {
         return Response::json(['error' => $message], 403);
     } else {
         $url = $this->url->action('anlutro\\Core\\Web\\AuthController@login');
         $intended = $request->getMethod() == 'GET' ? $request->fullUrl() : ($request->header('referer') ?: '/');
         $this->session->put('url.intended', $intended);
         return $this->redirect->to($url)->with('error', $message);
     }
 }
示例#2
0
 /**
  * Calculate age for given timestamp(s)
  *
  * @param  mixed $timestamp1  accepts string, unix-timestamp and DateTime object
  * @param  mixed $timestamp2  accepts string, unix-timestamp and DateTime object
  * @param  string $unit       constraint output to a given unit
  * @return string
  */
 public function age($timestamp1, $timestamp2 = null, $unit = null)
 {
     $timestamp1 = is_numeric($timestamp1) ? '@' . intval($timestamp1) : $timestamp1;
     $timestamp1 = is_a($timestamp1, 'DateTime') ? $timestamp1 : new DateTime($timestamp1);
     $timestamp2 = is_numeric($timestamp2) ? '@' . intval($timestamp2) : $timestamp2;
     $timestamp2 = is_a($timestamp2, 'DateTime') ? $timestamp2 : new DateTime($timestamp2);
     if ($timestamp1 == $timestamp2) {
         return $this->translator->get($this->getTranslationKey('date.n0w'));
     }
     $diff = $timestamp1->diff($timestamp2);
     $total = array('year' => $diff->y, 'month' => $diff->m + $diff->y * 12, 'week' => floor($diff->days / 7), 'day' => $diff->days, 'hour' => $diff->h + $diff->days * 24, 'minute' => $diff->h + $diff->i + $diff->days * 24 * 60, 'second' => $diff->h + $diff->i + $diff->s + $diff->days * 24 * 60 * 60);
     if (is_null($unit)) {
         foreach ($total as $key => $value) {
             if ($value > 0) {
                 $lang_key = 'date.' . $key . '_choice';
                 $lang_key = $this->getTranslationKey($lang_key);
                 $unit = $this->translator->choice($lang_key, $value);
                 return $value . ' ' . $unit;
             }
         }
     } elseif (array_key_exists($unit, $total)) {
         $value = $total[$unit];
         $lang_key = 'date.' . $unit . '_choice';
         $lang_key = $this->getTranslationKey($lang_key);
         $unit = $this->translator->choice($lang_key, $value);
         return $value . ' ' . $unit;
     }
     throw new \InvalidArgumentException('Invalid argument in function call');
 }
 /**
  * Guess the sections title.
  *
  * @param ControlPanelBuilder $builder
  */
 public function guess(ControlPanelBuilder $builder)
 {
     $sections = $builder->getSections();
     foreach ($sections as &$section) {
         // If title is set then skip it.
         if (isset($section['title'])) {
             continue;
         }
         $module = $this->modules->active();
         $title = $module->getNamespace('section.' . $section['slug'] . '.title');
         if (!isset($section['title']) && $this->translator->has($title)) {
             $section['title'] = $title;
         }
         $title = $module->getNamespace('addon.section.' . $section['slug']);
         if (!isset($section['title']) && $this->translator->has($title)) {
             $section['title'] = $title;
         }
         if (!isset($section['title']) && $this->config->get('streams::system.lazy_translations')) {
             $section['title'] = ucwords($this->string->humanize($section['slug']));
         }
         if (!isset($section['title'])) {
             $section['title'] = $title;
         }
     }
     $builder->setSections($sections);
 }
 public function __construct(DatabaseManager $DB, AuthenticationManagementInterface $AuthenticationManager, Translator $Lang)
 {
     $this->DB = $DB;
     $this->AuthenticationManager = $AuthenticationManager;
     /*
     $this->Database = $DB->table('ACCT_Journal_Entry AS je')
     						->join('ACCT_Journal_Voucher AS jv', 'jv.id', '=', 'je.journal_voucher_id')
     						->rightJoin('ACCT_Account AS c', 'je.account_id', '=', 'c.id')
     						->join('ACCT_Account_Type AS at', 'at.id', '=', 'c.account_type_id')
     						->where(function($query)
     		                {
     		                  $query->orWhere('jv.status', '=', 'B');
     		                  $query->orWhereNull('jv.status');
     		                }
     						)
     						->where('c.organization_id', '=', $AuthenticationManager->getCurrentUserOrganizationId())
     						->whereIn('at.pl_bs_category', array('B', 'C'))
     						->whereNull('je.deleted_at')
     						->whereNull('jv.deleted_at');
     */
     $this->Database = $DB->connection($AuthenticationManager->getCurrentUserOrganizationConnection())->table('ACCT_Journal_Entry AS je')->join('ACCT_Journal_Voucher AS jv', 'jv.id', '=', 'je.journal_voucher_id')->rightJoin('ACCT_Account AS c', 'je.account_id', '=', 'c.id')->join('ACCT_Account_Type AS at', 'at.id', '=', 'c.account_type_id')->where('jv.status', '=', 'B')->where('jv.organization_id', '=', $AuthenticationManager->getCurrentUserOrganizationId())->where('c.is_group', '=', 0)->whereIn('at.pl_bs_category', array('B', 'C'))->whereNull('je.deleted_at')->whereNull('jv.deleted_at');
     $this->Database2 = $DB->connection($AuthenticationManager->getCurrentUserOrganizationConnection())->table('ACCT_Account AS c')->join('ACCT_Account_Type AS at', 'at.id', '=', 'c.account_type_id')->where('c.is_group', '=', 1)->where('c.organization_id', '=', $AuthenticationManager->getCurrentUserOrganizationId())->whereIn('at.pl_bs_category', array('B', 'C'))->select(array($DB->raw('0 AS acct_pl_debit'), $DB->raw('0 AS acct_pl_credit'), 'c.id AS acct_pl_account_id', 'c.parent_account_id AS acct_pl_parent_account_id', 'c.key AS acct_pl_account_key', 'c.name AS acct_pl_account_name', 'c.is_group AS acct_pl_is_group', 'c.balance_type AS acct_pl_balance_type', $DB->raw('CASE at.pl_bs_category WHEN "B" THEN "' . $Lang->get('decima-accounting::profit-and-loss.income') . '" ELSE "' . $Lang->get('decima-accounting::profit-and-loss.expenses') . '" END AS acct_pl_pl_bs_category'), $DB->raw('0 AS acct_pl_balance')));
     $this->visibleColumns = array($DB->raw('IFNULL(SUM(je.debit),0) AS acct_pl_debit'), $DB->raw('IFNULL(SUM(je.credit),0) AS acct_pl_credit'), 'c.id AS acct_pl_account_id', 'c.parent_account_id AS acct_pl_parent_account_id', 'c.key AS acct_pl_account_key', 'c.name AS acct_pl_account_name', 'c.is_group AS acct_pl_is_group', 'c.balance_type AS acct_pl_balance_type', $DB->raw('CASE at.pl_bs_category WHEN "B" THEN "' . $Lang->get('decima-accounting::profit-and-loss.income') . '" ELSE "' . $Lang->get('decima-accounting::profit-and-loss.expenses') . '" END AS acct_pl_pl_bs_category'), $DB->raw('0 AS acct_pl_balance'));
     $this->orderBy = array(array('acct_pl_account_key', 'asc'));
 }
示例#5
0
 /**
  * Render the likes into a string.
  *
  * @param Collection $likesCollection  The likes to render.
  *
  * @param string     $viewAllLikesLink The link to view all of the likes for the content.
  *
  * @return string
  */
 public function render(Collection $likesCollection, $viewAllLikesLink)
 {
     $numLikesToList = $this->settings->get('posts.likes_to_show', 3);
     $numOtherLikes = $likesCollection->count() - $numLikesToList;
     $userId = $this->guard->user()->getAuthIdentifier();
     $likes = [];
     $likesCollection = $likesCollection->filter(function (Like $like) use(&$likes, &$numLikesToList, $userId) {
         if ($like->user->id === $userId) {
             $like->user->name = $this->lang->get('likes.current_user');
             $likes[] = $like;
             $numLikesToList--;
             return false;
         }
         return true;
     });
     $numLikesInCollection = $likesCollection->count();
     if ($numLikesInCollection > 0 && $numLikesToList > 0) {
         if ($numLikesInCollection < $numLikesToList) {
             $numLikesToList = $numLikesInCollection;
         }
         $randomLikes = $likesCollection->random($numLikesToList);
         if (!is_array($randomLikes)) {
             // random returns a single model if $numLikesToList is 1...
             $randomLikes = array($randomLikes);
         }
         foreach ($randomLikes as $key => $like) {
             $likes[] = $like;
         }
     }
     return $this->viewFactory->make('likes.list', compact('numOtherLikes', 'likes', 'viewAllLikesLink'))->render();
 }
 /**
  * Handle the fields.
  *
  * @param PermissionFormBuilder $builder
  * @param AddonCollection       $addons
  * @param Translator            $translator
  * @param Repository            $config
  */
 public function handle(PermissionFormBuilder $builder, AddonCollection $addons, Translator $translator, Repository $config)
 {
     /* @var UserInterface $user */
     $user = $builder->getEntry();
     $fields = [];
     $namespaces = ['streams'];
     /* @var Addon $addon */
     foreach ($addons->withConfig('permissions') as $addon) {
         $namespaces[] = $addon->getNamespace();
     }
     foreach ($namespaces as $namespace) {
         foreach ($config->get($namespace . '::permissions', []) as $group => $permissions) {
             $label = $namespace . '::permission.' . $group . '.name';
             if (!$translator->has($warning = $namespace . '::permission.' . $group . '.warning')) {
                 $warning = null;
             }
             if (!$translator->has($instructions = $namespace . '::permission.' . $group . '.instructions')) {
                 $instructions = null;
             }
             $fields[$namespace . '::' . $group] = ['label' => $label, 'warning' => $warning, 'instructions' => $instructions, 'type' => 'anomaly.field_type.checkboxes', 'value' => function () use($user, $namespace, $group) {
                 return array_map(function ($permission) use($user, $namespace, $group) {
                     return str_replace($namespace . '::' . $group . '.', '', $permission);
                 }, $user->getPermissions());
             }, 'config' => ['options' => function () use($group, $permissions, $namespace) {
                 return array_combine($permissions, array_map(function ($permission) use($namespace, $group) {
                     return $namespace . '::permission.' . $group . '.option.' . $permission;
                 }, $permissions));
             }]];
         }
     }
     $builder->setFields($fields);
 }
示例#7
0
 /**
  * Setup the translator instance.
  *
  * @param string $fallbackLocale
  * @param string $path
  * @return void
  */
 protected function setupTranslator($fallbackLocale, $path)
 {
     $file = new Filesystem();
     $loader = new FileLoader($file, $path);
     $trans = new Translator($loader, $this->container['config']['app.locale']);
     $trans->setFallback($fallbackLocale);
     $this->translator = $trans;
 }
 public function test_jalali_after_or_before_replacer_is_applied_with_date()
 {
     $this->translator->setLocale('fa');
     $faNow = '۱۳۹۴/۹/۱۴';
     $validator = $this->factory->make(['birth_date' => 'garbage'], ['birth_date' => "required|jalali_after:{$faNow}|jalali_before:{$faNow}"]);
     $this->assertTrue($validator->fails());
     $this->assertEquals(['birth_date' => ["تاریخ تولد وارد شده باید یک تاریخ شمسی معتبر بعد از {$faNow} باشد.", "تاریخ تولد وارد شده باید یک تاریخ شمسی معتبر قبل از {$faNow} باشد."]], $validator->messages()->toArray());
 }
 /**
  * @param \Illuminate\Translation\Translator         $translator
  * @param \Illuminate\Routing\Router                 $router
  * @param \Illuminate\Contracts\Routing\UrlGenerator $urlGenerator
  */
 public function __construct(Translator $translator, Router $router, UrlGenerator $urlGenerator)
 {
     $this->translator = $translator;
     $this->router = $router;
     $this->urlGenerator = $urlGenerator;
     // Unfortunately we can't do this in the service provider since routes are booted first
     $this->translator->addNamespace('paginateroute', __DIR__ . '/../resources/lang');
     $this->pageKeyword = $this->translator->get('paginateroute::paginateroute.page');
 }
 public function update()
 {
     $roles = $this->request->get('roles', []);
     try {
         $this->execute('Pardisan\\Commands\\Permission\\PermRoleCommand', ['roles' => $roles]);
         return $this->redirectRoute('admin.permissions.index')->with('success_message', $this->lang->get('messages.permissions.update_success'));
     } catch (RepositoryException $e) {
         return $this->redirectBack()->with('error_message', $this->lang->get('messages.repository_error'));
     }
 }
 /**
  * Register any translation services.
  *
  * @param  \Pimple\Container $container
  */
 public function register(Container $container)
 {
     $this->registerLoader($container);
     $container['translator'] = function () use($container) {
         $config = $container['config'];
         $translator = new Translator($container['translation.loader'], $config['app.locale']);
         $translator->setFallback($config['app.fallback_locale']);
         return $translator;
     };
 }
示例#12
0
 /**
  * Renders the age gate view
  */
 public function agegate()
 {
     $previousTooYoung = $this->session->get('laravel-avp.previous_too_young');
     $view = view(config('agegate.view'))->with(compact('previousTooYoung'));
     if (!$this->session->has('errors') && $previousTooYoung) {
         $messages = $this->lang->get('laravel-avp::validation.custom');
         $errorMsg = $messages['dob.previous'];
         $view->withErrors(['dob' => [$errorMsg]]);
     }
     return $view;
 }
 public function __construct(DatabaseManager $DB, AuthenticationManagementInterface $AuthenticationManager, Translator $Lang)
 {
     // $this->DB = $DB;
     // $this->DB->connection()->enableQueryLog();
     $this->Database = $DB->connection($AuthenticationManager->getCurrentUserOrganizationConnection())->table('ACCT_Account AS a')->leftJoin('ACCT_Account AS ap', 'ap.id', '=', 'a.parent_account_id')->join('ACCT_Account_Type AS at', 'at.id', '=', 'a.account_type_id')->where('a.organization_id', '=', $AuthenticationManager->getCurrentUserOrganizationId())->whereNull('a.deleted_at');
     $this->visibleColumns = array('a.id AS acct_am_id', 'a.key as acct_am_key', 'a.name as acct_am_name', 'a.balance_type as acct_am_balance_type', 'a.is_group as acct_am_is_group', 'a.account_type_id as acct_am_account_type_id', 'at.name as acct_am_account_type', 'ap.id as acct_am_parent_account_id', 'ap.key as acct_am_parent_key', 'ap.name as acct_am_parent_account', $DB->raw('CASE a.balance_type WHEN "D" THEN "' . $Lang->get('decima-accounting::account-management.D') . '" ELSE "' . $Lang->get('decima-accounting::account-management.A') . '" END AS acct_am_balance_type_name'), $DB->raw('CASE a.is_group WHEN 1 THEN 0 ELSE 1 END AS acct_am_is_leaf'));
     $this->orderBy = array(array('acct_am_key', 'asc'));
     $this->treeGrid = true;
     $this->parentColumn = 'ap.id';
     $this->leafColumn = 'acct_am_is_leaf';
 }
 public function __construct(DatabaseManager $DB, AuthenticationManagementInterface $AuthenticationManager, AccountManagementInterface $AccountManager, Translator $Lang, Carbon $Carbon)
 {
     $this->DB = $DB;
     $this->AccountManager = $AccountManager;
     $this->AuthenticationManager = $AuthenticationManager;
     $this->Carbon = $Carbon;
     $this->Database = $DB->connection($AuthenticationManager->getCurrentUserOrganizationConnection())->table('ACCT_Journal_Entry AS je')->join('ACCT_Journal_Voucher AS jv', 'jv.id', '=', 'je.journal_voucher_id')->join('ACCT_Account AS c', 'je.account_id', '=', 'c.id')->where('jv.organization_id', '=', $AuthenticationManager->getCurrentUserOrganizationId())->where('c.is_group', '=', 0)->whereNull('je.deleted_at')->whereNull('jv.deleted_at')->select(array($DB->raw('IFNULL(SUM(je.debit),0) AS acct_gl_debit'), $DB->raw('IFNULL(SUM(je.credit),0) AS acct_gl_credit'), 'c.id AS acct_gl_account_id', 'c.parent_account_id AS acct_gl_parent_account_id', 'c.key AS acct_gl_account_key', 'c.name AS acct_gl_account_name', 'c.is_group AS acct_gl_is_group', 'c.balance_type AS acct_gl_balance_type', $DB->raw('0 AS acct_gl_total_debit'), $DB->raw('0 AS acct_gl_total_credit'), $DB->raw('0 AS acct_gl_opening_balance'), $DB->raw('0 AS acct_gl_closing_balance'), $DB->raw('\'\' AS acct_gl_voucher_date'), $DB->raw('\'\' AS acct_gl_voucher_type'), $DB->raw('\'\' AS acct_gl_voucher_number')));
     $this->Database2 = $DB->connection($AuthenticationManager->getCurrentUserOrganizationConnection())->table('ACCT_Account AS c')->where('c.is_group', '=', 1)->where('c.organization_id', '=', $AuthenticationManager->getCurrentUserOrganizationId())->select(array($DB->raw('0 AS acct_gl_debit'), $DB->raw('0 AS acct_gl_credit'), 'c.id AS acct_gl_account_id', 'c.parent_account_id AS acct_gl_parent_account_id', 'c.key AS acct_gl_account_key', 'c.name AS acct_gl_account_name', 'c.is_group AS acct_gl_is_group', 'c.balance_type AS acct_gl_balance_type', $DB->raw('0 AS acct_gl_total_debit'), $DB->raw('0 AS acct_gl_total_credit'), $DB->raw('0 AS acct_gl_opening_balance'), $DB->raw('0 AS acct_gl_closing_balance'), $DB->raw('\'\' AS acct_gl_voucher_date'), $DB->raw('\'\' AS acct_gl_voucher_type'), $DB->raw('\'\' AS acct_gl_voucher_number')));
     $this->Database3 = $DB->connection($AuthenticationManager->getCurrentUserOrganizationConnection())->table('ACCT_Journal_Entry AS je')->join('ACCT_Journal_Voucher AS jv', 'jv.id', '=', 'je.journal_voucher_id')->join('ACCT_Account AS c', 'je.account_id', '=', 'c.id')->where('jv.organization_id', '=', $AuthenticationManager->getCurrentUserOrganizationId())->where('c.is_group', '=', 0)->whereNull('je.deleted_at')->whereNull('jv.deleted_at')->select(array($DB->raw('0 AS acct_gl_debit'), $DB->raw('0 AS acct_gl_credit'), 'c.id AS acct_gl_account_id', 'c.parent_account_id AS acct_gl_parent_account_id', 'c.key AS acct_gl_account_key', 'c.name AS acct_gl_account_name', 'c.is_group AS acct_gl_is_group', 'c.balance_type AS acct_gl_balance_type', $DB->raw('IFNULL(SUM(je.debit),0) AS acct_gl_total_credit'), $DB->raw('IFNULL(SUM(je.credit),0) AS acct_gl_total_credit'), $DB->raw('0 AS acct_gl_opening_balance'), $DB->raw('0 AS acct_gl_closing_balance'), $DB->raw('\'\' AS acct_gl_voucher_date'), $DB->raw('\'\' AS acct_gl_voucher_type'), $DB->raw('\'\' AS acct_gl_voucher_number')));
     $this->Database4 = $DB->connection($AuthenticationManager->getCurrentUserOrganizationConnection())->table('ACCT_Journal_Entry AS je')->join('ACCT_Journal_Voucher AS jv', 'jv.id', '=', 'je.journal_voucher_id')->join('ACCT_Voucher_Type AS vt', 'vt.id', '=', 'jv.voucher_type_id')->join('ACCT_Account AS c', 'je.account_id', '=', 'c.id')->where('jv.organization_id', '=', $AuthenticationManager->getCurrentUserOrganizationId())->where('c.is_group', '=', 0)->whereNull('je.deleted_at')->whereNull('jv.deleted_at')->select(array($DB->raw('je.debit AS acct_gl_debit'), $DB->raw('je.credit AS acct_gl_credit'), 'c.id AS acct_gl_account_id', 'c.parent_account_id AS acct_gl_parent_account_id', $DB->raw('IFNULL(jv.manual_reference,"' . $Lang->get('decima-accounting::journal-management.noRef') . '") AS acct_gl_account_key'), 'jv.remark AS acct_gl_account_name', 'c.is_group AS acct_gl_is_group', 'c.balance_type AS acct_gl_balance_type', $DB->raw('0 AS acct_gl_total_debit'), $DB->raw('0 AS acct_gl_total_credit'), $DB->raw('0 AS acct_gl_opening_balance'), $DB->raw('0 AS acct_gl_closing_balance'), $DB->raw('DATE_FORMAT(jv.date, "' . $Lang->get('form.mysqlDateFormat') . '") AS acct_gl_voucher_date'), $DB->raw('vt.name AS acct_gl_voucher_type'), $DB->raw('jv.number AS acct_gl_voucher_number')));
     $this->orderBy = array(array('acct_gl_account_key', 'asc'));
 }
示例#15
0
 /**
  * Get localized name of zodiac sign
  *
  * @return string
  */
 public function localized()
 {
     if (!is_a($this->translator, 'Illuminate\\Translation\\Translator')) {
         return "zodiacs.{$this->name}";
     }
     if ($this->translator->has("zodiacs.{$this->name}")) {
         // return error message from validation translation file
         return $this->translator->get("zodiacs.{$this->name}");
     }
     // return packages default message
     return $this->translator->get("zodiacs::zodiacs.{$this->name}");
 }
示例#16
0
 public function trans($id, array $parameters = [], $domain = 'messages', $locale = null)
 {
     $id = "{$domain}.{$id}";
     $message = $this->translator->get($id, $parameters, $locale);
     if ($message == $id) {
         $message = str_replace($domain . ".", "", $message);
         foreach ($parameters as $key => $value) {
             $message = str_replace(':' . $key, $value, $message);
         }
     }
     return $message;
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->registerLoader();
     $this->app->singleton('translator', function ($app) {
         $loader = $app['translation.loader'];
         // When registering the translator component, we'll need to set the default
         // locale as well as the fallback locale. So, we'll grab the application
         // configuration so we can easily get both of these values from there.
         $locale = $app['config']['app.locale'];
         $trans = new Translator($loader, $locale);
         $trans->setFallback($app['config']['app.fallback_locale']);
         return $trans;
     });
 }
示例#18
0
 /**
  * @param SigninRequest $request
  * @param Translator $lang
  * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function store(SignInRequest $request, Translator $lang)
 {
     $credentials = $request->except('_token', 'remember_me');
     $remember_me = $request->has('remember_me') ? true : false;
     $response = $this->dispatch(new Signin($credentials, $remember_me));
     if ($response instanceof User) {
         return redirect('admin/start');
     } elseif (is_string($response) && $response == 'unconfirmed') {
         $route = store_route('store.auth.confirm-email.create', ['email' => $credentials['email']]);
         $error = $lang->get('users::auth.errors.unconfirmed', ['url' => $route]);
         return redirect()->back()->withErrors(['email' => $error]);
     }
     return redirect()->back()->withErrors(['email' => $lang->get('users::auth.errors.failed')]);
 }
 /**
  * tries to translate the message if existing, otherwise returns the original message string
  *
  * @param string $message
  * @return string
  */
 private function translateMessage($message)
 {
     if ($this->translator->has($message)) {
         return $this->translator->get($message);
     }
     return $message;
 }
 public function get($key, array $replace = array(), $locale = null)
 {
     $cached = Cache::remember($key, 15, function () use($key, $replace, $locale) {
         return parent::get($key, $replace, $locale);
     });
     return $cached;
 }
示例#21
0
文件: User.php 项目: Adamzynoni/mybb2
 /**
  * @return string
  */
 public function last_page()
 {
     $lang = null;
     $collection = $this->router->getRoutes();
     $route = $collection->match(Request::create($this->wrappedObject->last_page));
     if ($route->getName() != null) {
         $langOptions = $this->getWioData($route->getName(), $route->parameters());
         if (!isset($langOptions['url'])) {
             $langOptions['url'] = route($route->getName(), $route->parameters());
         }
         if (!isset($langOptions['langString'])) {
             $langString = 'online.' . $route->getName();
         } else {
             $langString = 'online.' . $langOptions['langString'];
             unset($langOptions['langString']);
         }
         $lang = $this->translator->get($langString, $langOptions);
         // May happen if we have two routes 'xy.yx.zz' and 'xy.yx'
         if (is_array($lang)) {
             $lang = $this->translator->get($langString . '.index', $langOptions);
         }
     }
     if ($lang == null) {
         //			$lang = Lang::get('online.unknown', ['url' => '']);
         // Used for debugging, should be left here until we have added all routes
         $lang = 'online.' . $route->getName();
     }
     return $lang;
 }
 /**
  * Guess the sections description.
  *
  * @param ControlPanelBuilder $builder
  */
 public function guess(ControlPanelBuilder $builder)
 {
     $sections = $builder->getSections();
     foreach ($sections as &$section) {
         // If description is set then skip it.
         if (isset($section['description'])) {
             continue;
         }
         $module = $this->modules->active();
         $description = $module->getNamespace('section.' . $section['slug'] . '.description');
         if ($this->translator->has($description)) {
             $section['description'] = $description;
         }
     }
     $builder->setSections($sections);
 }
示例#23
0
 public function postReset()
 {
     $credentials = $this->request->only('email', 'password', 'password_confirmation', 'token');
     $response = $this->password->reset($credentials, function ($user, $password) {
         $user->password = $this->hasher->make($password);
         $user->save();
     });
     switch ($response) {
         case $this->password->INVALID_PASSWORD:
         case $this->password->INVALID_TOKEN:
         case $this->password->INVALID_USER:
             return $this->redirector->back()->with('error', $this->translator->get($response));
         case $this->password->PASSWORD_RESET:
             return $this->redirector->to('/');
     }
 }
示例#24
0
 /**
  * Translate a target array.
  *
  * @param array $target
  * @return array
  */
 public function translate($target)
 {
     if (is_string($target)) {
         return $this->translator->trans($target);
     }
     if (is_array($target)) {
         foreach ($target as &$value) {
             if (is_string($value) && $this->translator->has($value)) {
                 $value = $this->translator->trans($value);
             } elseif (is_array($value)) {
                 $value = $this->translate($value);
             }
         }
     }
     return $target;
 }
示例#25
0
 /**
  * Translate a level.
  *
  * @param  string       $level
  * @param  string|null  $locale
  *
  * @return string
  */
 private function getTranslatedName($level, $locale)
 {
     if ($locale === 'auto') {
         $locale = null;
     }
     return $this->translator->get('log-viewer::levels.' . $level, [], $locale);
 }
示例#26
0
 /**
  * Get the translated level.
  *
  * @param  string       $key
  * @param  string|null  $locale
  *
  * @return string
  */
 public function get($key, $locale = null)
 {
     if (is_null($locale) || $locale === 'auto') {
         $locale = $this->getLocale();
     }
     return $this->translator->get("log-viewer::levels.{$key}", [], $locale);
 }
 /**
  * Handle the command.
  *
  * @param Request    $request
  * @param MessageBag $messages
  * @param Translator $translator
  */
 public function handle(Request $request, MessageBag $messages, Translator $translator)
 {
     if ($this->builder->isAjax()) {
         return;
     }
     $errors = $this->builder->getFormErrors();
     $messages->error($errors->all());
     if ($request->segment(1) == 'admin' && ($stream = $this->builder->getFormStream()) && $stream->isTrashable()) {
         /* @var AssignmentInterface $assignment */
         foreach ($stream->getUniqueAssignments() as $assignment) {
             if ($this->builder->hasFormError($assignment->getFieldSlug())) {
                 $messages->warning($translator->trans('streams::validation.unique_trash', ['attribute' => '"' . $translator->trans($assignment->getFieldName()) . '"']));
             }
         }
     }
 }
示例#28
0
 /**
  * Guess the button from the hint.
  *
  * @param ControlPanelBuilder $builder
  */
 public function guess(ControlPanelBuilder $builder)
 {
     $buttons = $builder->getButtons();
     $module = $this->modules->active();
     /**
      * This will break if we can't figure
      * out what the active module is.
      */
     if (!$module instanceof Module) {
         return;
     }
     foreach ($buttons as &$button) {
         if (!isset($button['button'])) {
             continue;
         }
         $text = $module->getNamespace('button.' . $button['button']);
         if (!isset($button['text']) && $this->translator->has($text)) {
             $button['text'] = $text;
         }
         $text = $module->getNamespace('button.' . $button['button']);
         if (!isset($button['text']) && $this->translator->has($text)) {
             $button['text'] = $text;
         }
         if ((!isset($button['text']) || !$this->translator->has($button['text'])) && $this->config->get('streams::system.lazy_translations')) {
             $button['text'] = $this->string->humanize(array_get($button, 'slug', $button['button']));
         }
     }
     $builder->setButtons($buttons);
 }
示例#29
0
 /**
  * Attempts to translate texts if the translator component is set and the
  * lang key is found, otherwise returns the original text.
  *
  * @param $text
  * @param array $parameters
  * @return string
  */
 public function translate($text, $parameters = array())
 {
     if (!is_null($this->lang)) {
         return $this->lang->get($text, $parameters);
     }
     return $text;
 }
 /**
  * Handle the command.
  */
 public function handle(MessageBag $messages, Translator $translator)
 {
     // If we can't save or there are errors then skip it.
     if ($this->builder->hasFormErrors() || !$this->builder->canSave()) {
         return;
     }
     // If there is no model and there isn't anything specific to say, skip it.
     if (!$this->builder->getFormEntry() && !$this->builder->getFormOption('success_message')) {
         return;
     }
     $mode = $this->builder->getFormMode();
     // False means no message is desired.
     if ($this->builder->getFormOption('success_message') === false) {
         return;
     }
     $entry = $this->builder->getFormEntry();
     $stream = $this->builder->getFormStream();
     $parameters = ['title' => is_object($entry) ? $entry->getTitle() : null, 'name' => is_object($stream) ? $stream->getName() : null];
     // If the name doesn't exist we need to be clever.
     if (str_contains($parameters['name'], '::') && !$translator->has($parameters['name']) && $stream) {
         $parameters['name'] = ucfirst(str_singular(str_replace('_', ' ', $stream->getSlug())));
     } elseif ($parameters['name']) {
         $parameters['name'] = str_singular(trans($parameters['name']));
     } else {
         $parameters['name'] = trans('streams::entry.name');
     }
     /**
      * Set the default success message.
      */
     if ($this->builder->getFormOption('success_message') === null) {
         $this->builder->setFormOption('success_message', trans('streams::message.' . $mode . '_success', $parameters));
     }
     $messages->{$this->builder->getFormOption('success_message_type', 'success')}($this->builder->getFormOption('success_message'));
 }