private static void AddToDictionary(Dictionary <string, string> resultDictionary, string[] lines, ILocalizationReplaceProvider provider = null) { for (int i = 1; i < lines.Length; i++) { string line = lines[i]; if (!string.IsNullOrEmpty(line.Trim())) { int position = line.IndexOf("=", StringComparison.InvariantCultureIgnoreCase); string name = line.Substring(0, position - 1).Trim(); string value = line.Substring(position + 1).Trim(); if (null != provider) { int startIndex = value.IndexOf("{0:$", 0); if (startIndex > -1) { int endIndex = value.IndexOf("}", startIndex + 1); if (endIndex > -1) { string marker = value.Substring(startIndex, endIndex - startIndex + 1); string replaceContent = provider.Replace(marker); value = value.Replace(marker, replaceContent); } } } resultDictionary.Add(name, value); } } }
private static Dictionary<string, string> GetTranslateRessources(string[] splitArray, int languageId, ILocalizationReplaceProvider provider = null) { Dictionary<string, string> resultDictionary = new Dictionary<string, string>(); foreach (string item in splitArray) { string[] lines = item.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); foreach (string line in lines) { if ("[" + languageId.ToString() + "]" == line.Trim()) { AddToDictionary(resultDictionary, lines, provider); return resultDictionary; } } } return resultDictionary; }
private static Dictionary <string, string> GetTranslateRessources(string[] splitArray, int languageId, ILocalizationReplaceProvider provider = null) { Dictionary <string, string> resultDictionary = new Dictionary <string, string>(); foreach (string item in splitArray) { string[] lines = item.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); foreach (string line in lines) { if ("[" + languageId.ToString() + "]" == line.Trim()) { AddToDictionary(resultDictionary, lines, provider); return(resultDictionary); } } } return(resultDictionary); }
private static void AddToDictionary(Dictionary<string, string> resultDictionary, string[] lines, ILocalizationReplaceProvider provider = null) { for (int i = 1; i < lines.Length; i++) { string line = lines[i]; if (!string.IsNullOrEmpty(line.Trim())) { int position = line.IndexOf("=", StringComparison.InvariantCultureIgnoreCase); string name = line.Substring(0, position - 1).Trim(); string value = line.Substring(position + 1).Trim(); if (null != provider) { int startIndex = value.IndexOf("{0:$", 0); if (startIndex > -1) { int endIndex = value.IndexOf("}", startIndex + 1); if (endIndex > -1) { string marker = value.Substring(startIndex, endIndex - startIndex +1); string replaceContent = provider.Replace(marker); value = value.Replace(marker, replaceContent); } } } resultDictionary.Add(name, value); } } }