Seal.Forms.ToolsHelper.ExportSourceTranslations C# (CSharp) Méthode

ExportSourceTranslations() public méthode

public ExportSourceTranslations ( ExecutionLogInterface log ) : void
log ExecutionLogInterface
Résultat void
        public void ExportSourceTranslations(ExecutionLogInterface log)
        {
            Repository repository = Repository.Instance.CreateFast();
            StringBuilder translations = new StringBuilder();
            try
            {
                log.Log("Starting the export of the Data Source translations for '{0}'\r\n", Source.Name);
                string separator = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ListSeparator;
                string extraSeparators = initTranslationFile(translations, separator, repository);

                log.Log("Adding elements names in context: Element\r\n");
                foreach (var table in Source.MetaData.Tables)
                {
                    foreach (var element in table.Columns)
                    {
                        translations.AppendFormat("Element{0}{1}{0}{2}{3}\r\n", separator, Helper.QuoteDouble(element.Category + '.' + element.DisplayName), Helper.QuoteDouble(element.DisplayName), extraSeparators);
                    }
                }

                log.Log("Adding enum values in context: Enum\r\n");
                foreach (var enumList in Source.MetaData.Enums.Where(i => i.Translate))
                {
                    foreach (var enumVal in enumList.Values)
                    {
                        translations.AppendFormat("Enum{0}{1}{0}{2}{3}\r\n", separator, Helper.QuoteDouble(enumList.Name), Helper.QuoteDouble(enumVal.Val), extraSeparators);
                    }
                }

                log.Log("Adding Sub-Report names in context: SubReport\r\n");
                foreach (var table in Source.MetaData.Tables)
                {
                    foreach (var element in table.Columns)
                    {
                        foreach (var subReport in element.SubReports)
                        {
                            translations.AppendFormat("SubReport{0}{1}{0}{2}{3}\r\n", separator, Helper.QuoteDouble(element.Category + '.' + element.DisplayName), subReport.Name, extraSeparators);
                        }
                    }
                }

                string fileName = FileHelper.GetUniqueFileName(Path.Combine(repository.SettingsFolder, Helper.CleanFileName(string.Format("RepositoryTranslations_{0}_WORK.csv", Source.Name))));
                File.WriteAllText(fileName, translations.ToString(), Encoding.UTF8);

                log.Log("\r\nExport of the Data Source translations terminated.\r\n\r\nThe file has been saved to '{0}' and can be re-worked and merged with the repository translations file.\r\n\r\nNote that the effective repository translations file is 'RepositoryTranslations.csv' in the Repository Sub-Folder 'Settings'.", fileName);

                Process.Start(fileName);
            }
            catch (Exception ex)
            {
                log.Log("\r\n[UNEXPECTED ERROR RECEIVED]\r\n{0}\r\n", ex.Message);
            }
        }