All skills
skilld-dev avatar

/vue-i18n-skilld

@b9c39cb

Use when writing or debugging code that imports vue-i18n (Vue 3 internationalization). Covers createI18n, useI18n, message syntax, i18n-t/i18n-n/i18n-d components, pluralization, datetime and number formatting, TypeScript schemas, lazy loading, bundle optimization, and v10/v11/v12 migration.

Use this Skill: https://skilld.dev/gh/skilld-dev/vue-ecosystem-skills/vue-i18n-skilld

This session only. Nothing lands on disk.

referencesoptimization.md

≈692 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Optimization and builds

Bundle size: tree shaking

The esm-bundler builds expose compile-time feature flags (README.md:62-74):

Flag Default Controls
__VUE_I18N_FULL_INSTALL__ true Install components and directives with the plugin
__VUE_I18N_LEGACY_API__ true Legacy API support; set false in Composition-only apps
__INTLIFY_DROP_MESSAGE_COMPILER__ false Drop the message compiler when all messages are pre-compiled

Replace with boolean literals (never strings) via Vite define, webpack DefinePlugin, or @rollup/plugin-replace:

// vite.config.js
export default {
  define: {
    __VUE_I18N_FULL_INSTALL__: true,
    __VUE_I18N_LEGACY_API__: false,
    __INTLIFY_DROP_MESSAGE_COMPILER__: true // only with pre-compiled messages
  }
}

https://vue-i18n.intlify.dev/guide/advanced/optimization.html#reduce-bundle-size-with-tree-shaking

Pre-compile messages

@intlify/unplugin-vue-i18n compiles locale message resources (JSON / SFC <i18n> blocks) at build time. Required for strict CSP (no runtime eval/new Function) and improves runtime performance. Since v10 the runtime JIT-compiles string messages by default; pre-compiling keeps that off the hot path (https://vue-i18n.intlify.dev/guide/migration/breaking10.html#default-enable-for-jit-compilation).

Lazy loading locales

export async function loadLocale(i18n, locale) {
  if (i18n.global.availableLocales.includes(locale)) return
  const messages = await import(`./locales/${locale}.json`)
  i18n.global.setLocaleMessage(locale, messages.default)
  // or mergeLocaleMessage to add keys without replacing
}

Load in a router guard or locale switcher; keep initial bundle to the default locale. Keep the html lang attribute in sync on switch. https://vue-i18n.intlify.dev/guide/advanced/lazy.html

Distribution files

Package exports (package.json:63-83, README.md:5-55):

  • Bundlers (Vite, webpack, Rollup): root import resolves dist/vue-i18n.mjs (ESM). The JIT compiler is included; pair with __INTLIFY_DROP_MESSAGE_COMPILER__ when pre-compiled.
  • CDN <script>: dist/vue-i18n.global.js exposes VueI18n; .prod.js for production; .runtime.global.js if messages are pre-compiled.
  • Node CJS: dist/vue-i18n.cjs (dev) / vue-i18n.prod.cjs (prod), auto-selected by NODE_ENV via index.js:3-6. CJS is slated for deprecation; prefer dist/vue-i18n.node.mjs for ESM Node usage (README.md:55).
  • Global builds inline @intlify/*: import everything from the single file only.

SSR notes

  • The v-t directive required extra SSR settings and is deprecated anyway; avoid it.
  • Use the same lazy-load discipline on the server; set response Accept-Language handling consistently.

Source: SKILL.md on GitHub

No alerts9d3 checks · Risk SAFE
  • Gen Agent Trust Hub9d

    The skill is a comprehensive documentation set for the vue-i18n (Vue 3) internationalization library. It provides correct usage guidelines, migration paths, and security advice regarding XSS prevention when handling HTML in translations. No malicious patterns, obfuscation, or unauthorized access attempts were found.

  • Socket9d

    No alerts

  • Snyk9d

    Risk: LOW · No issues

Signed by skilld at b9c39cb. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last week.

Activeupdated last week

README badge

README badge for skilld-dev/vue-ecosystem-skills/vue-i18n-skilld