germania-kg/localisation
Composer 安装命令:
composer require germania-kg/localisation
包简介
Localisation interfaces, classes and factory
README 文档
README
Germania KG · Localisation
Installation
$ composer require germania-kg/localisation
Interfaces
LocalisationInterface
<?php namespace Germania\Localisation; interface LocalisationInterface { // Sets the fully-qualified Locale string such as `en_GB`. public function setLocale( string $locale ) : LocalisationInterface; // Returns a fully-qualified Locale string such as `en_GB`. public function __toString(); // Returns a fully-qualified Locale string such as `en_GB`. public function getLocale() : string; // Returns ISO 639-1 language code such as `en`. public function getLanguage() : string; // Returns an ISO 3166-1 alpha-2 country/region code such as `GB`, if possible. public function getRegion() : ?string; }
LocalisationFactoryInterface
<?php namespace Germania\Localisation; use Germania\Localisation\LocalisationInterface as Localisation; use Psr\Http\Message\ServerRequestInterface as Request; interface LocalisationFactoryInterface { /** * @param ServerRequestInterface $request PSR-7 Server Request * @return \Germania\Localisation\LocalisationInterface * @throws \Germania\Localisation\FactoryException */ public function createFromRequest( Request $request ) : Localisation; }
Factories
NegotiationLocalisationFactory
Class NegotiationLocalisationFactory implements LocalisationFactoryInterface. The constructor requires an instance of Will Durand´s LanguageNegotiator and an array with available language codes and locale strings.
Setup
<?php use Germania\Localisation\NegotiationLocalisationFactory; use Negotiation\LanguageNegotiator; $negotiator = new LanguageNegotiator; $available = array( "de" => "de_DE", "de-de" => "de_DE", "de_DE" => "de_DE" ); $factory = new NegotiationLocalisationFactory( $negotiator, $available); // Optional, as factory would use the first available locale from above, // e.g. "de_DE" $factory->setDefaultLocale("en_US");
Usage
<?php use Germania\Localisation\ExceptionInterface; use Psr\Http\Message\ServerRequestInterface; try { $server_request = ...; // $localisation = $factory->createFromRequest( $server_request ); } catch (\Germania\Localisation\ExceptionInterface $e) { echo get_class($e); // Germania\Localisation\FactoryException }
Development
$ git clone git@github.com:GermaniaKG/Localisation.git
$ cd Localisation
$ composer install
germania-kg/localisation 适用场景与选型建议
germania-kg/localisation 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 44 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 12 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 germania-kg/localisation 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 germania-kg/localisation 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 44
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-12-14