本文整理汇总了PHP中Illuminate\Translation\Translator类的典型用法代码示例。如果您正苦于以下问题:PHP Translator类的具体用法?PHP Translator怎么用?PHP Translator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Translator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
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'));
}
示例2: handle
/**
* 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);
}
示例3: setupTranslator
/**
* 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;
}
示例4: __construct
/**
* @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');
}
示例5: register
/**
* 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;
};
}
示例6: __construct
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';
}
示例7: __construct
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'));
}
示例8: localized
/**
* 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}");
}
示例9: register
/**
* 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;
});
}
示例10: store
/**
* @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')]);
}
示例11: makeResponse
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);
}
}
示例12: age
/**
* 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');
}
示例13: guess
/**
* 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);
}
示例14: render
/**
* 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();
}
示例15: test_jalali_after_or_before_replacer_is_applied_with_date
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());
}