@open-xchange/vite-plugin-po2json
v1.1.5
Published
A Vite plugin to load po files into our gettext based dictionary implementation.
Maintainers
Keywords
Readme
Vite Plugin PO2JSON
A Vite plugin that compiles GNU gettext PO files into JSON translation dictionaries for App Suite UI. Forked from @open-xchange/rollup-plugin-po2json and adapted for Vite 8 / Rolldown.
Install
pnpm i "@open-xchange/vite-plugin-po2json"How to use
// in the vite.config.js
import vitePluginPo2json from '@open-xchange/vite-plugin-po2json'
export default defineConfig({
plugins: [vitePluginPo2json({
poFiles: 'i18n/*.po'
})]
})Options
- poFiles
<string>(required) Glob pattern pointing to the PO files to compile. - outFile
<string>Output filename for the extracted POT file. Default:'i18n.pot' - defaultDictionary
<string>Name of the default translation dictionary. Default:'i18n' - defaultLanguage
<string>The default language to use. Default:'en_US' - headers
<object>Headers to include in the generated POT file. Default:{ 'Content-Type': 'text/plain; charset=UTF-8', 'Content-Transfer-Encoding': '8bit' } - includeFuzzy
<boolean>Whether to include fuzzy translations in the output. Default:false
How to test
pnpm testTranslator comments in Vue templates
Translator hints written as HTML comments (<!-- #. … -->) directly above
a gt(...) call in a template are picked up and attached to the extracted
msgid, in addition to the usual // #. … comments in <script>:
<template>
<!-- #. Opens the Manage categories dialog -->
<button :title="gt('Manage categories')">…</button>
</template>Multiple comments before the same call are collected in order; a comment is attached to the first translatable expression that follows it.
