本文整理汇总了PHP中Illuminate\Translation\Translator::addNamespace方法的典型用法代码示例。如果您正苦于以下问题:PHP Translator::addNamespace方法的具体用法?PHP Translator::addNamespace怎么用?PHP Translator::addNamespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Translation\Translator
的用法示例。
在下文中一共展示了Translator::addNamespace方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __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');
}
示例2: register
/**
* Register an addon.
*
* @param $path
* @param $enabled
* @param $installed
*/
public function register($path, array $enabled, array $installed)
{
if (!is_dir($path)) {
return;
}
$vendor = strtolower(basename(dirname($path)));
$slug = strtolower(substr(basename($path), 0, strpos(basename($path), '-')));
$type = strtolower(substr(basename($path), strpos(basename($path), '-') + 1));
$class = studly_case($vendor) . '\\' . studly_case($slug) . studly_case($type) . '\\' . studly_case($slug) . studly_case($type);
/* @var Addon|Module|Extension|Twig_ExtensionInterface $addon */
$addon = app($class)->setPath($path)->setType($type)->setSlug($slug)->setVendor($vendor);
// If the addon supports states - set the state now.
if ($addon->getType() === 'module' || $addon->getType() === 'extension') {
$addon->setInstalled(in_array($addon->getNamespace(), $installed));
$addon->setEnabled(in_array($addon->getNamespace(), $enabled));
}
// Bind to the service container.
$this->container->alias($addon->getNamespace(), $alias = get_class($addon));
$this->container->instance($alias, $addon);
// Load package configuration.
$this->configurator->addNamespace($addon->getNamespace(), $addon->getPath('resources/config'));
// Load system overrides.
$this->configurator->addNamespaceOverrides($addon->getNamespace(), base_path('resources/addons/' . $addon->getVendor() . '/' . $addon->getSlug() . '-' . $addon->getType()));
// Load application overrides.
$this->configurator->addNamespaceOverrides($addon->getNamespace(), $this->application->getResourcesPath('addons/' . $addon->getVendor() . '/' . $addon->getSlug() . '-' . $addon->getType() . '/config'));
// Continue loading things.
$this->provider->register($addon);
// Add the view / translation namespaces.
$this->views->addNamespace($addon->getNamespace(), $addon->getPath('resources/views'));
$this->translator->addNamespace($addon->getNamespace(), $addon->getPath('resources/lang'));
/*
* If the addon is a plugin then
* load it into Twig when appropriate.
*/
if ($addon->getType() === 'plugin') {
$this->events->listen('Anomaly\\Streams\\Platform\\View\\Event\\RegisteringTwigPlugins', function (RegisteringTwigPlugins $event) use($addon) {
$twig = $event->getTwig();
$twig->addExtension($addon);
});
}
$this->collection->put($addon->getNamespace(), $addon);
$this->events->fire(new AddonWasRegistered($addon));
}
示例3: handle
/**
* Detect the active theme and set up
* our environment with it.
*/
public function handle()
{
$admin = $this->themes->get($this->config->get('streams::themes.admin'));
$standard = $this->themes->get($this->config->get('streams::themes.standard'));
if ($admin) {
$admin->setActive(true);
}
if ($standard) {
$standard->setActive(true);
}
if ($admin && in_array($this->request->segment(1), ['installer', 'admin'])) {
$admin->setCurrent(true);
} elseif ($standard) {
$standard->setCurrent(true);
}
if ($theme = $this->themes->current()) {
$this->view->addNamespace('theme', $theme->getPath('resources/views'));
$this->translator->addNamespace('theme', $theme->getPath('resources/lang'));
$this->asset->addPath('theme', $theme->getPath('resources'));
$this->image->addPath('theme', $theme->getPath('resources'));
}
}
示例4: addNamespace
/**
* Add a new namespace to the loader.
*
* @param string $namespace
* @param string $hint
* @return void
* @static
*/
public static function addNamespace($namespace, $hint)
{
\Illuminate\Translation\Translator::addNamespace($namespace, $hint);
}
示例5: addNamespace
/**
* Add a new namespace to the loader.
*
* @param string $namespace
* @param string $hint
* @return void
*/
public function addNamespace($namespace, $hint)
{
parent::addNamespace($namespace, $hint);
$this->hints[$hint] = $namespace;
}
示例6: addNamespace
/**
* Add a new namespace to the loader.
* @param string $namespace
* @param string $hint
* @return void
*/
public function addNamespace($namespace, $hint)
{
parent::addNamespace($namespace, $hint);
$namespaceAppPath = app_path() . '/lang/' . str_replace('.', '/', $namespace);
$this->appTranslator->addNamespace($namespace, $namespaceAppPath);
}