Mongoose schema plugin for multilingual (i18n) fields, version 3.3.0. This plugin allows you to define string fields that store translations in multiple languages as a subdocument, while presenting them as virtual string properties. It supports Mongoose versions 4, 5, and 6 via peer dependencies. Languages are configured via an option array, with optional default language and fallback behavior. The plugin is lightweight and specific to Mongoose, offering a simple API for reading and writing translations using standard get/set methods. Alternative packages like mongoose-i18n or mongoose-multilingual exist, but mongoose-intl is one of the oldest and most used plugins for this purpose.
npm install mongoose-intlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to install, configure, and use mongoose-intl plugin with multilingual fields, including setting and reading translations.
Update languages option to an array of strings, e.g., ['en', 'fr'].
Upgrade mongoose to version 6 or later.
Ensure your languages array is ordered by priority if using fallback=true.
Set schema option: { toJSON: { virtuals: true } } or use post.toObject({ virtuals: true }).Ensure fields with intl: true are of type String.
Use `const mongooseIntl = require('mongoose-intl');` (default export).Use `model.get/set` with language suffix, e.g., `post.set('title.de', 'value')`. Do not modify the internal object directly.Add the plugin to the schema before creating the model: `schema.plugin(mongooseIntl, { languages: ... }).`