nuxt-i18n-preferred

Add preferred locale
550
Install
npm install nuxt-i18n-preferred
Latest Version:0.3.0
Vue:2
License:MIT
Last Updated:Jan 7, 2023
Links: GitHub  ·  npm
Maintainer: shrpne

nuxt-i18n-preferred

NPM Package License: MIT

Preferred locale for nuxt-i18n. Add middleware, that save preferred locale between sessions, when user comes back, it will check if preferred locale is set and redirect to it. Redirect works only on root page for now. Add enhanced preferredPath method instead of localePath.

Install

NPM

npm install nuxt-i18n-preferred

Register Nuxt module

// nuxt-config.js
module.exports = {
    modules: [
        ['nuxt-i18n-preferred', {
            routesNameSeparator: '___',
            languageCookieKey: 'nuxt_i18n_preferred_locale',
            detectBrowserLanguage: false,        
        }],
        ['nuxt-i18n', {
            // options
        }],
    ],
};

Usage

.preferredPath()

First check preferred locale, than check current locale, than check default locale. In comparison with nuxt-i18n's localePath, which check only current locale.

<nuxt-link :to="preferredPath('index')">{{ $t('home') }}</nuxt-link>

License

MIT License

Related Packages

@i18n-micro/core

Core utilities for translations, formatting, and locale routing in Nuxt I18n Mic...

199,259 251
@i18n-micro/route-strategy

Locale-aware route generator for Nuxt i18n micro

117,046 251
@vintl/nuxt

Nuxt Module for VIntl integration

9,922 2
@brc-dd/nuxt-i18n

Minimal module for i18n with locale auto-imports & localized routing

898 12
@nuxtjs/i18n

Internationalization for Nuxt

23,877,608 2,085

Version History

Version Released Vue License
0.3.0 ^2 MIT
0.2.0 ^2.6.10 MIT
0.1.2 ^2.6.10 MIT
0.1.1 ^2.6.10 MIT
0.1.0 ^2.0.0 MIT
Pre-releases (1)
Version Released License
0.0.1-security