public static void SetTranslated(TranslatorItem item) { if (BaseSettings.TranslationMode) { string[] k = item.Key.Split('*'); string page = k[0]; string ciName = k[1]; var ci = new CultureInfo(ciName); string sourceName = k[2]; string key = k[3]; WriteToResx(sourceName, ci, key, item.Val); if (item.Split != "true") { CommonResourcesCache.SetText(sourceName, ciName, key, item.Val); } lock (g_translatedContainer) { if (g_translatedContainer.ContainsKey(ci)) { if (g_translatedContainer[ci].ContainsKey(page)) { var i = g_translatedContainer[ci][page].SingleOrDefault(c => c.Key == item.Key); if (i != null) { i.Val = item.Val; } } } } } }
internal static void AddTranslated(BaseStringsStorage source, string key, string val, bool bSplit, string langId) { if (BaseSettings.TranslationMode) { var ci = langId == null ? Thread.CurrentThread.CurrentUICulture : new CultureInfo(CustomCultureHelper.GetCustomCultureName(langId)); string page = getPageForWeb(); var n = source.ResourceName.Split('.'); string sourceName = n[n.Length - 1]; if (page != null) { lock (g_translatedContainer) { if (!g_translatedContainer.ContainsKey(ci)) { g_translatedContainer.Add(ci, new Dictionary <string, TranslatorContainer>()); } if (!g_translatedContainer[ci].ContainsKey(page)) { g_translatedContainer[ci].Add(page, new TranslatorContainer()); } string k = page + "*" + ci.Name + "*" + sourceName + "*" + key; if (g_translatedContainer[ci][page].Find(c => c.Key == k) == null) { string[] langs = Config.GetSetting("TranslationModeLanguages", "en").Split(','); string l1 = langs.Length > 0 ? source.GetStringInternal(key, key, langs[0]) : ""; var bIsValueExists = source.IsValueExists; string l2 = langs.Length > 1 ? source.GetStringInternal(key, key, langs[1]) : ""; bIsValueExists = bIsValueExists || source.IsValueExists; g_translatedContainer[ci][page].Add(new TranslatorItem() { Key = k, Lang1 = l1, Lang2 = l2, Val = val, Split = bSplit ? "true" : "", IsValueExists = bIsValueExists }); } else { var item = g_translatedContainer[ci][page].Find(c => c.Key == k); item.Val = val; item.Split = bSplit ? "true" : ""; } } } if (!bSplit) { CommonResourcesCache.SetText(sourceName, ci.Name, key, val); } } // in the scanning resources usage mode - gather in g_resourcesFormView forms and views where current function was invoked from if (BaseSettings.ScanFormsMode) { var formView = GetFormViewFromStack(); // remember found form and view string file = source.ResourceName.Substring(source.ResourceName.LastIndexOf('.') + 1); g_resourcesFormView.Add(new Tuple <string, string, string, string>(key, file, formView.Item1, formView.Item2)); } }
internal static Tuple <string, bool> GetTranslated(BaseStringsStorage source, string key, string stringValue, string langId, string parentViewName, out bool found) { if (BaseSettings.TranslationMode) { // During resource reading in Translation mode we first check SplittedResources xml file - if it contains given resource for currently translated view. string view = null; if (parentViewName == null) { var formView = GetFormViewFromStack(); view = String.IsNullOrEmpty(formView.Item2) ? formView.Item1 : formView.Item2; } else { view = parentViewName; } string splitted; if ((splitted = ResourceSplitter.Read(view, key, langId, null)) != null) { found = true; return(new Tuple <string, bool>(splitted, true)); } ////////////////////////////// var ci = langId == null ? Thread.CurrentThread.CurrentUICulture : new CultureInfo(CustomCultureHelper.GetCustomCultureName(langId)); var n = source.ResourceName.Split('.'); string sourceName = n[n.Length - 1]; if (CommonResourcesCache.ContainsKey(sourceName, ci.Name, key)) { found = true; source.IsValueExists = true; return(new Tuple <string, bool>(CommonResourcesCache.GetText(sourceName, ci.Name, key), false)); } if (HttpContext.Current != null) { return(new Tuple <string, bool>(ReadFormResx(sourceName, langId, key, stringValue, out found), false)); } } var res = new Tuple <string, bool>(source.GetStringInternal(key, stringValue, langId), false); found = source.IsValueExists; return(res); }