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

Fallback scheme #12

Open
peterver opened this issue Mar 7, 2017 · 1 comment
Open

Fallback scheme #12

peterver opened this issue Mar 7, 2017 · 1 comment

Comments

@peterver
Copy link

peterver commented Mar 7, 2017

How would i go about the following,

I have the following locales defined (en.json, nl.json, fr.json), If a user pops up using Accept-Language nl-BE it will fallback to en due to it being the default language.

How do i make it so that nl-BE (iso 639-4) falls back to the language code nl ? Do i use the modes array for this ?

@alexc101
Copy link

alexc101 commented Oct 5, 2017

I found a solution:

 modes: [
        function () {
            let locale = this.getLocaleFromHeader();
            // if locale undefined set to default
            if(!locale) return 'en';
            // if locale ('en-GB' || 'en-US' etc return 'en')
            if(locale.length > 2) locale = locale.slice(0, 2);

            return locale;
        }
    ]

Not sure if advisable to do like this?

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