public void FileNuggetFinder_disable_references() { var settingService = new SettingService_Mock(); settingService.SetSetting("i18n.WhiteList", "ReferencesTest.txt"); { i18nSettings settings = new i18nSettings(settingService); FileNuggetFinder finder = new FileNuggetFinder(settings); var templates = finder.ParseAll(); var item = templates.Values.First(); Assert.AreEqual(5, item.References.Count()); } { //Disabling references settingService.SetSetting("i18n.DisableReferences", "true"); i18nSettings settings = new i18nSettings(settingService); FileNuggetFinder finder = new FileNuggetFinder(settings); var templates = finder.ParseAll(); var item = templates.Values.First(); Assert.AreEqual(1, item.References.Count()); } }
static void Main(string[] args) { //TestCode //args = new string[] {@"C:\viducate2\Viducate\Viducate.WebUI\Web.config"}; string configPath; if (args.Length == 0) { System.Console.WriteLine("You have to specify path to web.config."); return; } try { configPath = args[0]; using (FileStream fs = File.Open(configPath, FileMode.Open)) { } } catch (Exception) { System.Console.WriteLine("Failed to open config file at path."); return; } //todo: this assumes PO files, if not using po files then other solution needed. i18nSettings settings = new i18nSettings(new WebConfigSettingService(configPath)); POTranslationRepository rep = new POTranslationRepository(settings); FileNuggetFinder nugget = new FileNuggetFinder(settings); var items = nugget.ParseAll(); rep.SaveTemplate(items); TranslationMerger ts = new TranslationMerger(rep); ts.MergeAllTranslation(items); Console.WriteLine("i18n.PostBuild completed successfully."); }
private void Run() { ThrowIfConfigFileNotFound(); ReferenceContext.ShowSourceContext = ShowSourceContext; //todo: this assumes PO files, if not using po files then other solution needed. var settings = new i18nSettings(new WebConfigSettingService(ConfigPath)); settings.LocaleOtherFiles = Enumerable.Empty<string>(); var repository = new POTranslationRepository(settings); var nuggetFinder = new FileNuggetFinder(settings); var items = nuggetFinder.ParseAll(); repository.SaveTemplate(items); var merger = new TranslationMerger(repository); merger.MergeAllTranslation(items); Console.WriteLine("i18n.PostBuild completed successfully."); }
/// <summary> /// This function is the callback used to execute a command when the a menu item is clicked. /// See the Initialize method to see how the menu item is associated to this function using /// the OleMenuCommandService service and the MenuCommand class. /// </summary> private void _menuItemCallback(object sender, EventArgs e) { dynamic currentProject = _getCurrentProject(); if (currentProject != null) { var dir = new DirectoryInfo((string) currentProject.FullName).Parent; // ReSharper disable PossibleNullReferenceException var configPath = dir.FullName + "\\web.config"; // ReSharper restore PossibleNullReferenceException. Can't be null as is being picked from project if (!File.Exists(configPath)) { throw new Exception("Project does not have a web.config file"); } var settings = new i18nSettings(new WebConfigSettingService(configPath)); var rep = new POTranslationRepository(settings); var nugget = new FileNuggetFinder(settings); var items = nugget.ParseAll(); rep.SaveTemplate(items); var ts = new TranslationMerger(rep); ts.MergeAllTranslation(items); var uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); var clsid = Guid.Empty; int result; ErrorHandler.ThrowOnFailure(uiShell.ShowMessageBox( 0, ref clsid, "i18n.POTGenerator", string.Format(CultureInfo.CurrentCulture, "POT File generated correctly"), string.Empty, 0, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST, OLEMSGICON.OLEMSGICON_INFO, 0, // false out result)); } }