Completed
Last Updated: 14 Feb 2019 16:13 by ADMIN
Mihajlo
Created on: 29 Jan 2019 13:46
Category: RichTextEditor
Type: Bug Report
1
Button OK not being localized.. mostly

I added this line just before Application.Run(new MainForm()); in Word-inspired project:

RichTextBoxLocalizationProvider.CurrentProvider = RichTextBoxLocalizationProvider.FromFile(@"AllCapsRichTextBoxStrings.xml");

 

I took RichTextBoxStrings.xml from localization page of RichTextEditor. In the xml file I converted all the text between <value> tags to uppercase, and also replaced "OK" (value of "Confirm" data element) with "AYE". I expected all the OK's in all the forms within rich text editor to be replaced, but they all remained as "Ok" (note the lower case "k" here). Well, all except Page Layout > Columns form, which did display AYE, and also References > Insert citation. So, here are the issues that I found:

  • XML file in localizaiton page of RichTextEditor is missing entries for resources "Ok", "Insert", and "Apply".
  • "Ok" resource is used in most places, but "Confirm" resource (with value "OK") is used in AddNewBibliographicSourceDialog.cs and SectionColumns\SectionColumnsDialog.cs. This seems inconsistent.
  • Paper sizes are not localizable, which is actually fine by me for all but the last paper size, "Size14x10", but then what is the purpose of all RibbonUI_PaperSizeXxx resources in resource file?
  • Value of resource "Documents_InsertHyperlinkDialog_SelectionInDocument" is weird. Not sure this resource should even exist, as I could not make it appear in the InsertHyperlinkDialog. Looks like a dummy placeholder.
  • Fallback mechanism for missing resources is weird. If resource is missing the resource name is returned as resource value, which is the reason why Ok, Insert, and Apply are actually shown. Maybe this is intentional, if resource is missing it will be obvious (for unusual resource names). Alternative would be not to change the string at all, as it is already set to default english in .Designer.cs file anyway. So instead of "this.someTextBox.Text = LocalizationManager.GetString("Some_Resource");" it would be something like "this.someTextBox.Text = LocalizationManager.GetString("Some_Resource", this.someTextBox.Text);".

To create AllCapsRichTextBoxStrings.xml, make a copy of provided resource file, open it in Notepad++ and replace all <value>([^<]*)</value> with <value>\U\1\E</value> using regular expressions, and then replace all &AMP;, &LT; and &GT; with &amp;, &lt; and &gt;.

2 comments
Dimitar
Posted on: 14 Feb 2019 12:42

Hello,

A fix will be available in Telerik UI for WinForms version R1 2019 SP1.

Button "Ok" will be localized in all dialogs. Additionally, all paper size strings will be localized as well.

Regards,
Dimitar

ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 30 Jan 2019 11:28
Hello, Mihajlo,       

I have logged it in our feedback portal by making this thread public. You can track its progress, subscribe for status changes and add your comments on the following link - https://feedback.telerik.com/winforms/1385263-button-ok-not-being-localized-mostly

I have also updated your Telerik points.

Currently, the possible solution that I can suggest is to open the xml file that contains the localized strings and add the missing texts in the following format:

<data name="Ok">
  <value>My OK</value>
</data>

As to the paper sizes, indeed they are not localized properly. In order to use the text in the XML, it is necessary to create a derivative of RichTextEditorRibbonBar and override its GetPaperSizeItems method:  

public class CustomRichTextEditorRibbonBar : RichTextEditorRibbonBar
{
    protected override Telerik.WinControls.RadItemCollection GetPaperSizeItems()
    {
        RadItemCollection collection = new RadItemCollection();
 
        foreach (PaperSize paperSize in this.GetPaperSizes())
        {
            float width = (float)paperSize.Width / 100f;
            float height = (float)paperSize.Height / 100f;
            string formatString = string.Empty;
 
            if (System.Globalization.RegionInfo.CurrentRegion.IsMetric)
            {
                width *= 2.54f;
                height *= 2.54f;
                formatString = "<html><b>{0}</b> ({1:F1}" + LocalizationManager.GetString("RibbonUI_Centemeter") +
                               "x {2:F1}" + LocalizationManager.GetString("RibbonUI_Centemeter") + ")</html>";
            }
            else
            {
                formatString = "<html><b>{0}</b> ({1:F1}\" x {2:F1}\")</html>";
            }
 
            RadMenuItem item = new RadMenuItem();
            item.Text = string.Format(formatString, LocalizationManager.GetString("RibbonUI_PaperSize"+paperSize.PaperName), width, height);
            item.Tag = Enum.Parse(typeof(PaperTypes), paperSize.PaperName);
 
            collection.Add(item);
        }
 
        return collection;
    }
}

The "Documents_InsertHyperlinkDialog_SelectionInDocument" text is used in the InsertHyperlinkDialog. It is shown in rare cases when the selected text is null. In this case the "Text to display" RadTextBox is disabled and the localized text is shown.

Your feedback about the fallback mechanism is greatly appreciated. We will consider it in the future control's improvement. If any string is missing in the XML file, feel free to add it as it was mentioned above. Thus, you can obtain the desired text.

I hope this information helps. If you need any further assistance please don't hesitate to contact me.