예제 #1
0
        String GenerateOutput(EntityLocalizationEntry[] dsCurrent, EntityLocalizationEntry[] dsNew, EntityLocalizationEntry[] dsDeleted)
        {
            var list = new List <EntityLocalizationEntry>();

            if (dsCurrent != null)
            {
                list.AddRange(dsCurrent);
            }
            if (dsNew != null)
            {
                list.AddRange(dsNew);
            }
            if (dsDeleted != null)
            {
                list.AddRange(dsDeleted);
            }

            var blocks = (from c in list
                          where c.IsChecked
                          group c by new {
                EntityNameForOverride = c.LocalizableProperty.EnclosingEntity.EntityNameForOverride,
                IsDextopLocalize = c.LocalizableProperty.EnclosingEntity.IsDextopLocalize
            } into grp
                          select new LocalizedEntityBlock {
                EntityNameForOverride = grp.Key.EntityNameForOverride,
                IsDextopLocalize = grp.Key.IsDextopLocalize,
                LocalizationGridRows = grp.ToArray()
            }
                          ).ToArray();


            var com = LocalizationModule.Create(LocalizerType).Composer;

            return(com.GenerateOutputFile(blocks));
        }
예제 #2
0
        private void Run()
        {
            List <String> fileNames = tbInputFiles.Text.Split(new String[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).ToList();
            List <String> includes  = new List <string>();
            List <String> excludes  = new List <string>();

            foreach (var fileName in fileNames)
            {
                if (fileName.StartsWith("-"))
                {
                    excludes.Add(fileName.Substring(1));
                }
                else if (!fileName.StartsWith("#"))
                {
                    includes.Add(fileName);
                }
            }
            try
            {
                EntityExtractor ext = LocalizationModule.Create(LocalizerType).Extractor;
                ext.Logger = WindowLogger;

                Dictionary <String, LocalizableEntity> map1 = new Dictionary <string, LocalizableEntity>();
                ext.ProcessFileList(includes.ToArray(), excludes.ToArray(), RootPathResolved, FileExtension, map1);

                map1 = map1.OrderBy(a => a.Value.ShallowEntityPath).ToDictionary(a => a.Key, a => a.Value);

                Dictionary <String, LocalizableEntity> map2 = new Dictionary <string, LocalizableEntity>();
                try
                {
                    ext.ProcessFile(ReferenceResolved, map2);
                }
                catch (Exception ex)
                {
                    WindowLogger.LogFormat("Warning: error parsing reference input ({0})", ex.Message);
                }

                map2 = map2.OrderBy(a => a.Value.ShallowEntityPath).ToDictionary(a => a.Key, a => a.Value);

                Dictionary <String, LocalizableEntity> map3 = new Dictionary <string, LocalizableEntity>();

                Diff(map1, map2, map3);

                map3 = map3.OrderBy(a => a.Value.ShallowEntityPath).ToDictionary(a => a.Key, a => a.Value);

                dgvNew.DataSource     = GetLocalizationGridDataSource(map1, false);
                dgvCurrent.DataSource = GetLocalizationGridDataSource(map2, true);
                dgvDeleted.DataSource = GetLocalizationGridDataSource(map3, false);
            }
            catch (Exception ex)
            {
                WindowLogger.Log(ex.Message);
            }
        }