import { Viewer, DocumentGate } from '@embedpdf/react/runtime';
import type { OpenInput } from '@embedpdf/react/runtime';
import { Stage, stagePlugin, useStageState } 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 { cloudEngine } from '@cloudpdf/engine';
import './basic.css';
const engine = cloudEngine();
// Your strings. The buttons' labels are the standard commands', which come translated.
const en: Locale = {
code: 'en',
name: 'English',
translations: {
app: { language: 'Language', pages: { one: '{count} page', other: '{count} pages' } },
},
};
const nl: Locale = {
code: 'nl',
name: 'Nederlands',
translations: {
app: { language: 'Taal', pages: { one: '{count} pagina', other: "{count} pagina's" } },
},
};
const plugins = [
stagePlugin(),
renderPlugin(),
commandsPlugin({ commands: standardCommands }),
i18nPlugin({
locale: 'nl',
locales: [en, nl],
// Loaded the first time someone picks them; in your app, `() => import('./locales/de')`.
loaders: {
de: async () => ({
code: 'de',
name: 'Deutsch',
translations: {
app: { language: 'Sprache', pages: { one: '{count} Seite', other: '{count} Seiten' } },
},
}),
ja: async () => ({
code: 'ja',
name: '日本語',
translations: { app: { language: '言語', pages: { other: '{count} ページ' } } },
}),
},
}),
];
const welcome: OpenInput = { kind: 'grant', grant: 'shr_gvpJcG1ULUMon19C0D1wODSY' };
function LanguagePicker() {
const i18n = useI18n();
const t = useT();
const { locale, locales, loading } = useI18nState();
return (
);
}
function CommandButton({ id }: { id: string }) {
const command = useCommand(id);
if (!command.visible) return null;
return (
);
}
function PageCount() {
const t = useT();
const { pageCount } = useStageState();
return ;
}
export default function App() {
return (