Skip to content

Translations

Every string Inkbar shows comes from messages. English is the default. French and German ship with the library, and any other language is a set of strings you pass in.

messages is a plain object of strings and small functions. Inkbar asks nothing of your translation setup, so it works with whatever your app uses, or with nothing. The examples here call a generic t(key, params) where your own function goes.

A set is nested by feature area, such as toolbar and find. messages takes a partial set, and a key you leave out stays English.

Pass only what you want to change.

<script setup lang="ts">
import { InkRoot, InkViewport } from '@inkbar/vue'
import { assets } from 'virtual:inkbar-assets'
defineProps<{ file: File }>()
const messages = { toolbar: { find: 'Search this file' } }
</script>
<template>
<InkRoot :src="file" :assets="assets" :messages="messages">
<InkViewport />
</InkRoot>
</template>

Passing messages again replaces the last value, so overrides do not pile up.

Each language is its own entry point, so your bundler drops the ones you don’t import.

<script setup lang="ts">
import { fr } from '@inkbar/core/locales/fr'
import { InkRoot, InkViewport } from '@inkbar/vue'
import { assets } from 'virtual:inkbar-assets'
defineProps<{ file: File }>()
</script>
<template>
<InkRoot :src="file" :assets="assets" :messages="fr">
<InkViewport />
</InkRoot>
</template>

de comes from @inkbar/core/locales/de. To change a string in a shipped set, spread it: messages: { ...fr, find: { ...fr.find, field: 'Chercher' } }.

Both sets are drafts. If a string reads wrong to you, open an issue on inkbar/inkbar with the key and the wording you would use.

A message that takes values is a function of one params object. Call your own t from it:

import type { InkMessagesInput } from '@inkbar/core'
declare function t(key: string, params?: object): string
const messages: InkMessagesInput = {
lang: 'es',
find: {
field: t('find.field'),
count: ({ current, total }) => t('find.count', { current, total }),
},
}

Plurals are your t’s job. It knows your language’s rules, so find.count returns “1 de 1” or “2 de 7” in the form your language needs.

To do the same by hand, use the two helpers from @inkbar/core. template fills {name} placeholders. plural picks a form by the language’s plural rule for one parameter, and other is the fallback:

import { plural, template } from '@inkbar/core'
const messages = {
lang: 'en',
search: {
resultCount: plural('en', 'count', {
one: '{count} result',
other: '{count} results',
}),
},
thumbnails: {
page: template('en', 'Page {page}'),
},
}

Both format numbers for the language you give them, so 1200 reads 1,200 in English and 1.200 in German. The shipped sets are built with them.

Change messages or locale and the viewer relabels in place. It does not remount, reload the document or move the scroll position, and an open menu, popover, dialog or find bar stays open.

<script setup lang="ts">
import { de } from '@inkbar/core/locales/de'
import { fr } from '@inkbar/core/locales/fr'
import { InkRoot, InkViewport } from '@inkbar/vue'
import { ref } from 'vue'
import { assets } from 'virtual:inkbar-assets'
defineProps<{ file: File }>()
const messages = ref(fr)
</script>
<template>
<button @click="messages = fr">Français</button>
<button @click="messages = de">Deutsch</button>
<InkRoot :src="file" :assets="assets" :messages="messages">
<InkViewport />
</InkRoot>
</template>

Each set carries its lang: fr.lang is 'fr'. Without a locale, the viewer root’s lang attribute and the dates on notes follow it, so messages={fr} alone reads as French to a screen reader. Pass locale, such as 'de-CH', when the page language or the date format should differ from the messages.

The text you pass in is yours to translate. These each take a string or a function that returns one:

  • a tool’s label, and the label of a toolbar or panel
  • a sidebar’s handleLabel
  • an outline’s emptyText
  • a plugin command’s label and its errorStatus
  • a card’s title, label and action labels

Inkbar calls a function label when it renders and again on every setMessages or setLocale, so the label follows the language.

const toolbar = createToolbar({ label: () => t('toolbar'), messages: viewer.messages })
definePlugin('review', (plugin) => {
const notes = plugin.records<Note>('notes')
plugin.command('suggest', () => t('suggest'), run, {
errorStatus: () => t('suggest.failed'),
})
plugin.marks(notes, {
rect: (n) => n.rect,
label: (n) => t('note.label', { text: n.text }),
card: (n) => ({
title: () => t('note.title'),
actions: [{ label: () => t('note.dismiss'), run: () => notes.remove(n.id) }],
}),
})
})

A card’s actions is an array of { label, run } so each label can be a function. The object form, with the label as the key, works for fixed text. See Writing a plugin.

Every message in the English set, by group. The table leaves out lang, which names the set’s language and isn’t a message. A function message shows its template, or its plural forms, with {name} for the values it receives. Your replacement for a function message takes the same params object.

viewer

KeyEnglish
viewer.documentDocument
viewer.loadingLoading document…
viewer.openFailedThis document could not be opened.
viewer.pageFailed (function)Page {page} could not be shown.
viewer.saveFailedYour changes could not be written into this file.
viewer.saveUnavailableSaving is not available right now. Check your connection and try again.
viewer.preparingFilePreparing your file…
viewer.applyRedactionsApply redactions
viewer.redactTitleApply redactions?
viewer.redactSummary (function)This removes the content under {marks, plural, one {{marks} mark} other {{marks} marks}} on {pages, plural, one {{pages} page} other {{pages} pages}}.
viewer.redactLocked (function)one: {count} mark saved in this file earlier will be applied too, unless another program made it. | other: {count} marks saved in this file earlier will be applied too, unless another program made them.
viewer.redactPermanentIt cannot be undone.
viewer.redactOverlapped (function)one: {count} other annotation under the marks will be removed too. | other: {count} other annotations under the marks will be removed too.
viewer.redactSignedThis file is signed. Its signature will stop verifying.
viewer.redactConfirmApply
viewer.redactCancelCancel
viewer.redactingApplying redactions…
viewer.redactFailedThe redactions could not be applied. Nothing was changed.
viewer.redactUnremovable (function)one: {count} mark covers content that cannot be removed. Move or delete it and try again. | other: {count} marks cover content that cannot be removed. Move or delete them and try again.
viewer.redactUnverifiedSome content could not be removed, so nothing was changed.
viewer.redactUnavailableRedaction is not available right now. Check your connection and try again.
viewer.redactDone (function)one: {marks} redaction applied. | other: {marks} redactions applied.
viewer.redactHiddenLayersThis file has hidden layers. Their content was not removed.
viewer.redactForeign (function)one: {count} redaction mark from another program was left in place. | other: {count} redaction marks from another program were left in place.

toolbar

KeyEnglish
toolbar.labelDocument tools
toolbar.findFind
toolbar.downloadDownload
toolbar.printPrint
toolbar.undoUndo
toolbar.redoRedo
toolbar.backBack
toolbar.forwardForward
toolbar.zoomInZoom in
toolbar.zoomOutZoom out
toolbar.zoomZoom
toolbar.fitWidthFit width
toolbar.fitPageFit page
toolbar.zoomPercent (function){percent}%
toolbar.pagePage
toolbar.pageOf (function)of {total}
toolbar.previousPagePrevious page
toolbar.nextPageNext page

find

KeyEnglish
find.fieldFind in document
find.previousPrevious match
find.nextNext match
find.matchCaseMatch case
find.closeClose find
find.noResultsNo results
find.count (function){current} of {total}
find.countScanning (function){current} of {total}…
find.announce (function)Match {current} of {total}, page {page}
find.announceScanning (function)Match {current} of {total} so far, page {page}
KeyEnglish
search.fieldFind in document
search.placeholderSearch for a word or phrase
search.promptSearch to list every match.
search.noResultsNo results
search.resultCount (function)one: {count} result | other: {count} results
search.matchPage (function)Page {page}
search.match (function)Match {index}

records

KeyEnglish
records.emptyNothing here yet.
records.itemCount (function)one: {count} item | other: {count} items

sidebar

KeyEnglish
sidebar.tab (function){label}, {badge}
sidebar.resizeLeftResize left sidebar
sidebar.resizeRightResize right sidebar

outline

KeyEnglish
outline.labelOutline
outline.emptyThis document has no outline

thumbnails

KeyEnglish
thumbnails.page (function)Page {page}

annotations

KeyEnglish
annotations.highlightHighlight
annotations.underlineUnderline
annotations.strikeoutStrikethrough
annotations.squigglySquiggly underline
annotations.textNote
annotations.freetextText box
annotations.squareRectangle
annotations.circleEllipse
annotations.lineLine
annotations.polylinePolyline
annotations.polygonPolygon
annotations.inkDrawing
annotations.stampStamp
annotations.loupeLoupe
annotations.maskMask
annotations.redactRedaction
annotations.signatureSignature
annotations.withComment (function){name} with comment
annotations.byAuthor (function){name} by {author}
KeyEnglish
links.unsupportedThis link is not supported
links.goToLinkGo to link
links.goToPage (function)Go to page {page}

tools

KeyEnglish
tools.select-textSelect text
tools.selectRectangle select
tools.drawDraw
tools.shapeShape
tools.noteAdd note
tools.highlightHighlight
tools.freetextText box
tools.sketchSketch
tools.signatureSignature
tools.redact-areaMark for redaction

lineStyle

KeyEnglish
lineStyle.labelLine style
lineStyle.weightWeight
lineStyle.weightValue (function){points} pt
lineStyle.patternPattern
lineStyle.solidSolid
lineStyle.dashedDashed
lineStyle.arrowheadsArrowheads
lineStyle.arrowNoneNo arrowheads
lineStyle.arrowStartArrowhead at start
lineStyle.arrowEndArrowhead at end
lineStyle.arrowBothArrowheads at both ends

color

KeyEnglish
color.borderBorder colour
color.fillFill colour
color.textColorText colour
color.noFillNo fill
color.swatchesColours
color.customCustom…
color.customColourCustom colour

textStyle

KeyEnglish
textStyle.labelText style
textStyle.fontFont
textStyle.fontSizeFont size
textStyle.boldBold
textStyle.italicItalic
textStyle.underlineUnderline
textStyle.alignmentAlignment
textStyle.alignLeftAlign left
textStyle.alignCenterAlign centre
textStyle.alignRightAlign right
textStyle.alignJustifyJustify
textStyle.sizeSize
textStyle.decreaseDecrease font size
textStyle.increaseIncrease font size
textStyle.emphasisEmphasis
textStyle.mixedMixed

highlight

KeyEnglish
highlight.labelHighlight
highlight.chooseChoose highlight
highlight.menuHighlights
highlight.kindsKinds
highlight.colourColour
highlight.highlightColourHighlight colour
highlight.highlightHighlight
highlight.underlineUnderline
highlight.strikeoutStrikethrough
highlight.squigglySquiggly underline

shape

KeyEnglish
shape.labelShape
shape.chooseChoose shape
shape.menuShapes
shape.current (function)Shape: {kind}
shape.lineLine
shape.arrowArrow
shape.rectangleRectangle
shape.roundedRectangleRounded rectangle
shape.ellipseEllipse
shape.bubbleSpeech bubble
shape.starStar
shape.polygonPolygon
shape.loupeLoupe
shape.maskMask
shape.ovalMaskOval mask

notes

KeyEnglish
notes.noteThreadNote thread
notes.commentThreadComment thread
notes.anonymousAnonymous
notes.closeClose
notes.commentComment
notes.replyReply
notes.deleteDelete
notes.deleteHighlightDelete highlight

signature

KeyEnglish
signature.signSign
signature.triggerChoose signature
signature.menuSignatures
signature.savedSaved signatures
signature.createCreate signature
signature.dialogCreate signature
signature.tabsSignature source
signature.drawDraw
signature.typeType
signature.imageImage
signature.padSignature pad
signature.clearClear
signature.nameName
signature.namePlaceholderYour name
signature.fontsFont
signature.fileImage file
signature.cancelCancel
signature.saveSave
signature.item (function)Signature {n}
signature.remove (function)Remove signature {n}
signature.imageTooLargeThis image is too large. Choose a smaller one.
signature.imageTypeChoose a PNG or JPEG image.
signature.storageFullYour browser's storage is full. Remove a saved signature, or try a smaller one.
signature.saveFailedThe signature could not be saved. Try again.
signature.removeFailedThe signature could not be removed. Try again.

password

KeyEnglish
password.dialogPassword required
password.descriptionThis document is password protected. Enter its password to open it.
password.fieldPassword
password.submitOpen
password.cancelCancel
password.incorrectIncorrect password. Try again.
password.lockedThis document is password protected.
password.unlockEnter password

forms

KeyEnglish
forms.unnamedForm field
forms.signSign
forms.signField (function)Sign this field: {label}
forms.signFieldTitleSign this field
forms.alertMessage
forms.okOK

plugins

KeyEnglish
plugins.commandFailedSomething went wrong.