定制 bushbaby/bsb-localized-template-path-stack 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

bushbaby/bsb-localized-template-path-stack

Composer 安装命令:

composer require bushbaby/bsb-localized-template-path-stack

包简介

BsbLocalizedTemplatePathStack is a small ZF2 module that provides a template stack resolver which resolves to templates based on the current locale.

README 文档

README

BsbLocalizedTemplatePathStackResolver is a small ZF2 module that provides a template path stack resolver to load templates named to the active locale.

Installation

as zf2 project

BsbLocalizedTemplatePathStackResolver works with Composer. To install it into your project, just add the following line into your composer.json file:

"require": {
    "bushbaby/bsb-localized-template-path-stack-resolver": "*"
}

Then update your project by runnning composer.phar update.

Finally enable the module by adding BsbLocalizedTemplatePathStackResolver in your application.config.php file.

as standalone

For development purposes you might want to install BsbLocalizedTemplatePathStackResolver standalone. Clone the project somewhere on your computer

git clone git@github.com:bushbaby/BsbLocalizedTemplatePathStack.git BsbLocalizedTemplatePathStack
cd BsbLocalizedTemplatePathStack
curl -sS https://getcomposer.org/installer | php
git checkout develop
./composer.phar install
phpunit

Configuration

To configure the module just copy the bsb_localized_template_path_stack.local.php.dist (you can find this file in the config folder of BsbLocalizedTemplatePathStack) into your config/autoload folder, and override what you want.

Note that the resolver is attached after the zend resolvers. This means that it will be only visited when those fail to resolve to a template.

The the resolver is automaticly configured with the paths supplied in the view_manager['template_path_stack'] option and it are these paths that are used to look for a localized version of a template.

Options

fallback_locale string, defaults to null

The resolver will use this locale as fallback locale when primary locale will not resolve.

Note: When the value is not a string, the factory will get the application translator and use its fallback locale. The second value in the translator locale option represents the fallback locale within the application translator.

'translator' => array(
    'locale' => array(null, 'en_GB')
)

name_conversion_pattern string, defaults to '#DIRNAME#/#FILENAME#/#LOCALE#.#EXTENSION#'

This pattern is used to look for a template.

Example

Given a directory structure and a template name of 'application/index' the default pattern will be able to succesfully resolve a template if the current locale is one of nl_NL, de_DE or en_UK.

view
  application
	index
      index
        nl_NL.phtml
        de_DE.phtml
        en_UK.phtml

Given a directory structure and a template name of 'application/index' the conversion pattern should be changed to '#DIRNAME#/#LOCALE#/#FILENAME#.#EXTENSION#'.

view
  application
	index
      nl_NL
        index.phtml
      de_DE
        index.phtml
      en_UK
        index.phtml

This will resolve to application/index/nl_NL.phtml when the current locale is nl_NL. When the current locale is en_US resolving will fail unless a fallback locale has been set (to one of the provided templates).

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-10-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固