Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nuxt-i18n

Package Overview
Dependencies
Maintainers
2
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuxt-i18n

i18n for Nuxt

  • 6.13.12
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
30K
increased by9.03%
Maintainers
2
Weekly downloads
 
Created
Source

nuxt-i18n logo

nuxt-i18n

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!

Contributing

All contributions are welcome! If you would like to make some changes, follow these steps:

  • Fork the project and clone it in your existing Nuxt project:
cd my-nuxt-project
mkdir modules
git clone git@github.com:<username>/i18n-module.git modules/i18n-module # ssh
git clone https://github.com/<username>/i18n-module.git modules/i18n-module # https
  • Edit your Nuxt config to use the local module:
// nuxt.config.js

{
  modules: [
    ['./modules/i18n-module', {
      // options...
    }]
  ]
}
  • Install the module's dependencies:
cd modules/i18n-module/
yarn # yarn
npm i # npm
  • Create a new branch for your changes:
git checkout -b my-new-feature
  • Code, code, code!
  • Run ESLint and Jest
yarn lint && yarn test # yarn
npm run lint && npm test # npm
  • Commit and push your changes
  • Submit awesome PRs

Documentation

  • Fork and clone the project:
git clone git@github.com:<username>/i18n-module.git # ssh
git clone https://github.com/<username>/i18n-module.git # https
  • Install the dependencies:
cd i18n-module
yarn # yarn
npm i # npm
  • Create a new branch for your changes:
git checkout -b my-new-feature
  • Start the docs server:
yarn docs:dev # yarn
npm run docs:dev # npm
  • Write some doc by editing files in docs/ directory

If you're adding new pages, make sure you add them to the table of contents in docs/.vuepress/config

  • Commit and push your changes
  • Once you're done, submit that shiny PR!

Issues, questions & requests

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

License

MIT License - Copyright (c) Nuxt Community

FAQs

Package last updated on 22 Aug 2020

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc