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: