Socket
Socket
Sign inDemoInstall

nuxt-i18n

Package Overview
Dependencies
48
Maintainers
3
Versions
167
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    nuxt-i18n

i18n for Nuxt


Version published
Maintainers
3
Install size
5.59 MB
Created

Changelog

Source

6.28.1 (2021-08-03)

Bug Fixes

  • error on loading when using nuxt-vite (#1251) (cb67e05)

Readme

Source

nuxt-i18n logo

i18n for your Nuxt project

Features

  • Integration with vue-i18n
  • Automatic routes generation and custom paths
  • Search Engine Optimization
  • Lazy-loading of translation messages
  • Redirection based on auto-detected language
  • Different domain names for different languages
  • Storing current locale and messages with Vuex

Setup

yarn add nuxt-i18n # yarn
npm i nuxt-i18n # npm

Basic usage

Firstly, you need to add nuxt-i18n to your Nuxt config.

// nuxt.config.js

{
  modules: [
    [
      'nuxt-i18n',
      {
        locales: ['en', 'es'],
        defaultLocale: 'en',
        vueI18n: {
          fallbackLocale: 'en',
          messages: {
            en: {
              greeting: 'Hello world!'
            },
            es: {
              greeting: '¡Hola mundo!'
            }
          }
        }
      }
    ]
  ]
}

Then you can start using nuxt-i18n in your Vue components!

<template>
  <main>
    <h1>{{ $t('greeting') }}</h1>

    <nuxt-link
      v-if="$i18n.locale !== 'en'"
      :to="switchLocalePath('en')"
    >
      English
    </nuxt-link>

    <nuxt-link
      v-if="$i18n.locale !== 'es'"
      :to="switchLocalePath('es')"
    >
      Español
    </nuxt-link>
  </main>
</template>

If you would like to find out more about how to use nuxt-i18n, check out the docs!

Issues, questions & requests

If you have any questions or issues, check out Discord server.

License

MIT License - Copyright (c) Nuxt Community

FAQs

Last updated on 03 Aug 2021

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc