Localization in WPF Pdf Viewer
8 Sep 20231 minute 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.
We are using en-US
culture-based resource file as default in PDF Viewer. This can be downloaded from this GitHub location.
Adding Resource file
- Create a folder name as
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 name it 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 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 can be done using Assembly.GetExecuteAssembly method. When the resource file is located at different assembly or namespace, it can 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();
}
NOTE
You can refer to our WPF PDF Viewer feature tour page for its groundbreaking feature representations. You can also explore our WPF PDF Viewer example to know how to render and configure the pdfviewer.