Socket
Book a DemoInstallSign in
Socket

nuxt-i18n-preferred

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuxt-i18n-preferred

Add preferred locale

latest
Source
npmnpm
Version
0.3.0
Version published
Maintainers
1
Created
Source

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

Keywords

vue

FAQs

Package last updated on 16 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts