public ActionResult SaveView(string assembly, string culture, string filter) { var currentAssembly = AssembliesToLocalize().Single(a => a.GetName().Name == assembly); List <TranslationRecord> list = GetTranslationRecords(); if (culture.HasText()) { LocalizedAssembly locAssembly = LocalizedAssembly.ImportXml(currentAssembly, CultureInfo.GetCultureInfo(culture), forceCreate: true); list.GroupToDictionary(a => a.Type).JoinDictionaryForeach(locAssembly.Types.Values.ToDictionary(a => a.Type.Name), (tn, tuples, lt) => { foreach (var t in tuples) { t.Apply(lt); } }); locAssembly.ExportXml(); } else { Dictionary <string, LocalizedAssembly> locAssemblies = TranslationLogic.CurrentCultureInfos(CultureInfo.GetCultureInfo("en")).ToDictionary(ci => ci.Name, ci => LocalizedAssembly.ImportXml(currentAssembly, ci, forceCreate: true)); Dictionary <string, List <TranslationRecord> > groups = list.GroupToDictionary(a => a.Lang); list.GroupToDictionary(a => a.Lang).JoinDictionaryForeach(locAssemblies, (cn, recs, la) => { recs.GroupToDictionary(a => a.Type).JoinDictionaryForeach(la.Types.Values.ToDictionary(a => a.Type.Name), (tn, tuples, lt) => { foreach (var t in tuples) { t.Apply(lt); } }); la.ExportXml(); }); } return(RedirectToAction("View", new { assembly = assembly, culture = culture, searchPressed = true, filter = filter })); }
public ActionResult SaveSync(string assembly, string culture) { Assembly currentAssembly = AssembliesToLocalize().Where(a => a.GetName().Name == assembly).SingleEx(() => "Assembly {0}".FormatWith(assembly)); LocalizedAssembly locAssembly = LocalizedAssembly.ImportXml(currentAssembly, CultureInfo.GetCultureInfo(culture), forceCreate: true); List <TranslationRecord> records = GetTranslationRecords(); records.GroupToDictionary(a => a.Type).JoinDictionaryForeach(DictionaryByTypeName(locAssembly), (tn, tuples, lt) => { foreach (var t in tuples) { t.Apply(lt); } }); locAssembly.ExportXml(); return(RedirectToAction("Index")); }
public void SaveTypes(string assembly, string culture, [Required, FromBody] AssemblyResultTS result) { var currentAssembly = AssembliesToLocalize().Single(a => a.GetName().Name == assembly); var cultureGroups = (from a in result.types.Values from lt in a.cultures.Values group new { a.type, lt } by lt.culture into cg select cg).ToList(); foreach (var cultureGroup in cultureGroups) { LocalizedAssembly locAssembly = LocalizedAssembly.ImportXml(currentAssembly, CultureInfo.GetCultureInfo(cultureGroup.Key), forceCreate: true) !; var types = cultureGroup.ToDictionary(a => a.type !, a => a.lt !); /*CSBUG*/ foreach (var lt in locAssembly.Types.Values) { var ts = types.TryGetC(lt.Type.Name); if (ts != null) { if (ts.typeDescription != null) { var td = ts.typeDescription; lt.Gender = td.gender?[0]; lt.Description = td.description; lt.PluralDescription = td.pluralDescription; } lt.Members !.SetRange(ts.members.Select(a => KVP.Create(a.Key !, a.Value.description !))); } } locAssembly.ExportXml(); } }