Skip to content
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

Setting a default #25

Open
chearmstrong opened this issue Jan 23, 2018 · 2 comments
Open

Setting a default #25

chearmstrong opened this issue Jan 23, 2018 · 2 comments

Comments

@chearmstrong
Copy link

Hi,

Is it possible to have a default language fallback - for example, if the accept-language header doesn't contain one of our supported languages it uses a default. For example:

parser.pick(['en-GB'], 'en-US'); // can it return en-GB not null

Thanks.

@ArnoldZokas
Copy link
Member

Do you mean something like this?

var supportedLanguages = ['en-GB'];
var parsedAcceptLanguageHeader = 'en-US';
var defaultLanguage = 'en-GB';

parser.pick(supportedLanguages, parsedAcceptLanguageHeader) || defaultLanguage;

@chearmstrong
Copy link
Author

Yeah, that's what I'm doing at the moment. I was just wondering if parser.pick could do it. However, it's no biggie. I was thinking more if someone forgot to set the default.

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

2 participants