Esempio n. 1
0
        public ActionResult Index(Lite <RoleEntity> role)
        {
            var cultures = TranslationLogic.CurrentCultureInfos(CultureInfo.GetCultureInfo("en"));

            var assemblies = AssembliesToLocalize().ToDictionary(a => a.FullName);

            var dg = DirectedGraph <Assembly> .Generate(assemblies.Values, a => a.GetReferencedAssemblies().Select(an => assemblies.TryGetC(an.FullName)).NotNull());

            var dic = dg.CompilationOrderGroups().SelectMany(gr => gr.OrderBy(a => a.FullName)).ToDictionary(a => a,
                                                                                                             a => cultures.Select(ci => new TranslationFile
            {
                Assembly    = a,
                CultureInfo = ci,
                IsDefault   = ci.Name == a.GetCustomAttribute <DefaultAssemblyCultureAttribute>().DefaultCulture,
                FileName    = LocalizedAssembly.TranslationFileName(a, ci)
            }).ToDictionary(tf => tf.CultureInfo));


            if (role != null)
            {
                ViewBag.Role = role.InDB().Select(e => e.ToLite()).SingleEx();
            }

            return(base.View(TranslationClient.ViewPrefix.FormatWith("Index"), dic));
        }
Esempio n. 2
0
        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);
        }