Localization in .NET MAUI PDF Viewer (SfPdfViewer)
19 Aug 20254 minutes to read
Localization is the process of translating the application resources into a different language for 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.
-
Right-click on the
Resources
folder in the application. -
Click the
Add
option and then selectNewItem
. -
In the
Add New Item
wizard, select theResource File
option and name the file in the format<control name>.<culture name>.resx
. For example, name the file as SfPdfViewer.fr.resx forFrench
culture. -
Click the
Add
option to add the resource file in the Resources folder. -
Change the
Build Action
of the resource file toEmbedded resource
. -
Double tap on the resource file to add the name and value details to the Resource Designer.
-
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();
}
}
NOTE
When localizing multiple Syncfusion MAUI controls in a .NET MAUI application, it’s important to understand that these controls support only a single ResourceManager instance for localization. If you assign different ResourceManager instances for separate resource (.resx) files, the last assigned ResourceManager will override the others. This can result in incomplete or incorrect localization across your controls. To ensure consistent and accurate localization, consolidate all localization keys (name-value pairs) into a single resource (.resx) file and assign the ResourceManager using that unified resource file, as shown below:
using Syncfusion.Maui.Core.Localization; // Assign the ResourceManager using the unified .resx file LocalizationResourceAccessor.ResourceManager = new ResourceManager("Localization.Resources.SyncfusionControls", Application.Current.GetType().Assembly); // Replace the above string with your resource file's actual namespace and name.
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 |
NoBookmarks | No Bookmarks |
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 |
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 |
AddBookmark | Add bookmark |
Back | Back |
MoreItems | More items |
TextColor | Text color |
TextFillColor | Text fill color |
Bookmarks | Bookmarks |
of | of |
GoToPage | Go to Page |
CreateSignature | Create Signature |
XFAFormNotSupportedMessage | This PDF cannot be loaded because it contains an XFA form. |
InvalidPasswordError | Can't open an encrypted document. The password is invalid. |