Skip to Content
AnyPreview

Translations and right-to-left

Translate every label in the AnyPreview viewer with a typed message catalogue, format numbers by locale and mirror the UI for Arabic, Hebrew and other right-to-left languages.

All of the viewer's own text, including labels, tooltips, messages and screen-reader announcements, goes through one typed catalogue, Messages. Pass any subset; the rest stay English.

import { DocViewer, type Messages } from '@anypreview/react';

const de: Partial<Messages> = {
  zoomIn: 'Vergrößern',
  zoomOut: 'Verkleinern',
  pageOf: (count) => `von ${count}`,
  commentCount: (n) => (n === 1 ? '1 Kommentar' : `${n} Kommentare`),
};

<DocViewer source={file} messages={de} locale="de" />;

Messages with values are functions, so plurals and word order are up to the translation.

  • locale formats numbers, sizes and dates. Right-to-left locales (Arabic, Hebrew, Persian, Urdu and others) mirror the toolbar, side panel and arrows. Set dir to override.
  • Documents always keep their own direction.
  • Files opened inside a ZIP or an email use the outer viewer's language.
  • pseudoMessages() and pseudoMessages({ rtl: true }) produce pseudo-translations for testing your integration. Try them in the playground.