Skip to content

Internationalization ​

Nine locales ship built in – ar, de, en, es, fr, he, ja, ko, and zh – with interpolation, RTL, and Intl number formatting. Every user-facing string is a typed key on LocaleMessages.

Resolution order for any string: per-component messages → plugin messages → built-in bundle for locale → en fallback. Missing keys fall back to English.

Override individual strings ​

vue
<PdfViewer
  :messages="{
    download: 'Export',
    thumbnailLabel: 'Sheet {page}',
  }"
/>

Add a locale ​

ts
import { PdfViewer, type LocaleMessages } from 'vue-pdfz'
import { en } from 'vue-pdfz/locales/en' // built-in bundles are tree-shakeable

const it: LocaleMessages = { ...en, nextPage: 'Pagina successiva' /* ... */ }

// Per instance:
// <PdfViewer locale="it" :messages="it" />

// Or app-wide via the plugin:
// app.use(VuePdfz, { locale: 'it', messages: { it } })

Add an optional vue-i18n adapter ​

With an adapter to a host vue-i18n instance, keys resolve as ${prefix}${key} (the default prefix is vuePdfz.), with unresolved keys falling back to the built-in bundle.

ts
import { useI18n } from 'vue-i18n'
import { createVueI18nAdapter } from 'vue-pdfz'

const i18n = useI18n()

app.use(VuePdfz, {
  i18nAdapter: createVueI18nAdapter(i18n),
})

RTL ​

The text direction is derived from the locale and applied via dir; the layout uses CSS logical properties so the toolbar and sidebar flip automatically. The CJK locales (ja / ko / zh) are left-to-right and need no special configuration.

CJK documents (character maps) ​

The ja / ko / zh bundles localize the viewer UI. Rendering CJK text that is embedded in a PDF sometimes needs PDF.js character maps. If glyphs are missing, point the source at the maps shipped with pdfjs-dist:

vue
<PdfViewer
  :source="{
    cMapPacked: true,
    cMapUrl: '/cmaps/', // copy from node_modules/pdfjs-dist/cmaps
    url: '/document.pdf',
  }"
  locale="zh"
/>