承接 validus/translation 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

validus/translation

Composer 安装命令:

composer require validus/translation

包简介

Provides translation for your Expressive project.

README 文档

README

Provides translations for zend expressive projects.

SensioLabsInsight

Packagist GitHub license Build Status Scrutinizer Code Quality Code Intelligence Status Coverage Status

Symfony Translation factories for PSR-11 with Zend configuration provider.

Installation

The easiest way to install this package is through composer:

$ composer require validus/translation

Configuration

A complete example configuration can be found in example/full-config.php. Please note that the values in there are the defaults, and don't have to be supplied when you are not changing them. Keep your own configuration as minimal as possible. A minimal configuration can be found in example/simple-config.php

If your application uses the zend-component-installer Composer plugin, your configuration is complete; the shipped Validus\Translation\ConfigProvider registers the translation service.

Usage

Validus Translation provides middleware consuming PSR-7 HTTP message instances, via implementation of PSR-15 interfaces.

Adding the middleware to your application

you may pipe this middleware anywhere in your application. If you want to have it available anywhere, pipe it early in your application, prior to any routing. As an example, within Expressive, you could pipe it in the config/pipeline.php file:

$app->pipe(\Validus\Translation\Middleware\TranslatorMiddleware::class);

Within Expressive, you can do this when routing, in your config/routes.php file, or within a delegator factory:

$app->post('/login', [
    \Validus\Translation\Middleware\TranslatorMiddleware::class,
    \User\Middleware\LoginHandler::class
]);

Accessing the translator

if you have added the middleware to your application, you can access the translator from the request attributes :

     public function handle(ServerRequestInterface $request): ResponseInterface
     {
        $translator = $request->getAttribute(TranslatorMiddleware::TRANSLATOR_ATTRIBUTE);
        // or simply 
        $translator = $request->getAttribute('translator');
        
        // do your thing 
        
        return $response;
     }

or via the container :

use Symfony\Component\Translation\TranslatorInterface;

$translator = $container->get(TranslatorInterface::class);

统计信息

  • 总下载量: 15
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-09-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固