/// <summary> /// Initializes the plug-in settings, so that they can be used during the actual verification. /// </summary> /// <param name="settingsBundle"></param> /// <param name="configurationId"></param> #region "InitializeSettings" public void InitializeSettings(ISettingsBundle settingsBundle, string configurationId) { VerifierSettings _settings = new VerifierSettings(); _settings.PopulateFromSettingsBundle(settingsBundle, "Length Check XML v 1.0.0.0"); Enabled = _settings.Enable; }
/// <summary> /// This method is used to load the setting from the settings bundle, /// which is physically stored in an XML-compliant *.sdlproj or *.sdltpl file. /// </summary> /// <param name="settingsBundle"></param> /// <param name="configurationId"></param> #region "PopulateFromSettingsBundle" public override void PopulateFromSettingsBundle(ISettingsBundle settingsBundle, string filterDefinitionId) { ISettingsGroup settingsGroup = settingsBundle.GetSettingsGroup(filterDefinitionId); LockPrdCodes = GetSettingFromSettingsGroup(settingsGroup, SettingsLockPrdCodes, DefaultLockPrdCodes); PrdCodesPrefix = GetSettingFromSettingsGroup(settingsGroup, SettingsPrdCodesPrefix, DefaultPrdCodePrefix); }
/// <summary> /// Configures the analyze task file settings, i.e. in our implementation /// report cross-file repetitions and report the internal fuzzy match leverage. /// </summary> private void GetAnalyzeSettings( FileBasedProject project, string trgLocale, bool reportCrossFileRepetitions, bool reportInternalFuzzyMatchLeverage) #endregion { #region "trgLanguage" Language trgLanguage = new Language(CultureInfo.GetCultureInfo(trgLocale)); #endregion #region "ISettingsBundle" ISettingsBundle settings = project.GetSettings(trgLanguage); AnalysisTaskSettings analyzeSettings = settings.GetSettingsGroup <AnalysisTaskSettings>(); #endregion #region "ConfigureSettings" analyzeSettings.ReportCrossFileRepetitions.Value = reportCrossFileRepetitions; analyzeSettings.ReportInternalFuzzyMatchLeverage.Value = reportInternalFuzzyMatchLeverage; #endregion #region "UpdateSettings" project.UpdateSettings(trgLanguage, settings); #endregion }
/// <summary> /// This method is used to load the setting from the settings bundle, /// which is physically stored in an XML-compliant *.sdlproj or *.sdltpl file. /// </summary> /// <param name="settingsBundle"></param> /// <param name="configurationId"></param> #region "PopulateFromSettingsBundle" public override void PopulateFromSettingsBundle(ISettingsBundle settingsBundle, string configurationId) { ISettingsGroup settingsGroup = settingsBundle.GetSettingsGroup(configurationId); ResetToDefaults(); Enable = GetSettingFromSettingsGroup(settingsGroup, "Enable", Enable); }
public void GetPretranslateTaskSettings(FileBasedProject project) { #region "PetranslateTaskSettings" ISettingsBundle settings = project.GetSettings(); TranslateTaskSettings pretranslateSettings = settings.GetSettingsGroup <TranslateTaskSettings>(); #endregion #region "MinimumScore" pretranslateSettings.MinimumMatchScore.Value = 95; #endregion #region "ExactMatches" pretranslateSettings.ConfirmAfterApplyingExactMatch.Value = true; pretranslateSettings.LockExactMatchSegments.Value = false; #endregion #region "ContextMatches" pretranslateSettings.ConfirmAfterApplyingInContextExactMatch.Value = true; pretranslateSettings.LockContextMatchSegments.Value = true; #endregion #region "NoMatch" pretranslateSettings.NoTranslationMemoryMatchFoundAction.Value = NoTranslationMemoryMatchFoundAction.CopySourceToTarget; #endregion #region "TranslationOverwrite" pretranslateSettings.TranslationOverwriteMode.Value = TranslationUpdateMode.OverwriteExistingTranslation; #endregion #region "UpdateTaskSettings" project.UpdateSettings(settings); #endregion }
/// <summary> /// This method is used to store the settings as configured in the plug-in UI /// in the settings bundle, which means that the settings are physically written /// into the XML-compliant *.sdlproj or *.sdltpl file. /// </summary> /// <param name="settingsBundle"></param> /// <param name="configurationId"></param> #region "SaveToSettingsBundle" public override void SaveToSettingsBundle(ISettingsBundle settingsBundle, string filterDefinitionId) { ISettingsGroup settingsGroup = settingsBundle.GetSettingsGroup(filterDefinitionId); UpdateSettingInSettingsGroup(settingsGroup, SettingsLockPrdCodes, LockPrdCodes, DefaultLockPrdCodes); UpdateSettingInSettingsGroup(settingsGroup, SettingsPrdCodesPrefix, PrdCodesPrefix, DefaultPrdCodePrefix); }
public override void SaveToSettingsBundle(ISettingsBundle settingsBundle, string fileTypeConfigurationId) { var settingsGroup = settingsBundle.GetSettingsGroup(fileTypeConfigurationId); UpdateSettingInSettingsGroup(settingsGroup, IsPathFilteringEnabledSetting, IsPathFilteringEnabled, DefaultIsPathFilteringEnabled); _pathRules.SaveToSettingsGroup(settingsGroup, PathRulesSetting); }
/// <summary> /// This method is used to store the settings as configured in the plug-in UI /// in the settings bundle, which means that the settings are physically written /// into the XML-compliant *.sdlproj or *.sdltpl file. /// </summary> /// <param name="settingsBundle"></param> /// <param name="configurationId"></param> #region "SaveToSettingsBundle" public override void SaveToSettingsBundle(ISettingsBundle settingsBundle, string configurationId) { ISettingsGroup settingsGroup = settingsBundle.GetSettingsGroup(configurationId); var defaults = new VerifierSettings(); UpdateSettingInSettingsGroup(settingsGroup, "Enable", Enable, defaults.Enable); }
public void GetUpdateTmTaskSettings(FileBasedProject project) { #region "UpdateTmTaskSettings" ISettingsBundle settings = project.GetSettings(); TranslationMemoryUpdateTaskSettings updateTmSettings = settings.GetSettingsGroup <TranslationMemoryUpdateTaskSettings>(); #endregion #region "NewTranslations" updateTmSettings.TmImportOptions.Value = TmImportOption.AlwaysAddNewTranslation; #endregion #region "Status" updateTmSettings.UpdateWithApprovedSignOffSegments.Value = true; updateTmSettings.UpdateWithApprovedTranslationSegments.Value = true; updateTmSettings.UpdateWithTranslatedSegments.Value = true; updateTmSettings.UpdateWithDraftSegments.Value = false; updateTmSettings.UpdateWithRejectedSignOffSegments.Value = false; updateTmSettings.UpdateWithRejectedTranslationSegments.Value = false; updateTmSettings.UpdateWithUnspecifiedSegments.Value = false; #endregion #region "UpdateTaskSettings" project.UpdateSettings(settings); #endregion }
public void GetAnalyzeTaskSettings(FileBasedProject project) { #region "AnalysisTaskSettings" ISettingsBundle settings = project.GetSettings(); AnalysisTaskSettings analyseSettings = settings.GetSettingsGroup <AnalysisTaskSettings>(); #endregion #region "ReportCrossFileRepetitions" analyseSettings.ReportCrossFileRepetitions.Value = true; #endregion #region "ReportInternalFuzzyMatchLeverage" analyseSettings.ReportInternalFuzzyMatchLeverage.Value = true; #endregion #region "ExportFrequentSettings" analyseSettings.ExportFrequentSegments.Value = true; analyseSettings.FrequentSegmentsNoOfOccurrences.Value = 5; #endregion #region "ExportUnknownSegments" analyseSettings.ExportUnknownSegments.Value = true; analyseSettings.UnknownSegmentsMaximumMatchValue.Value = 50; #endregion #region "UpdateAnalyzeSettings" project.UpdateSettings(settings); #endregion }
/// <summary> /// Copies the settings group. /// </summary> /// <param name="sourceSettings">The source settings.</param> /// <param name="targetSettings">The target settings.</param> /// <param name="settingsGroupId">The settings group identifier.</param> /// <param name="targetProject">The target project.</param> /// <param name="targetLanguage">The target language.</param> private void CopySettingsGroup(ISettingsBundle sourceSettings, ISettingsBundle targetSettings, string settingsGroupId, FileBasedProject targetProject, Language targetLanguage) { if (!string.IsNullOrEmpty(settingsGroupId)) { if (targetSettings.ContainsSettingsGroup(settingsGroupId)) { targetSettings.RemoveSettingsGroup(settingsGroupId); } if (sourceSettings.ContainsSettingsGroup(settingsGroupId)) { ISettingsGroup sourceSettingsGroup = sourceSettings.GetSettingsGroup(settingsGroupId); ISettingsGroup targetSettingsGroup = targetSettings.GetSettingsGroup(settingsGroupId); targetSettingsGroup.ImportSettings(sourceSettingsGroup); if (targetLanguage == null) { targetProject.UpdateSettings(targetSettings); } else { targetProject.UpdateSettings(targetLanguage, targetSettings); } } } }
public override void PopulateFromSettingsBundle(ISettingsBundle settingsBundle, string fileTypeConfigurationId) { var settingsGroup = settingsBundle.GetSettingsGroup(fileTypeConfigurationId); SourceLineType = GetSettingFromSettingsGroup(settingsGroup, SourceLineTypeSetting, DefaultSourceLineType); IsTargetTextNeeded = GetSettingFromSettingsGroup(settingsGroup, IsTargetTextNeededSetting, DefaultIsTargetTextNeededSetting); }
public override void SaveToSettingsBundle(ISettingsBundle settingsBundle, string fileTypeConfigurationId) { var settingsGroup = settingsBundle.GetSettingsGroup(fileTypeConfigurationId); UpdateSettingInSettingsGroup(settingsGroup, SourceLineTypeSetting, SourceLineType, DefaultSourceLineType); UpdateSettingInSettingsGroup(settingsGroup, IsTargetTextNeededSetting, IsTargetTextNeeded, DefaultIsTargetTextNeededSetting); }
public override void SaveToSettingsBundle(ISettingsBundle settingsBundle, string fileTypeConfigurationId) { var settingsGroup = settingsBundle.GetSettingsGroup(fileTypeConfigurationId); UpdateSettingInSettingsGroup(settingsGroup, SettingRegexEmbeddingEnabled, Enabled, DefaultRegexEmbeddingEnabled); _structureInfos.SaveToSettingsGroup(settingsGroup, SettingStructureInfoList); _matchRules.SaveToSettingsGroup(settingsGroup, SettingMatchRuleList); }
public void SetUp() { _embeddedContentVisitorFactoryMock = A.Fake <IEmbeddedContentVisitorFactory>(); _embeddedContetnRegexSettingsMock = A.Fake <IEmbeddedContentRegexSettings>(); _textProcessorMock = A.Fake <ITextProcessor>(); _settingsBundleMock = A.Fake <ISettingsBundle>(); _itemFactoryMock = A.Fake <IDocumentItemFactory>(); }
/// <summary> /// This method is used to store the settings as configured in the plug-in UI /// in the settings bundle, which means that the settings are physically written /// into the XML-compliant *.sdlproj or *.sdltpl file. /// </summary> /// <param name="settingsBundle"></param> /// <param name="configurationId"></param> #region "SaveToSettingsBundle" public override void SaveToSettingsBundle(ISettingsBundle settingsBundle, string configurationId) { ISettingsGroup settingsGroup = settingsBundle.GetSettingsGroup(configurationId); var defaults = new VerifierSettings(); UpdateSettingInSettingsGroup(settingsGroup, nameof(CheckWordArt), CheckWordArt, defaults.CheckWordArt); UpdateSettingInSettingsGroup(settingsGroup, nameof(MaxWordCount), MaxWordCount, defaults.MaxWordCount); }
/// <summary> /// This method is used to load the setting from the settings bundle, /// which is physically stored in an XML-compliant *.sdlproj or *.sdltpl file. /// </summary> /// <param name="settingsBundle"></param> /// <param name="configurationId"></param> #region "PopulateFromSettingsBundle" public override void PopulateFromSettingsBundle(ISettingsBundle settingsBundle, string configurationId) { ISettingsGroup settingsGroup = settingsBundle.GetSettingsGroup(configurationId); ResetToDefaults(); CheckWordArt = GetSettingFromSettingsGroup(settingsGroup, nameof(CheckWordArt), CheckWordArt); MaxWordCount = GetSettingFromSettingsGroup(settingsGroup, nameof(MaxWordCount), MaxWordCount); }
/// <summary> /// Initializes the plug-in settings, so that they can be used during the actual verification. /// </summary> /// <param name="settingsBundle"></param> /// <param name="configurationId"></param> #region "InitializeSettings" public void InitializeSettings(ISettingsBundle settingsBundle, string configurationId) { VerifierSettings _settings = new VerifierSettings(); _settings.PopulateFromSettingsBundle(settingsBundle, "Word 2007 v 2.0.0.0 WordArt Verifier"); CheckWordArt = _settings.CheckWordArt; MaxWordCount = _settings.MaxWordCount; }
private void CopySettingsFuzzyBands(ISettingsBundle sourceSettingsBundle, ISettingsBundle targetSettingsBundle, string settingsGroupId, FileBasedProject sourceProject, FileBasedProject targetProject) { //Valentin -> code already prepared for the "long term" Studio API solution change, if the "Studio team" will add this AnalysisBands settings in the BundleSettings where it should be. //I hope that they will respect the naming convention and the section will be named "FuzzyBandsSettings" if (!CopySettingsGroup(sourceSettingsBundle, targetSettingsBundle, settingsGroupId, targetProject)) { CopySettingsFuzzyBands(sourceProject, targetProject); } }
public override void PopulateFromSettingsBundle(ISettingsBundle settingsBundle, string fileTypeConfigurationId) { var settingsGroup = settingsBundle.GetSettingsGroup(fileTypeConfigurationId); IsPathFilteringEnabled = GetSettingFromSettingsGroup(settingsGroup, IsPathFilteringEnabledSetting, DefaultIsPathFilteringEnabled); if (settingsGroup.ContainsSetting(PathRulesSetting)) { _pathRules.Clear(); _pathRules.PopulateFromSettingsGroup(settingsGroup, PathRulesSetting); } }
private void RemoveSettings(ISettingsBundle projectSettingsBundle) { if (projectSettingsBundle is null) { return; } if (!projectSettingsBundle.ContainsSettingsGroup(nameof(BatchAnonymizerSettings))) { return; } projectSettingsBundle.RemoveSettingsGroup(nameof(BatchAnonymizerSettings)); }
public void InitializeSettings_ShouldSetSettingsByPopulatingFromSettingsBundle() { // Arrange var testString = string.Empty; var testee = CreateTestee(testString); const string configurationId = "testId"; ISettingsBundle settingsBundleMock = A.Fake <ISettingsBundle>(); // Act testee.InitializeSettings(settingsBundleMock, configurationId); // Assert A.CallTo(() => _segmentSettingsMock.PopulateFromSettingsBundle(settingsBundleMock, configurationId)) .MustHaveHappened(); }
public override void PopulateFromSettingsBundle(ISettingsBundle settingsBundle, string fileTypeConfigurationId) { var settingsGroup = settingsBundle.GetSettingsGroup(fileTypeConfigurationId); Enabled = GetSettingFromSettingsGroup(settingsGroup, SettingRegexEmbeddingEnabled, DefaultRegexEmbeddingEnabled); if (settingsGroup.ContainsSetting(SettingStructureInfoList)) { _structureInfos.Clear(); _structureInfos.PopulateFromSettingsGroup(settingsGroup, SettingStructureInfoList); } if (settingsGroup.ContainsSetting(SettingMatchRuleList)) { _matchRules.Clear(); _matchRules.PopulateFromSettingsGroup(settingsGroup, SettingMatchRuleList); } }
public void GetPerfectMatchTaskSettings(FileBasedProject project) { #region "PerfectMatchTaskSettings" ISettingsBundle settings = project.GetSettings(); PerfectMatchTaskSettings perfectMatchSettings = settings.GetSettingsGroup <PerfectMatchTaskSettings>(); #endregion #region "MarkAsPerfectMatchAndLock" perfectMatchSettings.MarkAsPerfectMatchAndLock.Value = true; #endregion #region "UpdateTaskSettings" project.UpdateSettings(settings); #endregion }
public void GetProjectTmTaskSettings(FileBasedProject project) { #region "TaskSettings" ISettingsBundle settings = project.GetSettings(); ProjectTranslationMemoryTaskSettings projectTmSettings = settings.GetSettingsGroup <ProjectTranslationMemoryTaskSettings>(); #endregion #region "ProjectTmSettings" projectTmSettings.CreateServerBasedProjectTranslationMemories.Value = true; projectTmSettings.ServerConnectionUri.Value = string.Empty; projectTmSettings.TranslationMemoryContainerName.Value = "TMCont"; #endregion #region "UpdateTaskSettings" project.UpdateSettings(settings); #endregion }
/// <summary> /// Use project settings bundle to adapt specific project settings. For more details see Sdl.ProjectAutomation.Settings /// </summary> private void AdaptProjectSettings(FileBasedProject createdProject) { // Adapting translate task settings ISettingsBundle settings = createdProject.GetSettings(); TranslateTaskSettings translateSettings = settings.GetSettingsGroup <TranslateTaskSettings>(); translateSettings.NoTranslationMemoryMatchFoundAction.Value = NoTranslationMemoryMatchFoundAction.CopySourceToTarget; AnalysisTaskSettings analyzeSettings = settings.GetSettingsGroup <AnalysisTaskSettings>(); analyzeSettings.ExportFrequentSegments.Value = true; createdProject.UpdateSettings(settings); // Note the most complicated settings are TranslationMemorySettings, to adapt some part of these you need to use TM API // for example for filters. The documentation should mention this fact and describe how user can get a TM API (link to website) // We should not add such examples into ProjectAutomation API as it would add to many dependencies. }
public void GetExportTaskSettings(FileBasedProject project) { #region "ExportTaskSettings" ISettingsBundle settings = project.GetSettings(); ExportFilesSettings exportTaskSettings = settings.GetSettingsGroup <ExportFilesSettings>(); #endregion #region "ExportLocation" exportTaskSettings.ExportLocation.Value = @"c:\temp"; #endregion #region "ExportFileVersion" exportTaskSettings.ExportFileVersion.Value = ExportFileVersion.Bilingual; #endregion #region "UpdateSettings" project.UpdateSettings(settings); #endregion }
public void ConfigureBatchTaskSettings(FileBasedProject project, string trgLocale, int minMatchValue) { #region "SetLanguage" Language trgLanguage = new Language(CultureInfo.GetCultureInfo(trgLocale)); #endregion #region "TaskSettings" ISettingsBundle settings = project.GetSettings(trgLanguage); TranslateTaskSettings pretranslateSettings = settings.GetSettingsGroup <TranslateTaskSettings>(); #endregion #region "MinimumMatchScore" pretranslateSettings.MinimumMatchScore.Value = minMatchValue; #endregion #region "UpdateSettings" project.UpdateSettings(trgLanguage, settings); #endregion }
private static void RunFinetune(FileBasedProject testProject) { ISettingsBundle settings = testProject.GetSettings(); FinetuneBatchTaskSettings finetuneSettings = settings.GetSettingsGroup <FinetuneBatchTaskSettings>(); TranslateTaskSettings pretranslateSettings = settings.GetSettingsGroup <TranslateTaskSettings>(); /*pretranslateSettings.Finetune = true; * pretranslateSettings.ExtractFuzzies = true; * pretranslateSettings.FuzzyMaxResults = 5; * pretranslateSettings.ExtractFillerUnits = true; * pretranslateSettings.FuzzyMinPercentage = 60; * pretranslateSettings.BatchTranslate = false; * pretranslateSettings.AddFiskmoProvider = false; * pretranslateSettings.ExtractConcordanceUnits = true; * pretranslateSettings.MaxFinetuningSentences = 100000; * pretranslateSettings.IncludePlaceholderTags = false; * pretranslateSettings.IncludeTagPairs = false;*/ var finetuneTaskSettingsWindow = new FiskmoTranslationProvider.FinetuneWpfControl(finetuneSettings); Window window = new Window { Title = "Finetune task settings", Content = finetuneTaskSettingsWindow }; window.ShowDialog(); testProject.UpdateSettings(settings); AutomaticTask pretranslateTask = testProject.RunAutomaticTask( testProject.GetTargetLanguageFiles().GetIds(), AutomaticTaskTemplateIds.PreTranslateFiles); AutomaticTask finetuneTask = testProject.RunAutomaticTask( testProject.GetTargetLanguageFiles().GetIds(), "FiskmoBatchTask"); testProject.Save(); }
private bool CopySettingsGroup(ISettingsBundle sourceSettings, ISettingsBundle targetSettings, string settingsGroupId, FileBasedProject targetProject) { if (string.IsNullOrEmpty(settingsGroupId)) { return(false); } if (!sourceSettings.ContainsSettingsGroup(settingsGroupId)) { return(false); } if (targetSettings.ContainsSettingsGroup(settingsGroupId)) { targetSettings.RemoveSettingsGroup(settingsGroupId); } var sourceSettingsGroup = sourceSettings.GetSettingsGroup(settingsGroupId); var targetSettingsGroup = targetSettings.GetSettingsGroup(settingsGroupId); targetSettingsGroup.ImportSettings(sourceSettingsGroup); targetProject.UpdateSettings(targetSettings); return(true); }