コード例 #1
0
        /// <summary>
        /// Create basic project from scratch, not using templates and add files from selected folder
        /// </summary>
        public void CreateProject(LocalProjectSettings settings)
        {
            try
            {
                ////Create new project object
                FileBasedProject createdProject = new FileBasedProject(
                    GetProjectInfo(
                        settings.ProjectName,
                        new Language(settings.SourceLanguage),
                        new Language[] { new Language(settings.TargetLanguage) }, settings.OutputPath));

                ////Add files from selected folder
                createdProject.AddFolderWithFiles(settings.InputFolder, true);

                ////Start the tasks
                RunTasks(createdProject, settings);

                createdProject.Save();
                ////project is saved but not listed in Studio, this is by design.
            }
            catch (Exception ex)
            {
                throw new Exception("Problem during project creation", ex);
            }
        }
コード例 #2
0
        /// <summary>
        /// Create a new project from the seected project package
        /// </summary>
        /// <param name="settings"></param>
        public void CreateProjectFromPackage(LocalProjectSettings settings)
        {
            try
            {
                ProjectPackageImport projectPackageImport;
                var createdProject = FileBasedProject.CreateFromProjectPackage(settings.PackagePath, settings.OutputPath, out projectPackageImport);

                createdProject.Save();
            }
            catch (Exception ex)
            {
                throw new Exception("Problem during project creation", ex);
            }
        }
コード例 #3
0
        /// <summary>
        /// Run defalut Batch Tasks after creating a new project
        /// </summary>
        /// <param name="createdProject">A project you have created</param>
        /// <param name="settings">Settings containing initial input parameters</param>
        private void RunTasks(FileBasedProject createdProject, LocalProjectSettings settings)
        {
            Language targetLanguage = new Language(settings.TargetLanguage);
            List <TaskStatusEventArgs> taskStatusEventArgsList = new List <TaskStatusEventArgs>();
            List <MessageEventArgs>    messageEventArgsList    = new List <MessageEventArgs>();

            // set up  perfect match
            ProjectFile[] projectFiles = createdProject.GetSourceLanguageFiles();
            createdProject.AddBilingualReferenceFiles(GetBilingualFileMappings(new Language[] { targetLanguage }, projectFiles, settings.OutputPath));

            // scan files
            AutomaticTask automaticTask = RunTasks(
                createdProject,
                projectFiles,
                AutomaticTaskTemplateIds.Scan,
                taskStatusEventArgsList,
                messageEventArgsList);

            CheckEvents(taskStatusEventArgsList, messageEventArgsList);

            // convert files
            automaticTask = RunTasks(
                createdProject,
                projectFiles,
                AutomaticTaskTemplateIds.ConvertToTranslatableFormat,
                taskStatusEventArgsList,
                messageEventArgsList);

            CheckEvents(taskStatusEventArgsList, messageEventArgsList);

            // copy files to target languages
            automaticTask = RunTasks(
                createdProject,
                projectFiles,
                AutomaticTaskTemplateIds.CopyToTargetLanguages,
                taskStatusEventArgsList,
                messageEventArgsList);

            CheckEvents(taskStatusEventArgsList, messageEventArgsList);

            // from now on use target language files
            projectFiles = createdProject.GetTargetLanguageFiles(targetLanguage);

            // Apply Perfect Match
            automaticTask = RunTasks(
                createdProject,
                projectFiles,
                AutomaticTaskTemplateIds.PerfectMatch,
                taskStatusEventArgsList,
                messageEventArgsList);

            CheckEvents(taskStatusEventArgsList, messageEventArgsList);

            // analyze files
            automaticTask = RunTasks(
                createdProject,
                projectFiles,
                AutomaticTaskTemplateIds.AnalyzeFiles,
                taskStatusEventArgsList,
                messageEventArgsList);

            CheckEvents(taskStatusEventArgsList, messageEventArgsList);

            // translate files
            automaticTask = RunTasks(
                createdProject,
                projectFiles,
                AutomaticTaskTemplateIds.PreTranslateFiles,
                taskStatusEventArgsList,
                messageEventArgsList);

            CheckEvents(taskStatusEventArgsList, messageEventArgsList);

            // populate project TM
            automaticTask = RunTasks(
                createdProject,
                projectFiles,
                AutomaticTaskTemplateIds.PopulateProjectTranslationMemories,
                taskStatusEventArgsList,
                messageEventArgsList);

            CheckEvents(taskStatusEventArgsList, messageEventArgsList);
        }