2017 © Pedro Peláez
 

library 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.

image

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.

  • Tuesday, November 26, 2013
  • by bushbaby
  • Repository
  • 2 Watchers
  • 1 Stars
  • 509 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

BsbLocalizedTemplatePathStack

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

Installation

as zf2 project

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

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

Then update your project by runnning composer.phar update., (*3)

Finally enable the module by adding BsbLocalizedTemplatePathStackResolver in your application.config.php file., (*4)

as standalone

For development purposes you might want to install BsbLocalizedTemplatePathStackResolver standalone. Clone the project somewhere on your computer, (*5)

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., (*6)

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., (*7)

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., (*8)

Options

fallback_locale string, defaults to null, (*9)

The resolver will use this locale as fallback locale when primary locale will not resolve., (*10)

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., (*11)

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

name_conversion_pattern string, defaults to '#DIRNAME#/#FILENAME#/#LOCALE#.#EXTENSION#', (*12)

This pattern is used to look for a template., (*13)

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., (*14)

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#'., (*15)

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)., (*16)

The Versions

26/11 2013

dev-master

9999999-dev https://github.com/bushbaby/BsbLocalizedTemplatePathStack

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

  Sources   Download

MIT

The Requires

 

The Development Requires

template zf2 module i18n

26/11 2013

1.0.1

1.0.1.0 https://github.com/bushbaby/BsbLocalizedTemplatePathStack

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

  Sources   Download

MIT

The Requires

 

The Development Requires

template zf2 module i18n

26/11 2013

dev-develop

dev-develop https://github.com/bushbaby/BsbLocalizedTemplatePathStack

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

  Sources   Download

MIT

The Requires

 

The Development Requires

template zf2 module i18n

13/10 2013

1.0.0

1.0.0.0 https://github.com/bushbaby/BsbLocalizedTemplatePathStack

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

  Sources   Download

MIT

The Requires

 

The Development Requires

template zf2 module i18n