Waavi/translation

Browser's Locale: add Region

Opened this issue · 0 comments

Hi,

I noticed TranslationMiddleware detects browser locale with following code at line 86.

$browserLocale = substr($request->server('HTTP_ACCEPT_LANGUAGE'), 0, 2);

is it possible to use config/translator variables to also support full HTTP_ACCEPT_LANGUAGE info?

Maybe something like this:

if( config('translator.browserLocale', true) ){

    $browserLocale = $request->server('HTTP_ACCEPT_LANGUAGE');

}else{

    $browserLocale = substr($request->server('HTTP_ACCEPT_LANGUAGE'), 0, 2);

}

By setting config data default to true we are supporting backward compatibility, correct?

This way we could choose from getting 'en' or 'en_US'

I havent checked if languageRepository->isValidLocale() requires a two character data.

Anyway, hope this helps improve even better your package.

warm regards