simotod / slim-multilanguage
Multilanguage support for slim framework 2
dev-master
2016-01-24 23:10 UTC
Requires
- php: >=5.3.0
- slim/slim: >=2.3.0
This package is auto-updated.
Last update: 2024-10-16 07:15:32 UTC
README
This is an extension to the SLIM framework vers.2 to enable simple route localization.
##Installation Add dependecy to composer.json
{ "require": { "simotod/slim-multilanguage": "dev-master" } }
##Usage
require 'vendor/autoload.php'; $defaultLanguage = "en"; $availableLanguages = array("en", "it"); $app = new \Slim\Slim(); $app->add(new \SimoTod\Language\LanguageMiddleware($availableLanguages, $defaultLanguage)); $app->get('/hello', function () use ($app) { //This route works for "/hello", "/en/hello", "/it/hello" if($app->locale->get() == "it") { echo "Ciao mondo!"; } else { echo "Hello world!"; } }); $app->run();