Skip to content

Commit 06ff64c

Browse files
committed
Added Spanish translations and improved plugin configuration API.
- All plugin configuration options in `PDFViewerConfig` now use `Partial<>` types - Added Spanish (`es`) locale support with complete translations for all UI elements and commands.
1 parent aac941b commit 06ff64c

8 files changed

Lines changed: 475 additions & 26 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
'@embedpdf/snippet': minor
3+
---
4+
5+
Added Spanish translations and improved plugin configuration API.
6+
7+
### New Features
8+
9+
- **Spanish Translations**: Added Spanish (`es`) locale support with complete translations for all UI elements and commands.
10+
11+
### Improvements
12+
13+
- **Partial Plugin Configs**: All plugin configuration options in `PDFViewerConfig` now use `Partial<>` types, making it easier to override only the settings you need without specifying all required fields.
14+
15+
```typescript
16+
// Before: Had to provide full config objects
17+
// After: Can override just specific settings
18+
<PDFViewer
19+
config={{
20+
src: '/document.pdf',
21+
zoom: { defaultZoomLevel: ZoomMode.FitWidth }, // Only override what you need
22+
i18n: { defaultLocale: 'es' }, // Use Spanish translations
23+
}}
24+
/>
25+
```

viewers/snippet/src/components/app.tsx

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ import {
126126
dutchTranslations,
127127
germanTranslations,
128128
frenchTranslations,
129+
spanishTranslations,
129130
} from '@/config';
130131
import { ThemeConfig } from '@/config/theme';
131132
import { IconsConfig } from '@/config/icon-registry';
@@ -187,67 +188,70 @@ export interface PDFViewerConfig {
187188
disabledCategories?: string[];
188189

189190
// === Plugin Configurations (uses actual plugin types - no duplication!) ===
191+
// All plugin configs are Partial<> so users can override just the settings they need.
192+
// Defaults are merged in at runtime.
193+
190194
// Core plugins
191195
/** Document manager options (initialDocuments) */
192-
documentManager?: DocumentManagerPluginConfig;
196+
documentManager?: Partial<DocumentManagerPluginConfig>;
193197
/** Commands options (commands, disabledCategories) */
194-
commands?: CommandsPluginConfig;
198+
commands?: Partial<CommandsPluginConfig>;
195199
/** i18n options (defaultLocale, locales, paramResolvers) */
196-
i18n?: I18nPluginConfig;
200+
i18n?: Partial<I18nPluginConfig>;
197201
/** UI schema options (schema, disabledCategories) */
198-
ui?: UIPluginConfig;
202+
ui?: Partial<UIPluginConfig>;
199203

200204
// Viewport & Navigation
201205
/** Viewport options (viewportGap, scrollEndDelay) */
202-
viewport?: ViewportPluginConfig;
206+
viewport?: Partial<ViewportPluginConfig>;
203207
/** Scroll options (defaultStrategy, defaultPageGap, defaultBufferSize) */
204-
scroll?: ScrollPluginConfig;
208+
scroll?: Partial<ScrollPluginConfig>;
205209
/** Zoom options (defaultZoomLevel, minZoom, maxZoom, zoomStep) */
206-
zoom?: ZoomPluginConfig;
210+
zoom?: Partial<ZoomPluginConfig>;
207211
/** Spread/layout options (defaultSpreadMode) */
208-
spread?: SpreadPluginConfig;
212+
spread?: Partial<SpreadPluginConfig>;
209213
/** Rotation options (defaultRotation) */
210-
rotation?: RotatePluginConfig;
214+
rotation?: Partial<RotatePluginConfig>;
211215
/** Pan mode options (defaultMode: 'never' | 'mobile' | 'always') */
212-
pan?: PanPluginConfig;
216+
pan?: Partial<PanPluginConfig>;
213217

214218
// Rendering
215219
/** Render options (withForms, withAnnotations) */
216-
render?: RenderPluginConfig;
220+
render?: Partial<RenderPluginConfig>;
217221
/** Tiling options (tileSize, overlapPx, extraRings) */
218-
tiling?: TilingPluginConfig;
222+
tiling?: Partial<TilingPluginConfig>;
219223
/** Thumbnail options (width, gap, buffer, labelHeight, etc.) */
220-
thumbnails?: ThumbnailPluginConfig;
224+
thumbnails?: Partial<ThumbnailPluginConfig>;
221225

222226
// Content features
223227
/** Annotation options (tools, colorPresets, autoCommit, author, etc.) */
224-
annotations?: AnnotationPluginConfig;
228+
annotations?: Partial<AnnotationPluginConfig>;
225229
/** Search options (flags, showAllResults) */
226-
search?: SearchPluginConfig;
230+
search?: Partial<SearchPluginConfig>;
227231
/** Selection options (menuHeight) */
228-
selection?: SelectionPluginConfig;
232+
selection?: Partial<SelectionPluginConfig>;
229233
/** Bookmark options */
230-
bookmarks?: BookmarkPluginConfig;
234+
bookmarks?: Partial<BookmarkPluginConfig>;
231235
/** Attachment options */
232-
attachments?: AttachmentPluginConfig;
236+
attachments?: Partial<AttachmentPluginConfig>;
233237

234238
// Tools
235239
/** Capture options (scale, imageType, withAnnotations) */
236-
capture?: CapturePluginConfig;
240+
capture?: Partial<CapturePluginConfig>;
237241
/** Redaction options (drawBlackBoxes) */
238-
redaction?: RedactionPluginConfig;
242+
redaction?: Partial<RedactionPluginConfig>;
239243
/** Print options */
240-
print?: PrintPluginConfig;
244+
print?: Partial<PrintPluginConfig>;
241245
/** Export options (defaultFileName) */
242-
export?: ExportPluginConfig;
246+
export?: Partial<ExportPluginConfig>;
243247
/** Fullscreen options (targetElement) */
244-
fullscreen?: FullscreenPluginConfig;
248+
fullscreen?: Partial<FullscreenPluginConfig>;
245249

246250
// Infrastructure
247251
/** History/undo options */
248-
history?: HistoryPluginConfig;
252+
history?: Partial<HistoryPluginConfig>;
249253
/** Interaction manager options (exclusionRules) */
250-
interactionManager?: InteractionManagerPluginConfig;
254+
interactionManager?: Partial<InteractionManagerPluginConfig>;
251255
}
252256

253257
// Default configurations for all plugins
@@ -258,7 +262,13 @@ const DEFAULTS = {
258262
commands: { commands: defaultCommands } as CommandsPluginConfig,
259263
i18n: {
260264
defaultLocale: 'en',
261-
locales: [englishTranslations, dutchTranslations, germanTranslations, frenchTranslations],
265+
locales: [
266+
englishTranslations,
267+
dutchTranslations,
268+
germanTranslations,
269+
frenchTranslations,
270+
spanishTranslations,
271+
],
262272
paramResolvers: defaultParamResolvers,
263273
} as I18nPluginConfig,
264274
ui: { schema: defaultUISchema } as UIPluginConfig,

viewers/snippet/src/config/translations.ts

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,196 @@ export const frenchTranslations: Locale = {
759759
},
760760
};
761761

762+
export const spanishTranslations: Locale = {
763+
code: 'es',
764+
name: 'Español',
765+
translations: {
766+
search: {
767+
placeholder: 'Buscar',
768+
caseSensitive: 'Distinguir mayúsculas',
769+
wholeWord: 'Palabra completa',
770+
resultsFound: '{count} resultados encontrados',
771+
page: 'Página {page}',
772+
},
773+
zoom: {
774+
in: 'Acercar',
775+
out: 'Alejar',
776+
fitWidth: 'Ajustar al ancho',
777+
fitPage: 'Ajustar a la página',
778+
marquee: 'Zoom de selección',
779+
menu: 'Menú de zoom',
780+
level: 'Nivel de zoom ({level}%)',
781+
},
782+
pan: {
783+
toggle: 'Alternar modo desplazamiento',
784+
},
785+
pointer: {
786+
toggle: 'Alternar modo puntero',
787+
},
788+
capture: {
789+
screenshot: 'Captura de pantalla',
790+
},
791+
document: {
792+
menu: 'Menú del documento',
793+
open: 'Abrir',
794+
close: 'Cerrar',
795+
print: 'Imprimir',
796+
export: 'Exportar',
797+
fullscreen: 'Pantalla completa',
798+
},
799+
emptyState: {
800+
title: 'No hay documentos abiertos',
801+
description: 'Abra un documento PDF para comenzar.',
802+
descriptionMulti: 'Puede ver varios documentos usando pestañas.',
803+
openButton: 'Abrir documento',
804+
supportedFormats: 'Formato compatible: PDF',
805+
},
806+
passwordPrompt: {
807+
title: 'Contraseña requerida',
808+
required:
809+
'Este documento está protegido con contraseña. Por favor, ingrese la contraseña para abrirlo.',
810+
incorrect: 'La contraseña ingresada es incorrecta. Por favor, inténtelo de nuevo.',
811+
incorrectWarning: 'Contraseña incorrecta. Por favor, verifique e inténtelo de nuevo.',
812+
label: 'Contraseña',
813+
placeholder: 'Ingrese la contraseña del documento',
814+
open: 'Abrir',
815+
opening: 'Abriendo...',
816+
cancel: 'Cancelar',
817+
close: 'Cerrar',
818+
},
819+
documentError: {
820+
title: 'Error al cargar el documento',
821+
unknown: 'Ha ocurrido un error desconocido',
822+
errorCode: 'Código de error: {code}',
823+
close: 'Cerrar documento',
824+
},
825+
panel: {
826+
sidebar: 'Barra lateral',
827+
search: 'Buscar',
828+
comment: 'Comentario',
829+
thumbnails: 'Miniaturas',
830+
outline: 'Esquema',
831+
annotationStyle: 'Estilo de anotación',
832+
},
833+
menu: {
834+
viewControls: 'Controles de vista',
835+
zoomControls: 'Controles de zoom',
836+
moreOptions: 'Más opciones',
837+
},
838+
outline: {
839+
title: 'Esquema',
840+
loading: 'Cargando esquema...',
841+
noOutline: 'No hay esquema disponible',
842+
noBookmarks: 'Este documento no contiene marcadores',
843+
},
844+
page: {
845+
settings: 'Configuración de página',
846+
single: 'Página única',
847+
twoOdd: 'Dos páginas (Impar)',
848+
twoEven: 'Dos páginas (Par)',
849+
vertical: 'Vertical',
850+
horizontal: 'Horizontal',
851+
spreadMode: 'Modo de doble página',
852+
scrollLayout: 'Diseño de desplazamiento',
853+
rotation: 'Rotación de página',
854+
next: 'Página siguiente',
855+
previous: 'Página anterior',
856+
},
857+
rotate: {
858+
clockwise: 'Rotar en sentido horario',
859+
counterClockwise: 'Rotar en sentido antihorario',
860+
},
861+
selection: {
862+
copy: 'Copiar selección',
863+
},
864+
mode: {
865+
view: 'Ver',
866+
annotate: 'Anotar',
867+
shapes: 'Formas',
868+
redact: 'Redactar',
869+
},
870+
annotation: {
871+
text: 'Texto',
872+
highlight: 'Resaltar',
873+
strikeout: 'Tachar',
874+
underline: 'Subrayar',
875+
squiggly: 'Ondulado',
876+
rectangle: 'Rectángulo',
877+
circle: 'Círculo',
878+
line: 'Línea',
879+
arrow: 'Flecha',
880+
polygon: 'Polígono',
881+
polyline: 'Polilínea',
882+
ink: 'Tinta',
883+
stamp: 'Sello',
884+
// Sidebar labels
885+
color: 'Color',
886+
opacity: 'Opacidad',
887+
blendMode: 'Modo de fusión',
888+
strokeWidth: 'Grosor del trazo',
889+
strokeColor: 'Color del trazo',
890+
borderStyle: 'Estilo del borde',
891+
fillColor: 'Color de relleno',
892+
fontSize: 'Tamaño de fuente',
893+
fontFamily: 'Fuente',
894+
textAlign: 'Alineación del texto',
895+
verticalAlign: 'Alineación vertical',
896+
lineEnding: 'Final de línea',
897+
lineStart: 'Inicio de línea',
898+
lineEnd: 'Final de línea',
899+
font: 'Fuente',
900+
fontColor: 'Color de fuente',
901+
backgroundColor: 'Color de fondo',
902+
noStyles: 'No hay estilos para esta anotación.',
903+
noStylesStamp: 'No hay estilos para los sellos.',
904+
selectAnnotation: 'Seleccione una anotación para ver los estilos',
905+
deleteSelected: 'Eliminar anotación seleccionada',
906+
},
907+
redaction: {
908+
area: 'Redactar área',
909+
text: 'Redactar texto',
910+
applyAll: 'Aplicar todo',
911+
clearAll: 'Borrar todo',
912+
},
913+
history: {
914+
undo: 'Deshacer',
915+
redo: 'Rehacer',
916+
},
917+
comments: {
918+
page: 'Página {page}',
919+
commentCount: '{count} comentario',
920+
commentCountPlural: '{count} comentarios',
921+
addComment: 'Añadir comentario...',
922+
addReply: 'Añadir respuesta...',
923+
save: 'Guardar',
924+
cancel: 'Cancelar',
925+
edit: 'Editar',
926+
delete: 'Eliminar',
927+
showMore: 'más',
928+
showLess: 'menos',
929+
emptyState: 'Añada anotaciones para poder comentarlas.',
930+
},
931+
blendMode: {
932+
normal: 'Normal',
933+
multiply: 'Multiplicar',
934+
screen: 'Trama',
935+
overlay: 'Superponer',
936+
darken: 'Oscurecer',
937+
lighten: 'Aclarar',
938+
colorDodge: 'Sobreexponer color',
939+
colorBurn: 'Subexponer color',
940+
hardLight: 'Luz fuerte',
941+
softLight: 'Luz suave',
942+
difference: 'Diferencia',
943+
exclusion: 'Exclusión',
944+
hue: 'Tono',
945+
saturation: 'Saturación',
946+
color: 'Color',
947+
luminosity: 'Luminosidad',
948+
},
949+
},
950+
};
951+
762952
export const paramResolvers: ParamResolvers<State> = {
763953
'zoom.level': ({ state, documentId }) => {
764954
const zoomLevel = documentId

viewers/snippet/src/config/ui-schema.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ export const viewerUISchema: UISchema = {
3232
breakpoints: {
3333
md: {
3434
replaceShow: [
35+
'view-mode',
3536
'annotate-mode',
3637
'zoom-toolbar',
3738
'pan-button',
3839
'pointer-button',
3940
'divider-3',
41+
'overflow-tabs-button',
4042
],
4143
},
4244
},

viewers/snippet/src/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
tabBar: 'always',
2626
theme: {
2727
preference: 'system'
28+
},
29+
i18n: {
30+
defaultLocale: 'fr',
2831
}
2932
})
3033
</script>

0 commit comments

Comments
 (0)