Localization in .NET MAUI PDF Viewer (SfPdfViewer)

30 Sep 20243 minutes to read

Localization is the process of translating the application resources into a different language for the specific cultures. SfPdfViewer is set up by default with the language code en-US. However, by including a resource file (.resx) in the application with the language code, the static text used in the SfPdfViewer can be localized to a different language.

Follow the instructions given to apply localization to the SfPdfViewer.

Change the current user interface culture

Set the CurrentUICulture property in the App.xaml.cs file to the desired user interface culture. Refer to the following code sample to change the current culture to French.

using System.Globalization;

namespace PdfViewerLocalization;

public partial class App : Application
{
	public App()
	{
		InitializeComponent();
        CultureInfo.CurrentUICulture = new CultureInfo("fr-FR");
        MainPage = new AppShell();
	}
}

Create and add the resource file to the application

Follow the given steps to create and add the resource file to the application.

  1. Right-click on the Resources folder in the application.

    Resources folder in the .NET MAUI PDF Viewer application.

  2. Click the Add option and then select NewItem.

    Add new item in the .NET MAUI PDF Viewer application.

  3. In the Add New Item wizard, select the Resource File option and name the file in the format <control name>.<culture name>.resx. For example, name the file as SfPdfViewer.fr.resx for French culture.

    Adding resource file in the .NET MAUI PDF Viewer application.

  4. Click the Add option to add the resource file in the Resources folder.

  5. Change the Build Action of the resource file as Embedded resource.

    Build action of resource file

  6. Double tap on the resource file to add the name and value details in the Resource Designer.

  7. Set the ResourceManager as shown in the following code example, that looks up the resource file with the specified root name.

using System.Resources;
using System.Globalization;
using Syncfusion.Maui.PdfViewer;

namespace PdfViewerLocalization;

public partial class App : Application
{
	public App()
	{
		InitializeComponent();
        CultureInfo.CurrentUICulture = new CultureInfo("fr-FR");
        SfPdfViewerResources.ResourceManager = new ResourceManager("PdfViewerLocalization.Resources.SfPdfViewer", 
			Application.Current.GetType().Assembly);
        MainPage = new AppShell();
	}
}

Default names and values

The following table contains the default name and value details used in the SfPdfViewer in the en-US

Name Value
Cancel Cancel
CanOpenWebPage Do you want to open
Close CLOSE
DocumentLoadFailed Failed to load the PDF document.
EnterPassword Enter Password
Error Error
NoOutline No outline
Ok OK
Open OPEN
OpenWebPage Open Web Page
Outline Outline
PasswordErrorHint Check your password
RequestPassword This PDF file is protected. Please enter the password to open it.
Copy Copy
Highlight Highlight
Save Save
Squiggly Squiggly
Strikeout Strikeout
Underline Underline
StickyNoteEditorPlaceholder Write Your Note...
FreeTextEditorPlaceHolder Text...
AddFreeTextToastMessage Tap on the page to add the free text annotation
Draw your signature Draw your signature
Color Color
Clear Clear
Add Signature Add Signature
Draw Draw
Type Type
Upload Upload
Type your signature Type your signature
Signature Signature
Create Create
Insert Insert
Upload an image Upload an image
Drag and drop an image here Drag and drop an image here
AddHighlightToastMessage Drag over a text to highlight it
AddSignature Add signature
AddSignatureToastMessage Tap to add the signature
AddSquigglyToastMessage Drag over a text to add a squiggly underline
AddStampToastMessage Tap to add the stamp
AddStickyNoteToastMessage Tap to add a sticky note
AddStrikeoutToastMessage Drag over a text to strike it through
AddUnderlineToastMessage Drag over a text to underline it
Apply Apply
Annotations Annotations
Arrow Arrow
Border Border
Circle Circle
Cloud Cloud
ColorPicker Color picker
Comment Comment
ContinuousPage Continuous page
CreateStamps Create Stamps
Delete Delete
DragAndDropImage Drag and drop an image here.
DrawArrowToastMessage Drag to draw an arrow
DrawCircleToastMessage Drag to draw a circle
DrawCloudToastMessage Tap to begin drawing a cloud
DrawInkToastMessage Drag to draw an ink
DrawLineToastMessage Drag to draw a line
DrawPolygonToastMessage Tap to begin drawing a polygon
DrawPolylineToastMessage Tap to begin drawing a polyline
DrawSquareToastMessage Drag to draw a square
EraseInkToastMessage Drag over an ink to erase it
Fill Fill
FitToPage Fit to Page
FitToWidth Fit to Width
FontSize Font size
FreeText Free text
FreeTextEditorPlaceHolder Text…
Help Help
Ink Ink
InkEraser Ink eraser
InvalidPageNumber Invalid page number
Key Key
Line Line
MatchCase Match Case
NewParagraph New Paragraph
NextPage Next page
NoBookmark No Bookmark
NoColor No Color
NoMatchesWereFoundToastMessage No matches were found.
NoMoreMatchesWereFoundToastMessage No more matches were found
Note Note
Opacity Opacity
PageByPage Page by page
PageCount Page count
PageLayoutMode Page layout mode
PageNumberEntry Page number entry
PageNumberHint Enter page number here
Paragraph Paragraph
Polygon Polygon
Polyline Polyline
PreviousPage Previous page
Print Print
Redo Redo
Rename Rename
Search Search
Shapes Shapes
Square Square
Stamps Stamps
StickyNote Sticky note
StickyNoteIcons Sticky note icons
Stroke Stroke
SaveSignature Save Signature
SearchPlaceholder Find in the document
Text Text
TextMarkups Text markups
Thickness Thickness
TypeSignaturePlaceHolder Type your signature
Undo Undo
UploadImage Upload an image
ZoomMode Zoom mode
CustomStamps Custom Stamps
Enter Enter
StandardStamps Standard Stamps