public AssemblyResultTS Sync(string assembly, string culture, string? @namespace = null) { Assembly ass = AssembliesToLocalize().Where(a => a.GetName().Name == assembly).SingleEx(() => "Assembly {0}".FormatWith(assembly)); CultureInfo targetCulture = CultureInfo.GetCultureInfo(culture); CultureInfo defaultCulture = CultureInfo.GetCultureInfo(ass.GetCustomAttribute <DefaultAssemblyCultureAttribute>().DefaultCulture); var cultures = TranslationLogic.CurrentCultureInfos(defaultCulture); Dictionary <CultureInfo, LocalizedAssembly> reference = (from ci in cultures let la = DescriptionManager.GetLocalizedAssembly(ass, ci) where la != null || ci == defaultCulture || ci == targetCulture select KVP.Create(ci, la ?? LocalizedAssembly.ImportXml(ass, ci, forceCreate: ci == defaultCulture || ci == targetCulture))).ToDictionary(); var master = reference.Extract(defaultCulture); var target = reference.Extract(targetCulture); var changes = TranslationSynchronizer.GetAssemblyChanges(TranslationServer.Translator, target, master, reference.Values.ToList(), null, @namespace, out int totalTypes); return(new AssemblyResultTS { totalTypes = totalTypes, cultures = cultures.Select(c => c.ToCulturesTS()).ToDictionary(a => a.name), types = changes.Types.Select(t => t.Type.Type.ToLocalizableTypeTS().Let(localizedTypes => { localizedTypes.cultures = cultures.ToDictionary(c => c.Name, c => GetLocalizedType(t, c, c.Equals(targetCulture))); return localizedTypes; })).ToDictionary(lt => lt.type), }); }
public List <NamespaceSyncStats> SyncStats(string assembly, string culture) { Assembly ass = AssembliesToLocalize().Where(a => a.GetName().Name == assembly).SingleEx(() => "Assembly {0}".FormatWith(assembly)); CultureInfo targetCulture = CultureInfo.GetCultureInfo(culture); CultureInfo defaultCulture = CultureInfo.GetCultureInfo(ass.GetCustomAttribute <DefaultAssemblyCultureAttribute>().DefaultCulture); var targetAssembly = DescriptionManager.GetLocalizedAssembly(ass, targetCulture) ?? LocalizedAssembly.ImportXml(ass, targetCulture, forceCreate: true) !; var defaultAssembly = DescriptionManager.GetLocalizedAssembly(ass, defaultCulture) ?? LocalizedAssembly.ImportXml(ass, defaultCulture, forceCreate: true) !; return(TranslationSynchronizer.SyncNamespaceStats(targetAssembly, defaultAssembly)); }
private TranslatedSummaryState CalculateStatus(Assembly a, CultureInfo ci) { var fileName = LocalizedAssembly.TranslationFileName(a, ci); if (!System.IO.File.Exists(fileName)) { return(TranslatedSummaryState.None); } var target = DescriptionManager.GetLocalizedAssembly(a, ci) !; CultureInfo defaultCulture = CultureInfo.GetCultureInfo(a.GetCustomAttribute <DefaultAssemblyCultureAttribute>().DefaultCulture); var master = DescriptionManager.GetLocalizedAssembly(a, defaultCulture) !; var result = TranslationSynchronizer.GetMergeChanges(target, master, new List <LocalizedAssembly>()); if (result.Any()) { return(TranslatedSummaryState.Pending); } return(TranslatedSummaryState.Completed); }
public TranslatedSummaryState Status(Lite <RoleEntity> role) { if (!System.IO.File.Exists(FileName)) { return(TranslatedSummaryState.None); } var target = DescriptionManager.GetLocalizedAssembly(Assembly, CultureInfo); CultureInfo defaultCulture = CultureInfo.GetCultureInfo(Assembly.GetCustomAttribute <DefaultAssemblyCultureAttribute>().DefaultCulture); var master = DescriptionManager.GetLocalizedAssembly(Assembly, defaultCulture); var result = TranslationSynchronizer.GetMergeChanges(target, master, new List <LocalizedAssembly>()); if (result.Any(r => role == null || TranslationLogic.GetCountNotLocalizedMemebers(role, CultureInfo, r.Type.Type) > 0)) { return(TranslatedSummaryState.Pending); } return(TranslatedSummaryState.Completed); }
public ActionResult Sync(string assembly, string culture, bool translatedOnly, Lite <RoleEntity> role) { Assembly ass = AssembliesToLocalize().Where(a => a.GetName().Name == assembly).SingleEx(() => "Assembly {0}".FormatWith(assembly)); CultureInfo targetCulture = CultureInfo.GetCultureInfo(culture); CultureInfo defaultCulture = CultureInfo.GetCultureInfo(ass.GetCustomAttribute <DefaultAssemblyCultureAttribute>().DefaultCulture); Dictionary <CultureInfo, LocalizedAssembly> reference = (from ci in TranslationLogic.CurrentCultureInfos(defaultCulture) let la = DescriptionManager.GetLocalizedAssembly(ass, ci) where la != null || ci == defaultCulture || ci == targetCulture select KVP.Create(ci, la ?? LocalizedAssembly.ImportXml(ass, ci, forceCreate: true))).ToDictionary(); var master = reference.Extract(defaultCulture); var target = reference.Extract(targetCulture); DictionaryByTypeName(target); //To avoid finding duplicated types on save int totalTypes; var changes = TranslationSynchronizer.GetAssemblyChanges(TranslationClient.Translator, target, master, reference.Values.ToList(), role, null, out totalTypes); ViewBag.Role = role; ViewBag.TotalTypes = totalTypes; ViewBag.Culture = targetCulture; return(base.View(TranslationClient.ViewPrefix.FormatWith("Sync"), changes)); }