Localization of the Telerik control-retrieving key-value pairs of the current control and telerik Retrieval

Source: Internet
Author: User

Localization of the Telerik control-retrieving key-value pairs of the current control and telerik Retrieval

(For the first time, I wrote something and found it to be reproduced. I giggle at it, so I will try it out in the afternoon for you to analyze it. The sister paper says it is rare to be reproduced once, encourage me to write more)

Telerik has different built-in English versions, and many built-in key-value pairs are incomplete. The following method is used to query all key-value pairs of the current control.

This is an idea to learn from the data warehouse.

The core idea is to add a new class that inherits LocalizationManager and CustomLocalizationManager, and then retrieve all key-value pairs when rewriting the language of this class.

1. Create a CustomLocalizationManager class to inject the control you want to obtain the key-value pair.

Load custom Chinese classes at the beginning of the project

  /// <summary>    /// Interaction logic for App.xaml    /// </summary>    public partial class App : Application    {        public App()        {            LocalizationManager.Manager = new CustomLocalizationManager();        }    }

 

 public class CustomLocalizationManager : LocalizationManager    {        public override string GetStringOverride(string key)        {            //switch (key)            //{            //    case "JudgementCode":            //        return "Your translation";            //}            if (!dataKeys.dic.ContainsKey(key))            {                DataKeys.dic.Add(key, base.GetStringOverride(key));            }            return base.GetStringOverride(key);         }    }

 

Add a Dictionary class to record key-value pairs:

 public static class DataKeys    {        public static Dictionary<string, string> dic = new Dictionary<string, string>();    }

2. Load a telerik control that you want to define as follows: (Note that the LocalizationManager class is injected into the control)

<telerik:RadGridView Grid.Row="0"                              AutoGenerateColumns="False"                             Margin="5"><telerik:RadGridView.Columns>                <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}">                    <telerik:GridViewDataColumn.Header>                        <TextBlock telerik:LocalizationManager.ResourceKey="JudgementCode"></TextBlock>                    </telerik:GridViewDataColumn.Header>                </telerik:GridViewDataColumn></telerik:RadGridView.Columns>        </telerik:RadGridView>

 

Then there will be no more... after compilation, debug DataKeys. dic, which records all key-value pairs (delete the tested key-value JudgementCode), and then load the localized resource file according to the method described in the previous article... over

The DataKeys. dic value is as follows:

KEYS:

CommitEditCommitCellEditBeginEditBeginInsertCancelCellEditCancelRowEditCopyDeleteMoveLeftMoveRightMoveUpMoveDownMoveNextMovePreviousMoveFirstMoveLastMoveHomeMoveEndMovePageDownMovePageUpMoveTopMoveBottomPasteSelectCurrentItemSelectCurrentUnitExtendSelectionToCurrentUnitActivateRowExpandHierarchyItemCollapseHierarchyItemJudgementCodeGridViewGroupPanelTextGridViewGroupPanelTopTextGrouped

VALUES:

Commit EditCommitCellEditBegin EditBegin InsertCancel Cell EditCancel Row EditCopyDeleteMove LeftMove RightMove UpMove DownMove NextMove PreviousMove FirstMove LastMove HomeMove EndMove PageDownMove PageUpMove TopMove BottomPasteSelect Current ItemSelect the current unitExtends selection to current unitActivateExpandCollapseDrag a column header and drop it here to group by that columnGrouped by:

  

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.