Articles in this section
Category / Section

How to Change the Locale for the Word 'Clear' by Replacing 'klar' with 'löschen' in Blazor PDF Viewer

4 mins read

How to Change the Locale for the Word ‘Clear’ by Replacing ‘klar’ with ‘löschen’ in Blazor PDF Viewer

Description:

This article explains how to change the locale content for the word “Clear” in Syncfusion’s Blazor PDF Viewer. Specifically, it shows how to replace the default term “klar” with “löschen” locally in the Blazor application. By customizing the resource files and registering a localization service, you can control the language used in the PDF viewer, ensuring that the application is tailored to your preferred localization needs.

Solution:

To change the locale content for the word “Clear” in Syncfusion’s Blazor PDF Viewer, you need to modify the locale settings by updating the resource files and registering a custom localization service. This involves downloading and adding the appropriate resource files, updating the specific locale content (replacing “klar” with “löschen”), and then registering the localization service to apply the changes in the application.

Prerequisites:
  1. Syncfusion Blazor PDF Viewer Setup: Ensure you have installed and set up the Syncfusion Blazor PDF Viewer component in your Blazor project. If you haven’t already done so, you can follow the Syncfusion Blazor PDF Viewer - Getting Started guide.
  2. Basic Knowledge of Blazor: Familiarity with Blazor components, how to bind events, and handle component references will be helpful in implementing this solution.
  3. Access to Resource Files: You will need to add localization resource files available on Syncfusion’s GitHub repository.
Implementation Steps:
Steps to Change Locale Content for “Clear”:
Step 1: Add the Resource Files:
Step 2: Open the Default Resource File:
  • After adding the resource files to your project, locate the default .resx file (SfResources.resx).
  • Double-click the SfResources.resx file to open it in the Resource Editor.
Step 3: Modify the Access Modifier:
  • In the Resource Editor, change the Access Modifier option to Public. This ensures the resource can be accessed and modified as required.
Step 4: Change the Locale Content for “Clear”:
  • Locate the key corresponding to the word “Clear” in the .resx file. By default, this might be set to “klar”.
  • Replace “klar” with “löschen” to modify the label for the “Clear” button or option in the PDF viewer.
Step 5: Create and Register a Custom Localization Service:
  • Next, create a custom localization service to use the modified resource file in the Blazor application.
  • Create a class SyncfusionLocalizer.cs in your project with the following code:
using Syncfusion.Blazor;

public class SyncfusionLocalizer : ISyncfusionStringLocalizer
{
    public string GetText(string key)
    {
        return this.ResourceManager.GetString(key);
    }

    public System.Resources.ResourceManager ResourceManager
    {
        get
        {
            // Replace 'ApplicationNamespace' with your application name.
            return ApplicationNamespace.Resources.SfResources.ResourceManager;
        }
    }
}

Step 6: Register the Localization Service:

In your Program.cs file, add the following code to register the localization service and Syncfusion Blazor components:

builder.Services.AddSyncfusionBlazor();

// Register the locale service to localize the Syncfusion Blazor components.
builder.Services.AddSingleton(typeof(ISyncfusionStringLocalizer), typeof(SyncfusionLocalizer));

Step 7: Set the Locale and Culture:

Specify the static culture for your application. For instance, if you’re localizing for German (Germany), use the following code in Program.cs:

app.UseRequestLocalization("de-DE");
Key Features Used in the Code:
  1. Resource File Customization: Leverages resource files (like SfResources.resx) to change locale content for individual terms used in the Blazor application, ensuring it reflects the desired language. This allows you to easily modify specific words such as replacing “klar” with “löschen.”
  2. Custom Localization Service: Demonstrates how to create a custom localization service (SyncfusionLocalizer) using the ISyncfusionStringLocalizer interface, enabling seamless integration of modified resource files into the Blazor application. This ensures the correct localized text is applied across the components.
  3. Seamless Culture Switching: Uses app.UseRequestLocalization("de-DE") to set the static culture for the application, ensuring that the entire application (including the Syncfusion Blazor PDF Viewer) adheres to the specified locale and language settings, providing a consistent experience for users.
Sample:

You can find the full sample code in our GitHub repository

Conclusion:

I hope this article has helped you understand how to change the locale content in Syncfusion’s Blazor PDF Viewer and replace the term “klar” with “löschen.” By following the steps outlined, you can easily customize the language and terminology used in the viewer to match your specific localization needs.

You can refer to Blazor feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Blazor PDF Viewer example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied