/// <summary> /// Returns a list of all the resx files contained recursivelly in the basePath directory passed. /// The /// </summary> /// <param name="basePath">Where do you want to search for .resx</param> /// <param name="display">A predicate function to modify the string to be displayed. Can be null.</param> /// <returns></returns> public static SortedList <string, string> GetResXInDirectory(string basePath, GenericPredicate <string, string> display) { DirectoryInfo dir = new DirectoryInfo(basePath); FileInfo[] files = dir.GetFiles("*.resx", SearchOption.AllDirectories); SortedList <string, string> dict = new SortedList <string, string>(); foreach (FileInfo file in files) { string baseName = ResXUnified.GetBaseName(file.FullName); string path = Path.GetDirectoryName(file.FullName); string displayName = display == null ? path : display(path, basePath); displayName = Path.Combine(displayName, baseName); if (!dict.ContainsKey(displayName)) { dict.Add(displayName, file.FullName); } } return(dict); }
public ResXUnifiedIndexer(ResXUnified resx, string language) { this.resx = resx; this.language = language; }
private void FillGridView(string p, bool reloadFile) { if (Unified == null || reloadFile) Unified = new ResXUnified(p); gridView.Columns.Clear(); SortedList<string, string> langs = Unified.GetLanguages(); Unit columnSize = new Unit(Math.Round((gridView.Width.Value) / (langs.Values.Count)), UnitType.Percentage); ImageField keyColumn = new ImageField(); keyColumn.HeaderText = "Key"; keyColumn.DataAlternateTextField = "Key"; keyColumn.DataImageUrlField = "Key"; keyColumn.DataImageUrlFormatString = "~/App_Themes/" + Page.Theme + "/images/information.png"; // ignore key //keyColumn.DataField = "Key"; //keyColumn.ItemStyle.BackColor = Color.Gray; //keyColumn.ItemStyle.ForeColor = Color.White; keyColumn.ReadOnly = true; keyColumn.ItemStyle.Width = new Unit(30); keyColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left; keyColumn.ControlStyle.Width = new Unit(16, UnitType.Pixel); gridView.Columns.Add(keyColumn); foreach (string lang in langs.Values) { CultureInfo culture = null; try { culture = new CultureInfo(lang); } catch { } BoundField field = new BoundField { HeaderText = culture != null ? culture.DisplayName : @"Default", DataField = lang, ReadOnly = (culture == null) && !Roles.IsUserInRole("Administrator") }; field.ControlStyle.Width = new Unit(99,UnitType.Percentage); if (culture != null) { if (culture.TextInfo.IsRightToLeft) { field.ItemStyle.HorizontalAlign = HorizontalAlign.Right; field.ControlStyle.CssClass = "rtl"; } } if (lang == "Default") gridView.Columns.Insert(1,field); else if (culture.TwoLetterISOLanguageName.ToLower() == currEditLang.ToLower()) { currCultureName = culture.TextInfo.CultureName; gridView.Columns.Add(field); } } if (gridView.Columns.Count < 3 && !String.IsNullOrEmpty(currEditLang)) { try { if (!String.IsNullOrEmpty(currCultureName)) ddLanguage.SelectedValue = currCultureName; } catch (Exception) { //don't throw an error if it doesn't exist in the list } pnlAddLang.Visible = true; } else { pnlAddLang.Visible = false; } gridView.DataSource = Unified.ToDataTable(true); gridView.DataBind(); }