Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 36 additions & 16 deletions Document-Processing/Word/Word-Processor/wpf/Localization.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@ description: Learn here all about Localization support in Syncfusion WPF RichTex
platform: document-processing
control: SfRichTextBoxAdv
documentation: ug
keywords: localization
keywords: localization,resx,culture,current-ui-culture,resource-file
---
# Localization in WPF RichTextBox (SfRichTextBoxAdv)

Localization is the process of configuring the application to a specific language. [WPF RichTextBox](https://www.syncfusion.com/docx-editor-sdk/wpf-docx-editor) (SfRichTextBoxAdv) provides support to localize all the static text in ribbon and all its dialogs. Localization can be done by adding resource file (Resx) and setting the specific culture in the application.
Localization is the process of adapting the application to a specific language. [WPF RichTextBox](https://www.syncfusion.com/docx-editor-sdk/wpf-docx-editor) (SfRichTextBoxAdv) provides support to localize all the static text in the ribbon and its dialogs, including button labels, dialog titles, command tooltips, and menu items. Localization can be done by adding a resource file (Resx) and setting the desired culture in the application. The default culture is `en-US`.

The default English (`en-US`) resource files (`Syncfusion.SfRichTextBoxAdv.WPF.resx` and `Syncfusion.SfRichTextRibbon.WPF.resx`) are embedded inside the `Syncfusion.SfRichTextBoxAdv.WPF` and `Syncfusion.SfRichTextRibbon.WPF` assemblies, so they are available without any additional setup.

To localize the controls to a different culture, add a culture-specific `<assembly-name>.<culture>.resx` file (for example, `Syncfusion.SfRichTextBoxAdv.WPF.fr.resx`) to your project with its `Build Action` set to `Embedded Resource`. The runtime resource manager will then pick up the localized strings for the current UI culture, falling back to the embedded default if no culture-specific match is found.

## Setting Current UI Culture

For localizing your application to specific culture, you have to set the CurrentUICulture’ as required before invoking the InitializeComponent() method.
For localizing your application to a specific culture, set the `CurrentUICulture` to the required culture before invoking the `InitializeComponent()` method.

The following code example demonstrates how to set culture information for localizing an application.
The following code example demonstrates how to set the culture for localizing an application.

{% tabs %}
{% highlight c# %}
Expand All @@ -30,7 +34,7 @@ public MainWindow()
{% highlight VB %}
Partial Public Class MainWindow
Public Sub New()
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fr-FR")
System.Threading.Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo("fr-FR")
InitializeComponent()
End Sub
End Class
Expand All @@ -40,24 +44,40 @@ End Class

{% endtabs %}

[View example in GitHub](https://github.com/SyncfusionExamples/WPF-RichTextBox-Examples/tree/main/Samples/Localization)
[View the complete localization sample on GitHub](https://github.com/SyncfusionExamples/WPF-RichTextBox-Examples/tree/main/Samples/Localization)

## Adding Resource file

* Create a folder with name ‘Resources’ in your application.
* Add default English(“en-US”) [Resx](https://github.com/SyncfusionExamples/WPF-RichTextBox-Examples/tree/main/Samples/Localization/Localization/Resources) (resource) file of SfRichTextBoxAdv and SfRichTextRibbon in the ‘Resources’ folder named as Syncfusion.SfRichTextBoxAdv.WPF.resx and Syncfusion.SfRichTextRibbon.WPF.resx respectively
* Create Resx (resource) files and named as Syncfusion.SfRichTextBoxAdv.WPF. [Culture name].resx and Syncfusion.SfRichTextRibbon.WPF. [Culture name].resx. For example, Syncfusion.SfRichTextBoxAdv.WPF.fr.resx and Syncfusion.SfRichTextRibbon.WPF.fr.resx for French culture. For your reference, French(“fr-FR”) [Resx](https://github.com/SyncfusionExamples/WPF-RichTextBox-Examples/tree/main/Samples/Localization/Localization/Resources) file.
### Create the Resources folder

Create a folder named `Resources` in your project root (alongside your `.csproj` / `.vbproj` file).

### Add the default Resx

The default English (`en-US`) [Resx](https://github.com/SyncfusionExamples/WPF-RichTextBox-Examples/tree/main/Samples/Localization/Localization/Resources) (resource) files for `SfRichTextBoxAdv` and `SfRichTextRibbon` are available in the [GitHub sample](https://github.com/SyncfusionExamples/WPF-RichTextBox-Examples/tree/main/Samples/Localization). Copy `Syncfusion.SfRichTextBoxAdv.WPF.resx` and `Syncfusion.SfRichTextRibbon.WPF.resx` from the sample into the `Resources` folder of your application.

![Added resource files for SfRichTextBoxAdv and SfRichTextRibbon shown in the Visual Studio Resources folder](Localization_images/wpf-richtextbox-resource-file.jpeg)

### Create the localized Resx

Create Resx (resource) files named `Syncfusion.SfRichTextBoxAdv.WPF.<culture>.resx` and `Syncfusion.SfRichTextRibbon.WPF.<culture>.resx`. For example, `Syncfusion.SfRichTextBoxAdv.WPF.fr.resx` and `Syncfusion.SfRichTextRibbon.WPF.fr.resx` for the French (`fr`) culture. For your reference, see the French (`fr`) [Resx](https://github.com/SyncfusionExamples/WPF-RichTextBox-Examples/tree/main/Samples/Localization/Localization/Resources) files.

### Add resource keys

Add a resource key (such as the name of the string) and its corresponding localized value in the Resource Designer of the `Syncfusion.SfRichTextBoxAdv.WPF.fr.resx` and `Syncfusion.SfRichTextRibbon.WPF.fr.resx` files.

![Displaying Added Resource File for WPF RichTextBox](Localization_images/wpf-richtextbox-resource-file.jpeg)
![Resource Designer showing the name and localized value columns for the Resx file](Localization_images/wpf-richtextbox-property-values.jpeg)

* Add the resource key such as name and its corresponding localized value in Resource Designer of Syncfusion.SfRichTextBoxAdv.WPF.fr.resx and Syncfusion.SfRichTextRibbon.WPF.fr.resx file.
N> If you have not used `SfRichTextRibbon` in your application, you can skip the `Syncfusion.SfRichTextRibbon.WPF.<culture>.resx` files mentioned above. After adding or modifying Resx files, rebuild the application so the new resources are picked up at runtime.

![Displaying Resource File Property Items of WPF RichTextBox](Localization_images/wpf-richtextbox-property-values.jpeg)
The following screenshot shows the localization in the SfRichTextBoxAdv and SfRichTextRibbon controls

N> If you have not used SfRichTextRibbon in your application, you can skip Syncfusion.SfRichTextRibbon.WPF.[Culture name].resx file mentioned above.
![SfRichTextBoxAdv and SfRichTextRibbon rendered with French-localized text in the ribbon and dialogs](Localization_images/wpf-richtextbox-localized-text.jpeg)

The following screenshot shows the localization in SfRichTextBoxAdv and SfRichTextRibbon
N> You can refer to our [WPF RichTextBox](https://www.syncfusion.com/docx-editor-sdk/wpf-docx-editor) feature tour page for its groundbreaking feature representations. You can also explore our [WPF RichTextBox example](https://github.com/syncfusion/docx-editor-sdk-wpf-demos) to know how to render and configure the editing tool.

![Displaying Localized Text in WPF RichTextBoxAdv and RichTextRibbon](Localization_images/wpf-richtextbox-localized-text.jpeg)
## See Also

N> You can refer to our [WPF RichTextBox](https://www.syncfusion.com/docx-editor-sdk/wpf-docx-editor) feature tour page for its groundbreaking feature representations.You can also explore our [WPF RichTextBox example](https://github.com/syncfusion/docx-editor-sdk-wpf-demos) to knows how to render and configure the editing tools.
- [Getting Started in WPF RichTextBox](./Getting-Started)
- [Commands in WPF RichTextBox](./Commands)
- [Document Structure in WPF RichTextBox](./Document-Structure)
47 changes: 27 additions & 20 deletions Document-Processing/Word/Word-Processor/wpf/MVVM.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ description: Learn here all about MVVM support in Syncfusion WPF RichTextBox (Sf
platform: document-processing
control: SfRichTextBoxAdv
documentation: ug
keywords: mvvm
keywords: mvvm,data-binding,dependency-property,two-way-binding,viewmodel
---
# MVVM in WPF RichTextBox (SfRichTextBoxAdv)

The [WPF RichTextBox](https://www.syncfusion.com/docx-editor-sdk/wpf-docx-editor) (SfRichTextBoxAdv) control can be used with Model-View-View Model (MVVM) pattern. This section will demonstrate how to use the SfRichTextBoxAdv control with MVVM pattern.
The [WPF RichTextBox](https://www.syncfusion.com/docx-editor-sdk/wpf-docx-editor) (SfRichTextBoxAdv) control can be used with the Model-View-ViewModel (MVVM) pattern. This section demonstrates how to use the SfRichTextBoxAdv control with the MVVM pattern. For a complete working example, see the [WPF RichTextBox MVVM sample on GitHub](https://github.com/SyncfusionExamples/WPF-RichTextBox-Examples/tree/main/Samples/MVVM).

## Creating a View Model

The following code example demonstrates how to implement a view model class that contains properties to preserve the description about some of the animals and the animal that is selected for discussion. Whenever the animal chosen for discussion is changed, previously chosen animal description is updated to the database and newly chosen animal description is updated to the text property.
The following code example demonstrates how to implement a view model class that contains properties to hold a collection of animals, the currently selected animal, and the description for the selected animal. When the selected animal changes, the `Text` property is updated with the new animal's description; when `Text` changes (typed by the user), the in-memory description for the current animal is updated.
{% tabs %}
{% highlight c# %}
/// <summary>
Expand All @@ -32,7 +32,7 @@ public class ViewModel : INotifyPropertyChanged
/// Gets or sets the animal.
/// </summary>
/// <value>
/// The document title.
/// The animal.
/// </value>
public string Animal
{
Expand Down Expand Up @@ -63,7 +63,7 @@ public class ViewModel : INotifyPropertyChanged
/// Gets or sets the Text.
/// </summary>
/// <value>
/// The document.
/// The text.
/// </value>
public string Text
{
Expand Down Expand Up @@ -104,7 +104,7 @@ public class ViewModel : INotifyPropertyChanged
animals.Add("Tiger", "The tiger is the largest cat species, reaching a total body length of up to 3.38 m over curves and exceptionally weighing up to 388.7 kg in the wild.");
animals.Add("Lion", "The lion is one of the strongest animal. It is also known as the king of jungles.");
animals.Add("Panda", "The giant panda, also known as panda bear or simply panda, is a bear native to south central China. It is easily recognized by the large, distinctive black patches around its eyes, over the ears, and across its round body.");
animals.Add("Beer", "Bears are mammals and are classified as dog like carnivorous.");
animals.Add("Bear", "Bears are mammals and are classified as dog like carnivorous.");
animals.Add("Deer", "Deer are the ruminant mammals. Species in the family include the white-tailed deer, mule deer, elk, moose, red deer, reindeer, fallow deer, roe deer.");

Animal = "Lion";
Expand Down Expand Up @@ -214,7 +214,7 @@ Public Class ViewModel
m_animals.Add("Tiger", "The tiger is the largest cat species, reaching a total body length of up to 3.38 m over curves and exceptionally weighing up to 388.7 kg in the wild.");
m_animals.Add("Lion", "The lion is one of the strongest animal. It is also known as the king of jungles.");
m_animals.Add("Panda", "The giant panda, also known as panda bear or simply panda, is a bear native to south central China. It is easily recognized by the large, distinctive black patches around its eyes, over the ears, and across its round body.");
m_animals.Add("Beer", "Bears are mammals and are classified as dog like carnivorous.");
m_animals.Add("Bear", "Bears are mammals and are classified as dog like carnivorous.");
m_animals.Add("Deer", "Deer are the ruminant mammals. Species in the family include the white-tailed deer, mule deer, elk, moose, red deer, reindeer, fallow deer, roe deer.");

Animal = "Lion"
Expand Down Expand Up @@ -243,7 +243,8 @@ End Class

## Implementing extension class for SfRichTextBoxAdv

The following code example demonstrates how to implement an extension class for SfRichTextBoxAdv with dependency property that supports two way binding.
`SfRichTextBoxAdv` does not expose a `Text` dependency property of its own, so a derived class is needed to add two-way binding support. The following code example demonstrates how to implement an extension class for SfRichTextBoxAdv with a dependency property that supports two-way binding. The extension listens to the control's [ContentChanged](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Controls.RichTextBoxAdv.SfRichTextBoxAdv.html#Syncfusion_Windows_Controls_RichTextBoxAdv_SfRichTextBoxAdv_ContentChanged) event and re-reads the document as plain text whenever the user edits.

{% tabs %}
{% highlight c# %}
/// <summary>
Expand Down Expand Up @@ -314,7 +315,7 @@ public class SfRichTextBoxAdvExtension : SfRichTextBoxAdv
{
if (this.Document != null)
{
// To skip internal updation of document on setting Text property.
// To skip internal updating of the document when setting the Text property.
skipUpdating = true;
Stream stream = new MemoryStream();
// Saves the document's text into a Stream.
Expand All @@ -337,7 +338,7 @@ public class SfRichTextBoxAdvExtension : SfRichTextBoxAdv
/// <param name="text"></param>
private void UpdateDocument(string text)
{
// If text property is set internally means, skip updating the document.
// If the Text property is being set internally, skip updating the document.
if (!skipUpdating && !string.IsNullOrEmpty(text))
{
Stream stream = new MemoryStream();
Expand All @@ -346,7 +347,7 @@ public class SfRichTextBoxAdvExtension : SfRichTextBoxAdv
// Writes the byte array to stream.
stream.Write(bytes, 0, bytes.Length);
stream.Position = 0;
//Load the stream.
// Loads the stream.
Load(stream, FormatType.Txt);
}
}
Expand Down Expand Up @@ -389,14 +390,14 @@ Public Class SfRichTextBoxAdvExtension
#End Region

#Region "Constructor"
''' <summary>
''' Initializes the instance of SfRichTextBoxAdvExtension class.
''' </summary>
Public Sub New()
' Wires the ContentChanged event.
AddHandler this.ContentChanged, AddressOf RicTextBoxAdv_ContentChanged
End Sub
#End Region
''' <summary>
''' Initializes the instance of SfRichTextBoxAdvExtension class.
''' </summary>
Public Sub New()
' Wires the ContentChanged event.
AddHandler Me.ContentChanged, AddressOf RicTextBoxAdv_ContentChanged
End Sub
#End Region

#Region "Static Dependency Properties"
''' <summary>
Expand Down Expand Up @@ -517,4 +518,10 @@ The following code example demonstrates how to create XAML view with SfRichTextB

{% endtabs %}

N> You can refer to our [WPF RichTextBox](https://www.syncfusion.com/docx-editor-sdk/wpf-docx-editor) feature tour page for its groundbreaking feature representations.You can also explore our [WPF RichTextBox example](https://github.com/syncfusion/docx-editor-sdk-wpf-demos) to knows how to render and configure the editing tools.
N> You can refer to our [WPF RichTextBox](https://www.syncfusion.com/docx-editor-sdk/wpf-docx-editor) feature tour page for its groundbreaking feature representations. You can also explore our [WPF RichTextBox example](https://github.com/syncfusion/docx-editor-sdk-wpf-demos) to know how to render and configure the editing tool.

## See Also

- [Commands in WPF RichTextBox](./Commands)
- [Layout Types in WPF RichTextBox](./Layout-Types)
- [Document Structure in WPF RichTextBox](./Document-Structure)
26 changes: 18 additions & 8 deletions Document-Processing/Word/Word-Processor/wpf/Mini-Toolbar.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,48 @@ description: Learn here all about Mini Toolbar support in Syncfusion WPF RichTex
platform: document-processing
control: SfRichTextBoxAdv
documentation: ug
keywords: mini-toolbar
keywords: mini-toolbar,context-menu,formatting,floating-toolbar
---
# Mini Toolbar in WPF RichTextBox (SfRichTextBoxAdv)

The [WPF RichTextBox](https://www.syncfusion.com/docx-editor-sdk/wpf-docx-editor) (SfRichTextBoxAdv) supports built-in mini toolbar to provide rich text formatting options such as Bold, Italic etc. The following screenshot shows built-in mini toolbar of SfRichTextBoxAdv control.
![WPF RichTextBox displays Mini Toolbar](Mini-Toolbar_images/wpf-richtextbox-mini-toolbar.jpeg)
The [WPF RichTextBox](https://www.syncfusion.com/docx-editor-sdk/wpf-docx-editor) (SfRichTextBoxAdv) supports a built-in mini toolbar to provide rich text formatting options such as Bold, Italic, etc. The mini toolbar can be enabled or disabled through the [EnableMiniToolBar](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Controls.RichTextBoxAdv.SfRichTextBoxAdv.html#Syncfusion_Windows_Controls_RichTextBoxAdv_SfRichTextBoxAdv_EnableMiniToolBar) property.

The following screenshot shows the built-in mini toolbar of the SfRichTextBoxAdv control.
![WPF RichTextBox showing the built-in mini toolbar with formatting options above a selected text range](Mini-Toolbar_images/wpf-richtextbox-mini-toolbar.jpeg)

## Enable/Disable Mini Toolbar

In SfRichTextBoxAdv, the built-in mini toolbar is enabled by default. It is possible to enable/disable the built-in mini toolbar. The following code example demonstrates how to disable the built-in mini toolbar in SfRichTextBoxAdv.
In SfRichTextBoxAdv, the built-in mini toolbar is enabled by default (the default value of [EnableMiniToolBar](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Controls.RichTextBoxAdv.SfRichTextBoxAdv.html#Syncfusion_Windows_Controls_RichTextBoxAdv_SfRichTextBoxAdv_EnableMiniToolBar) is `true`). You can enable or disable the built-in mini toolbar as needed. Set `EnableMiniToolBar` to `true` to explicitly enable it, or to `false` to disable it.

The following code example demonstrates how to disable the built-in mini toolbar in the SfRichTextBoxAdv control.
{% tabs %}
{% highlight xaml %}
<RichTextBoxAdv:SfRichTextBoxAdv x:Name="richTextBoxAdv" EnableMiniToolBar="False" xmlns:RichTextBoxAdv="clr-namespace:Syncfusion.Windows.Controls.RichTextBoxAdv;assembly=Syncfusion.SfRichTextBoxAdv.Wpf" />
<RichTextBoxAdv:SfRichTextBoxAdv x:Name="richTextBoxAdv" EnableMiniToolBar="False"/>

{% endhighlight %}
{% highlight c# %}
// Initializes a new instance of RichTextBoxAdv.
SfRichTextBoxAdv richTextBoxAdv = new SfRichTextBoxAdv();

//Disables the built-in mini tool bar in SfRichTextBoxAdv.
// Disables the built-in mini toolbar in the SfRichTextBoxAdv.
richTextBoxAdv.EnableMiniToolBar = false;

{% endhighlight %}
{% highlight VB %}
' Initializes a new instance of RichTextBoxAdv.
Dim richTextBoxAdv As New SfRichTextBoxAdv()

'Disables the built-in mini tool bar in SfRichTextBoxAdv.
' Disables the built-in mini toolbar in the SfRichTextBoxAdv.
richTextBoxAdv.EnableMiniToolBar = False


{% endhighlight %}
{% endtabs %}

N> You can refer to our [WPF RichTextBox](https://www.syncfusion.com/docx-editor-sdk/wpf-docx-editor) feature tour page for its groundbreaking feature representations.You can also explore our [WPF RichTextBox example](https://github.com/syncfusion/docx-editor-sdk-wpf-demos) to knows how to render and configure the editing tools.
N> You can refer to our [WPF RichTextBox](https://www.syncfusion.com/docx-editor-sdk/wpf-docx-editor) feature tour page for its groundbreaking feature representations. You can also explore our [WPF RichTextBox example](https://github.com/syncfusion/docx-editor-sdk-wpf-demos) to know how to render and configure the editing tool.

## See Also

- [Getting Started in WPF RichTextBox](./Getting-Started)
- [Commands in WPF RichTextBox](./Commands)
- [Document Structure in WPF RichTextBox](./Document-Structure)
Loading