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

@nuxtjs/i18n

Package Overview
Dependencies
Maintainers
9
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nuxtjs/i18n

i18n for Nuxt

  • 8.0.0-rc.9
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
232K
decreased by-0.28%
Maintainers
9
Weekly downloads
 
Created

What is @nuxtjs/i18n?

@nuxtjs/i18n is a Nuxt.js module that provides internationalization (i18n) support for your Nuxt.js applications. It allows you to easily add multilingual support to your application, manage translations, and handle locale switching.

What are @nuxtjs/i18n's main functionalities?

Basic Setup

This code demonstrates the basic setup of the @nuxtjs/i18n module in a Nuxt.js project. It configures two locales (English and French) and sets English as the default locale. It also provides translation messages for the 'welcome' key in both languages.

{
  "modules": [
    "@nuxtjs/i18n"
  ],
  "i18n": {
    "locales": [
      { "code": "en", "name": "English" },
      { "code": "fr", "name": "Français" }
    ],
    "defaultLocale": "en",
    "vueI18n": {
      "fallbackLocale": "en",
      "messages": {
        "en": { "welcome": "Welcome" },
        "fr": { "welcome": "Bienvenue" }
      }
    }
  }
}

Locale Switching

This code demonstrates how to switch between locales in a Nuxt.js component using @nuxtjs/i18n. The $t function is used to translate the 'welcome' key, and the $i18n.setLocale method is used to change the current locale.

<template>
  <div>
    <p>{{ $t('welcome') }}</p>
    <button @click="$i18n.setLocale('en')">English</button>
    <button @click="$i18n.setLocale('fr')">Français</button>
  </div>
</template>

Dynamic Route Localization

This code demonstrates how to configure dynamic route localization with @nuxtjs/i18n. It maps the root path ('/') to '/accueil' for the French locale, allowing for localized URLs.

{
  "pages": {
    "index": {
      "en": "/",
      "fr": "/accueil"
    }
  }
}

Other packages similar to @nuxtjs/i18n

FAQs

Package last updated on 10 Dec 2023

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