Localization in .NET MAUI PDF Viewer (SfPdfViewer)
13 Mar 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.
-
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 asEmbedded resource
. -
Double tap on the resource file to add the name and value details in 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();
}
}
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 |