Product Delivery
Targeted Sales
Collicitudin vel metus scelerisque ante commodo.
In Progress25% Completed
i18n on init examples
i18next is a very popular internationalization library for browser or any other javascript environment (eg. node.js). i18next is exported in UMD format and can be loaded via commonjs, requirejs (AMD) or will be added to global scope window.i18next.
This example demonstrate how to set language on init. The lookup order for keys is always: 1 - en-US language + region, 2 - en language only, 3. - fallback thats defined in options.fallbackLng (string or array of fallback language). Basically, lng option sets a specified language that is loaded on every initialization.
<div aria-labelledby="dropdown-flag" class="dropdown-menu dropdown-menu-right">
<a href="#" class="dropdown-item">
<i class="flag-icon flag-icon-us"></i> English
</a>
<a href="#" class="dropdown-item">
<i class="flag-icon flag-icon-es"></i> Spanish
</a>
<a href="#" class="dropdown-item">
<i class="flag-icon flag-icon-pt"></i> Portuguese
</a>
<a href="#" class="dropdown-item">
<i class="flag-icon flag-icon-fr"></i> French
</a>
</div>
i18next
.use(window.i18nextXHRBackend)
.init({
debug: true,
lng: 'en',
fallbackLng: false,
backend: {
loadPath: "robust-assets/locales/{{lng}}/{{ns}}.json",
},
returnObjects: true
},
function (err, t) {
// Initialize Localization
jqueryI18next.init(i18next, $);
});