Open a ticket
Chat with us
Click or drag to resize

Translating UI and mesages

By default, text is in English. It can be ovveriden.

There are five types of text:

  • Aria-labels for accessibility

  • Toolbar button's tooltips

  • Messages

  • Document info

  • Miscellaneous text

TWPdfViewer has a property Options which has a property Texts.
Texts has properties:

  • Messages
  • DocumentInfoTexts
  • MiscTexts
  • AriaLabels
  • Tooltips.

DocumentInfoText properties and its default values:

Author = "Author:"
CreationDate = "CreationDate:"
Creator = "Creator:"
FileName = "FileName:"
FileSize = "FileSize:"
Keywords = "Keywords:"
ModificationDate = "ModificationDate:"
PageCount = "Page Count:"
PageSize = "Page Size:"
PDFProducer = "PDF Producer:"
PDFVersion = "PDF Version:"
Subject = "Subject:"
Title= "Title:"

AriaLabels properties and its default values:

CloseBookmarks = "Close bookmarks"
ClosePdfDocumentBtn = "Close PDF document"
CurrentPage = "Current page"
CurrentZoomValue = "Current zoom value"
DocumentInfoBtn = "Document information"
DownloadBtn = "Download PDF document"
NextFindBtn = "Next find"
NextPageBtn = "Next page"
NextVisitedPageBtn = "Next visited page"
MessageCloseBtn = "Message close"
MultiPageViewBtn = "Multi page view"
OpenBtn = "Open PDF document"
PasswordField = "Password"
PreviousFindBtn = "Previous find"
PreviousPageBtn = "Previous page"
PreviousVisitedBtn = "Previous visited page"
PrintBtn = "Print PDF document"
RotateClockwiseBtn = "Rotate clockwise"
RotateCounterClockwiseBtn = "Rotate counter-clockwise"
SearchBtn = "Search"
SearchOptionsBtn = "Search options"
SearchTerm = "Search term"
ShowBookmarksBtn = "Show bookmarks"
SinglePageViewBtn = "Single page view"
ZoomDropDownArrow = "Open zoom drop-down"
ZoomInBtn = "Zoom in"
ZoomOutBtn = "Zoom out"

MiscText properties and its default values:

CancelBtn = "Cancel"
CloseBtn = "Close"
EnterPassword = "Enter the password to open this PDF File"
FindInDocument = "Find in document..."
HighlightAll = "Highlight all"
MatchCase = "Match case"
OKBtn = "OK"
ZoomActualSize = "Actual page size"
ZoomPageLevel = "Zoom to page level"
WholeWord = "Whole word"

Tooltips properties and its default values:

ClosePdfDocumentBtn = "Close PDF document"
DocumentInfoBtn = "Document information"
DownloadBtn = "Download PDF document"
MultiPageViewBtn = "Multi page view"
NextPageBtn = "Next page"
NextVisitedPageBtn = "Next visited page"
OpenBtn = "Open PDF document"
PreviousPageBtn = "Previous page"
PreviousVisitedBtn = "Previous visited page"
PrintBtn = "Print PDF document"
ShowBookmarksBtn = "Show bookmarks"
SinglePageViewBtn = "Single page view"
RotateClockwiseBtn = "Rotate clockwise"
RotateCounterClockwiseBtn = "Rotate counter-clockwise"
ZoomInBtn = "Zoom in"
ZoomOutBtn = "Zoom out"

Messages properties and its default values:

FindReachedBottom = "Reached end of document, continued from top."
FindReachedTop = "Reached top of document, continued from bottom."
InvalidPassword = "Wrong password, please try again."
LoadDocumentError = "Load document error:"
PrintingPopupWarning = "For direct printing, popup must be allowed."
PreparingForPrint = "Preparing pages for print:"
TextNotFound = "Text not found."
UnknownError = "Unknown error"

Example

Example how to change MiscText.FindInDocument in Razor Pages

C#
        using PdfViewer = Terminalworks.PdfViewer.AspNetCore;        
<component type="typeof(PdfViewer.Pages.Shared.TWPdfViewer)"
render-mode="Static"
param-IsStatic='@("Yes")'
param-Options='@new PdfViewer.Options {
      Texts = new PdfViewer.ViewerTexts {
          MiscText = new PdfViewer.Texts.MiscText {
          FindInDocument = "Trova in documento"
        }
      }     
}'>/>
Another way of changing texts - UserDefined property dictionary

This could be useful, if you have different files with traslations for different languages.

C#
var options = new Terminalworks.PdfViewer.AspNetCore.Options();
var userDefined = new Dictionary<string, string>
{
    { TextCodeNames.AriaLabels.CurrentPage, "La pagina attuale" }
    // you can override all or just some texts...
};
options.Texts = new ViewerTexts
{                
    UserDefined = userDefined
};
See Also

Other Resources

Copyright © 2024 Terminalworks. All Rights Reserved