Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
nuxt-i18n-micro
Advanced tools
Nuxt I18n Micro is a lightweight, high-performance internationalization module for Nuxt, designed to handle multi-language support with minimal overhead, fast build times, and efficient runtime performance.
Nuxt I18n Micro
is a fast, simple, and lightweight internationalization (i18n) module for Nuxt. Despite its compact size, it's designed with large projects in mind, offering significant performance improvements over traditional i18n solutions like nuxt-i18n
. The module was built from the ground up to be highly efficient, focusing on minimizing build times, reducing server load, and shrinking bundle sizes.
The Nuxt I18n Micro
module was created to address critical performance issues found in the original nuxt-i18n
module, particularly in high-traffic environments and projects with large translation files. Key issues with nuxt-i18n
include:
To showcase the efficiency of Nuxt I18n Micro
, we conducted tests under identical conditions. Both modules were tested with a 10MB translation file on the same hardware.
Nuxt I18n:
Nuxt I18n Micro:
Nuxt I18n:
Nuxt I18n Micro:
These results clearly demonstrate that Nuxt I18n Micro
significantly outperforms the original module in every critical area.
Nuxt I18n Micro
is designed for large-scale projects, focusing on performance and efficiency.dev
mode if not present.Install the module in your Nuxt application with:
npm install nuxt-i18n-micro
Then, add it to your nuxt.config.ts
:
export default defineNuxtConfig({
modules: [
'nuxt-i18n-micro',
],
i18n: {
locales: [
{ code: 'en', iso: 'en-US', dir: 'ltr' },
{ code: 'fr', iso: 'fr-FR', dir: 'ltr' },
{ code: 'ar', iso: 'ar-SA', dir: 'rtl' },
],
defaultLocale: 'en',
translationDir: 'locales',
meta: true,
},
})
That's it! You're now ready to use Nuxt I18n Micro in your Nuxt app.
Translations are organized into global and page-specific files:
/locales
/pages
/index
en.json
fr.json
ar.json
/about
en.json
fr.json
ar.json
en.json
fr.json
ar.json
locales/{locale}.json
(e.g., locales/en.json
). Used for common texts shared across multiple pages, such as menus.locales/pages/{routeName}/{locale}.json
(e.g., locales/pages/index/en.json
). These are used for translations specific to individual pages.$getLocale()
Returns the current locale code.
const locale = $getLocale()
$getLocales()
Returns an array of all available locales configured in the module.
const locales = $getLocales()
$t(key: string, params?: Record<string, any>, defaultValue?: string)
Fetches a translation for the given key. Optionally interpolates parameters into the translation.
const welcomeMessage = $t('welcome', { username: 'Alice', unreadCount: 5 })
$tc(key: string, count: number, defaultValue?: string)
Fetches a pluralized translation for the given key based on the count.
const appleCountMessage = $tc('apples', 10)
$switchLocale(locale: string)
Switches to the given locale and redirects the user to the appropriate localized route.
$switchLocale('fr')
$localeRoute(to: RouteLocationRaw): RouteLocationRaw
Generates a localized route object based on the target route.
const localizedRoute = $localeRoute({ name: 'index' })
$mergeTranslations(newTranslations: Translations)
Merges new translations into the existing translation cache for the current route and locale.
$mergeTranslations({
welcome: 'Bienvenue, {username}!'
})
The module accepts the following options in the Nuxt configuration:
code
, and optionally, iso
and dir
(for RTL/LTR).
locales: [
{ code: 'en', iso: 'en-US', dir: 'ltr' },
{ code: 'fr', iso: 'fr-FR', dir: 'ltr' },
{ code: 'ar', iso: 'ar-SA', dir: 'rtl' }
]
alternate
links).'en'
).'locales'
).true
, automatically detects the user's preferred language and redirects accordingly.Nuxt I18n Micro
offers a highly efficient, minimalist approach to internationalization in Nuxt applications. By focusing on performance and simplicity, it provides a powerful alternative to heavier, more complex i18n solutions. Whether you're building a small website or a large-scale application, Nuxt I18n Micro
helps you manage multilingual content with ease.
For more details and updates, visit the Nuxt I18n Micro GitHub repository.
FAQs
Nuxt I18n Micro is a lightweight, high-performance internationalization module for Nuxt, designed to handle multi-language support with minimal overhead, fast build times, and efficient runtime performance.
We found that nuxt-i18n-micro demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.