Download the PHP package bushbaby/bsb-localized-template-path-stack without Composer
On this page you can find all versions of the php package bushbaby/bsb-localized-template-path-stack. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bushbaby/bsb-localized-template-path-stack
More information about bushbaby/bsb-localized-template-path-stack
Files in bushbaby/bsb-localized-template-path-stack
Package bsb-localized-template-path-stack
Short Description BsbLocalizedTemplatePathStack is a small ZF2 module that provides a template stack resolver which resolves to templates based on the current locale.
License MIT
Homepage https://github.com/bushbaby/BsbLocalizedTemplatePathStack
Informations about the package bsb-localized-template-path-stack
BsbLocalizedTemplatePathStack
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 [email protected]: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.
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).
All versions of bsb-localized-template-path-stack with dependencies
ext-intl Version *
zendframework/zend-mvc Version >=2.2.2
zendframework/zend-servicemanager Version >=2.2.2
zendframework/zend-view Version >=2.2.2