Fluent Vue Internationalization Unplugin

1.4.1 · active · verified Sun Apr 19

unplugin-fluent-vue is a build tool plugin that integrates Fluent.js for internationalization (i18n) into Vue.js projects. It provides support for defining Fluent messages directly within Vue Single File Components (SFCs) using custom blocks, or by referencing external `.ftl` (Fluent Translation List) files. It currently stands at version 1.4.1 and sees regular maintenance releases, with the latest update in April 2026. This unplugin differentiates itself by offering a unified API for Vite, Webpack, and Rollup, leveraging the unplugin ecosystem. Key features include syntax checking for Fluent messages, optional in-build FTL parsing, and dedicated plugins for SFC-based or external file-based message definitions, making it a flexible choice for Vue i18n with Fluent.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to configure unplugin-fluent-vue in a Vite project, showcasing both SFC-based and external FTL file approaches for i18n.

import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { ExternalFluentPlugin, SFCFluentPlugin } from 'unplugin-fluent-vue/vite';
import path from 'path';

export default defineConfig({
  plugins: [
    vue(),
    // Option 1: Define messages within Vue SFCs using <fluent> blocks
    SFCFluentPlugin({
      blockType: 'fluent', // default 'fluent'
      checkSyntax: true,   // default true
      parseFtl: false      // default false
    }),
    // Option 2: Define messages in external .ftl files
    ExternalFluentPlugin({
      baseDir: path.resolve(__dirname, 'src'), // required: base directory for Vue files
      ftlDir: path.resolve(__dirname, 'src/locales'), // required: directory with ftl files
      locales: ['en', 'da'], // required: list of supported locales
      checkSyntax: true,     // default true
      parseFtl: false        // default false. Set to true to pre-parse ftl at build time.
    })
  ]
});

// Example Vue SFC (src/App.vue):
// <template>
//   <p>{{ $t('greeting', { name: 'World' }) }}</p>
// </template>
// <script setup>
// import { useFluent } from 'fluent-vue';
// const { $t } = useFluent();
// </script>
// <fluent>
// greeting = Hello, { $name }!
// </fluent>

// Example FTL file (src/locales/en/messages.ftl):
// greeting = Hello, { $name } from FTL!

view raw JSON →