Localization in WPF Pdf Viewer
4 Sep 2020 / 2 minutes to read
Localization is the process of configuring the application to a specific language. PdfViewerControl
provides support to localize all the static text used for tooltip and context menu contents. Localization can be done by adding resource file (Resx) in the application.
The following table shows the default values for the common text used in the PdfViewerControl
which is in en-US
culture:
Name | Value |
---|---|
AddLayer | Click to add a layer |
Appearance | Appearance |
Author | Author |
BackgroundColor | Background Color : |
BookmarkTitle | Bookmarks |
BorderColor | Border Color : |
BorderThickness | Border Thickness : |
Cancel | Cancel |
CloseBookmark | Click to close the bookmark pane |
CloseFontPopUp | Click to close the text properties |
CloseLayer | Click to close the layer pane |
CloseSearchBar | Close Search Bar |
CloseThumbnail | Click to close the thumbnail pane |
Color | Color : |
ColorPicker | Color Picker |
Copy | Copy |
CurrentPageNumber | Current page index |
DecreaseMagnification | Click to decrease the magnification of the entire page. |
Delete | Delete |
DeleteLayer | Click to delete a layer |
DocumentProtected | This document is protected. Please enter a Document Open Password. |
DrawCircle | Circle |
DrawingTools | Drawing Tools |
DrawInk | Draw free form |
DrawLine | Line |
DrawRectangle | Rectangle |
EnlargePageThumbnails | Enlarge page thumbnails |
EnterPassword | Enter Password: |
EssentialPdfViewer | Essential Pdf Viewer |
FillColor | FillColor : |
FitPage | Click to show one page at a time. |
FitWidth | Click to fill the window with each page and scroll through pages continuously. |
FreeTextBox | Add text box |
FreeTextProperties | Free Text Properties |
General | General |
GoToFirstPage | Click to go to first page in the document. |
GoToLastPage | Click to go to last page in the document. |
GoToNextPage | Click to go to next page in the document. |
GoToPreviousPage | Click to go to previous page in the document. |
HighlightProperties | Highlight Properties |
HighlightText | Highlight text |
IncreaseMagnification | Click to increase the magnification of the entire page. |
InkProperties | Ink Properties |
LayerTitle | Layers |
LineProperties | Line Properties |
MakeDefault | Make Properties Default |
MatchCase | Match Case |
Modified | Modified |
Next | Next |
NoMatchesFound | Reader has finished searching the document. No matches were found |
Of | of |
Ok | Ok |
Opacity | Opacity (%) : |
OpenDocument | Click to open a PDF Document |
OpenPopupNote | Open Pop-up Note |
OvalProperties | Oval Properties |
PageCount | Total page count |
PasswordCancelButton | Cancel |
PasswordOkButton | OK |
Previous | Previous |
PrintDocument | Click to Print this PDF file or pages from it. |
Properties | Properties |
RectangleProperties | Rectangle Properties |
ReducePageThumbnails | Reduce page thumbnails |
Rename | Rename |
SaveDocument | Click to save the document in the local disk |
SearchIndicator | Searching |
SearchText | Click to search text |
StrikeoutProperties | StrikeOut Properties |
StrikeoutText | Strikethrough text |
Subject | Subject |
TextProperties | Text Properties |
Thickness | Thickness : |
ThumbnailTitle | Page Thumbnails |
UnderlineProperties | Underline Properties |
UnderlineText | Underline text |
ViewBookmarks | Click to view the bookmarks |
ViewLayers | Click to view the layers |
ViewThumbnails | Click to view the thumbnails |
ZoomLevel | Current zoom level |
Adding Resource file
- Create a folder names
Resources
in your application. - Add default English (“en-US”) Resx (resource) file of
PdfViewerControl
inResources
folder named as Syncfusion.PdfViewer.WPF.resx. - Create a Resx (resource) files and named as Syncfusion.PdfViewer.WPF.[Culture name].resx. For example, Syncfusion.PdfViewer.WPF.fr.resx for French culture.
- Add the resource key such as
OpenDocument
and its corresponding localized value in Syncfusion.PdfViewer.WPF.fr.resx file. Refer the below screenshot for the same. - Execute the application in the French culture to see the changes.
The following screenshot shows the PdfViewerControl
in French language
Localize Resource File with Different Assembly or Namespace
In general, PdfViewerControl try to read the resource file from executing assembly and its default namespace by using Assembly.GetExecuteAssembly method. When the resource file is located at different assembly or namespace, then it can be set to the PdfViewerControl by using LocalizationManager.SetResources
method.
public MainWindow()
{
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fr-FR");
// Set the Custom assembly and namespace for the localization.
LocalizationManager.SetResources(typeof(Custom_Class).Assembly, "ClassLibrary");
InitializeComponent();
}