Created
December 15, 2017 15:48
-
-
Save tuupola/03e004daf3baaf87e8c2b41ff3f74230 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Set default locale from the first parameter in url. */ | |
$app->add(function ($request, $response, $next) { | |
$params = $request->getAttribute("routeInfo")[2]; | |
if (empty($params["locale"])) { | |
Locale::setDefault("et"); | |
} else { | |
Locale::setDefault($params["locale"]); | |
} | |
return $next($request, $response); | |
}); | |
$app->get("/{locale:et|lv|lt|ru-ee|ru-lv|ru-lt}[/{dealer}]", function ($request, $response, $arguments) { | |
$data["locale"] = Locale::getDefault(); /* ru-ee */ | |
$data["language"] = Locale::getPrimaryLanguage($data["locale"]); /* ru */ | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment