sprintf-formatter v2.0.1 provides a formatter for vue-i18n that uses sprintf syntax, enabling printf-style string formatting in translations. It works with Vue 2 and vue-i18n v8.x, ships TypeScript types, and offers both ESM and UMD builds. Compared to vue-i18n's built-in formatter, it allows positional and named placeholders with sprintf formatting options. The package is stable but relies on an optional dependency on sprintf-js, which is bundled as part of vue-i18n in some setups. Since version 2, it only supports Vue 2 and vue-i18n v8, and does not support Vue 3.
npm install sprintf-formatterNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to install and configure SprintfFormatter with vue-i18n in a Vue 2 app, demonstrating sprintf-style placeholders.
Use the built-in MessageFormat or implement a custom formatter for vue-i18n v9.
Create a plugin file exporting a function that returns an object with the formatter property.
Ensure only one version of sprintf is used; consider removing explicit sprintf-js dependency.
Use positional parameters in the translation string and pass values as an array.
import SprintfFormatter from 'sprintf-formatter'; new VueI18n({ formatter: new SprintfFormatter() })Use SprintfFormatter instance, which implements the format method required by vue-i18n.
Add Vue.use(VueI18n) before new VueI18n().