import { Viewer, DocumentGate } from '@embedpdf/react/runtime'; import type { OpenInput } from '@embedpdf/react/runtime'; import { Stage, stagePlugin } from '@embedpdf/react/stage'; import { RenderLayer, renderPlugin } from '@embedpdf/react/render'; import { commandsPlugin, standardCommands, useCommand } from '@embedpdf/react/commands'; import { i18nPlugin, useI18n, useI18nState, useT } from '@embedpdf/react/i18n'; import type { Locale } from '@embedpdf/react/i18n'; import { localEngine } from '@embedpdf/engine'; import './rtl.css'; const engine = localEngine(); const en: Locale = { code: 'en', name: 'English', translations: { app: { title: 'The guide', switchTo: 'العربية' } }, }; // Arabic reads right to left. The standard commands have no Arabic labels, so the app gives // them, under the same keys. const ar: Locale = { code: 'ar', name: 'العربية', direction: 'rtl', translations: { app: { title: 'الدليل', switchTo: 'English' }, commands: { page: { previous: 'الصفحة السابقة', next: 'الصفحة التالية' }, zoom: { in: 'تكبير', out: 'تصغير' }, }, }, }; const plugins = [ stagePlugin(), renderPlugin(), commandsPlugin({ commands: standardCommands }), i18nPlugin({ locale: 'ar', locales: [en, ar] }), ]; const welcome = async (): Promise => { const response = await fetch('https://www.embedpdf.com/pdfs/welcome.pdf'); return { kind: 'bytes', id: 'welcome', bytes: new Uint8Array(await response.arrayBuffer()) }; }; function CommandButton({ id }: { id: string }) { const command = useCommand(id); if (!command.visible) return null; return ( ); } // The toolbar follows the language: in Arabic it runs from right to left. function ViewerRoot() { const i18n = useI18n(); const t = useT(); const { direction, locale } = useI18nState(); return (
{t('app.title')}
{() => }
); } export default function App() { return ( …

}>
); }