Skip to content

Browser's Locale: add Region #169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
rbayley opened this issue Jan 22, 2020 · 0 comments
Open

Browser's Locale: add Region #169

rbayley opened this issue Jan 22, 2020 · 0 comments

Comments

@rbayley
Copy link

rbayley commented Jan 22, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant