### i18n Fallback

### $5,668

Sales

#### Set Fallback Language

This example demonstrates how to set fallback language. Language to lookup key if not found on set language, can be a string `(en)`, an array `(['fe', 'en'])` or object defining fallbacks and a default `( { 'de-CH': ['fr', 'it'], 'zh-HANT': ['zh-HANS', 'en'], 'default': ['en'] } ).` In this example Arabic, Dutch or Italian language files don't exist in /data/locales/ folder. When one of these languages is selected, English language specified in fallbackLng option will be loaded.

##### Example Markup

                                <div aria-labelledby="dropdown-flag" class="dropdown-menu dropdown-menu-right">
                                    <a href="#" class="dropdown-item">
                                        <i class="flag-icon flag-icon-gb"></i> English
                                    </a>
                                    <a href="#" class="dropdown-item">
                                        <i class="flag-icon flag-icon-ar"></i> Arabic
                                    </a>
                                    <a href="#" class="dropdown-item">
                                        <i class="flag-icon flag-icon-nl"></i> Dutch
                                    </a>
                                    <a href="#" class="dropdown-item">
                                        <i class="flag-icon flag-icon-it"></i> Italian
                                    </a>
                                </div>

##### Js Code For Switching

                                i18next
                                    .use(window.i18nextXHRBackend)
                                    .init({
                                        debug: true,
                                        fallbackLng: 'en',
                                        backend: {
                                            loadPath: "../../../app-assets/data/locales/{{lng}}/{{ns}}.json",
                                        },
                                        returnObjects: true
                                    },
                                    function (err, t) {
                                        // Initialize Localization
                                        jqueryI18next.init(i18next, $);
                                    });