npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

nuxt-i18n-memory-lite

v0.1.3

Published

Lite nuxt i18n module, with messages defined in code, loaded in memory.

Readme

nuxt-i18n-memory-lite

A lightweight Nuxt module for i18n internationalization.

⚠️ Important Limitations

This module was created using vibe coding and has significant limitations:

  • Hard-coded configuration: Many features are hard-coded and not configurable
  • Only supports prefix-based routing: URLs must include the language prefix (e.g., /en/about, /ja/about)
  • Header-based language detection: When no language prefix is present in the URL, the module attempts to detect the language from HTTP headers
  • Configuration requires restart: Messages defined in nuxt.config.ts can import from other files, but any changes require a full server restart to take effect

✨ Advantages

Despite the limitations, this module offers some unique benefits:

  • Perfect for small i18n needs: Ideal for projects with a small amount of internationalization text
  • No file I/O operations: Since all messages are stored in memory and configured directly in nuxt.config.ts, there are no file system reads for i18n files
  • Serverless-friendly: The lack of file I/O makes this module perfect for serverless environments (AWS Lambda, Vercel, Netlify Functions, etc.) where file system access is limited or non-existent

📦 Installation

# npm
npm install nuxt-i18n-memory-lite

# yarn
yarn add nuxt-i18n-memory-lite

# pnpm
pnpm add nuxt-i18n-memory-lite

# bun
bun add nuxt-i18n-memory-lite

🔧 Configuration

Add the module to your nuxt.config.ts:

The locales option supports both string arrays and object arrays with code and name properties:

import { defineNuxtConfig } from 'nuxt'
import i18nMessages from './i18n.config'

export default defineNuxtConfig({
  modules: ['nuxt-i18n-memory-lite'],
  i18nMemoryLite: {
    defaultLocale: 'en',
    locales: [
      { code: 'en', name: 'English' },
      { code: 'zh', name: '中文简体' },
      { code: 'zh-TW', name: '中文繁体' },
      { code: 'ja', name: '日本語' },
    ],
    messages: i18nMessages
  }
})

Or using simple strings:

export default defineNuxtConfig({
  modules: ['nuxt-i18n-memory-lite'],
  i18nMemoryLite: {
    defaultLocale: 'en',
    locales: ['en', 'zh', 'ja'],
    messages: i18nMessages
  }
})

Create an i18n.config.ts file to define your messages.
You can place it anywhere, as long as you import it in nuxt.config.ts.

export default {
  en: {
    hello: 'Hello',
    welcome: 'Welcome to {appName}'
  },
  zh: {
    hello: '你好',
    welcome: '欢迎来到 {appName}'
  },
  'zh-TW': {
    hello: '你好',
    welcome: '歡迎來到 {appName}'
  },
  ja: {
    hello: 'こんにちは',
    welcome: '{appName}へようこそ'
  }
}

📝 Usage

In Vue Templates

<template>
  <div>
    <h1>{{ $t('hello') }}</h1>
    <p>{{ $t('welcome', { appName: 'My App' }) }}</p>
  </div>
</template>

In Composables/Setup

<script setup>
const { 
  t, 
  locale, 
  setLocale,
  availableLocales,
  localePath,
  switchLocalePath 
} = useI18n()

// Translate
console.log(t('hello'))
console.log(t('welcome', { appName: 'My App' }))

// Get current locale
console.log(locale.value)

// Get available locales
console.log(availableLocales.value) // Returns: [{ code: 'en', name: 'English' }, ...]

// Get localized path
console.log(localePath('/about')) // Returns /en/about (or current locale)

// Get path to switch locale
console.log(switchLocalePath('ja')) // Returns /ja/current-path

// Change locale
setLocale('ja')
</script>

Switching Locales

The module provides automatic locale switching based on URL prefix:

  • /en/about - English version
  • /ja/about - Japanese version
  • /zh/about - Chinese version

If no locale prefix is present, the module will attempt to detect the language from HTTP headers.

📄 License

MIT License