Skip to content
Permalink
Browse files

AcceptHeaderResolver: accept Http\IRequest

  • Loading branch information...
fprochazka committed Jul 5, 2015
1 parent f496162 commit 300d8eba97d7c4ed0975585091b5c7e655666d91
Showing with 6 additions and 2 deletions.
  1. +6 −2 src/Kdyby/Translation/LocaleResolver/AcceptHeaderResolver.php
@@ -29,9 +29,9 @@ class AcceptHeaderResolver extends Nette\Object implements Kdyby\Translation\IUs
/**
* @param Nette\Http\Request $httpRequest
* @param Nette\Http\IRequest $httpRequest
*/
public function __construct(Nette\Http\Request $httpRequest)
public function __construct(Nette\Http\IRequest $httpRequest)
{
$this->httpRequest = $httpRequest;
}
@@ -44,6 +44,10 @@ public function __construct(Nette\Http\Request $httpRequest)
*/
public function resolve(Kdyby\Translation\Translator $translator)
{
if (!method_exists($this->httpRequest, 'detectLanguage')) {
return NULL;
}
$short = array_map(function ($locale) {
return substr($locale, 0, 2);
}, $translator->getAvailableLocales());

2 comments on commit 300d8eb

@enumag

This comment has been minimized.

Copy link
Member

replied Jul 14, 2015

In my opinion the detectLanguage method should be copied to this class.

@fprochazka

This comment has been minimized.

Copy link
Member Author

replied Jul 14, 2015

@enumag you're probably right, this was more of a hotfix.

Please sign in to comment.
You can’t perform that action at this time.