public static LocalisationContainer CreateLocaleFromFile(string fileName) { LocalisationContainer container = new LocalisationContainer(Path.GetFileNameWithoutExtension(fileName)); IEnumerable <string> lines = File.ReadLines(fileName); bool firstline = true; foreach (string line in lines) { if (firstline) { container.ShortName = line.Replace(":", "").Trim(); firstline = false; } else { LocaleContent content = new LocaleContent() { Key = line.Split(':')[0].Trim(), Value = Regex.Match(line.Split(':')[1], "\"([^\"]*)\"").Groups[1].Value.Trim() }; container.LocalisationMap.Add(content); } } return(container); }
private void NotificationMessageReceived(NotificationMessage msg) { if (msg.Target != null && msg.Target != this) { //Message not itended for here return; } if (msg.Notification == "OpenFocusTree") { FociGridContainer container = msg.Sender as FociGridContainer; if (TabsModelList.Where((t) => t is FocusGridModel && ((FocusGridModel)t).UniqueID == container.IdentifierID).Any()) { return; } FocusGridModel newModel = new FocusGridModel(container.IdentifierID); TabsModelList.Add(newModel); RaisePropertyChanged("TabsModelList"); } if (msg.Notification == "OpenLocalisation") { LocalisationContainer container = msg.Sender as LocalisationContainer; if (TabsModelList.Where((t) => t is LocalisationModel && ((LocalisationModel)t).UniqueID == container.IdentifierID).Any()) { return; } LocalisationModel newModel = new LocalisationModel(container.IdentifierID); TabsModelList.Add(newModel); RaisePropertyChanged("TabsModelList"); } if (msg.Notification == "SaveProject") { saveProject(); } if (msg.Notification == "RefreshProjectViewer") { TabsModelList.Clear(); RaisePropertyChanged("TabsModelList"); } if (msg.Notification == "SendDeleteItemSignal") { ObservableObject Model = null; if (msg.Sender is FociGridContainer) { Model = TabsModelList.FirstOrDefault((m) => m is FocusGridModel && ((FocusGridModel)m).UniqueID == ((FociGridContainer)msg.Sender).IdentifierID); } else if (msg.Sender is LocalisationContainer) { Model = TabsModelList.FirstOrDefault((m) => m is LocalisationModel && ((LocalisationModel)m).UniqueID == ((LocalisationContainer)msg.Sender).IdentifierID); } TabsModelList.Remove(Model); RaisePropertyChanged("TabsModelList"); } }
private void TestLocaleToScript(LocalisationModel model) { //Arrange LocalisationContainer container = new LocalisationContainer(model); List <LocalisationContainer> list = new List <LocalisationContainer> { container }; //Act Dictionary <string, string> files = LocalisationParser.ParseEverything(list); string filecontent = files.FirstOrDefault().Value; string fileName = files.FirstOrDefault().Key; //Assert Assert.IsNotNull(filecontent); Assert.IsNotNull(fileName); Assert.AreEqual(fileName, "focus_l_english"); }
public LocalisationModel(LocalisationContainer container) { UniqueID = container.IdentifierID; visibleName = container.ContainerID; languageName = container.LanguageName; FileInfo = container.FileInfo; LocalisationMap = new ObservableCollection <LocaleModel>(); foreach (LocaleContent content in container.LocalisationMap) { LocalisationMap.Add(new LocaleModel() { Key = content.Key, Value = content.Value }); } LocalisationMap.CollectionChanged += LocalisationMap_CollectionChanged; SetupCommons(); }
public LocalisationContainer getSpecificLocalisationMap(Guid containerID) { LocalisationContainer container = localisationList.SingleOrDefault((c) => c.IdentifierID == containerID); return(container); }
public static string ParseLocalizationForCompare(LocalisationModel model) { LocalisationContainer container = new LocalisationContainer(model); return(Parse(container.LocalisationMap.ToList(), container.LanguageName)); }
private void OpenLocalisation(Guid param) { LocalisationContainer SelectedFile = localisationList.SingleOrDefault((f) => f.IdentifierID == param); Messenger.Default.Send(new NotificationMessage(SelectedFile, (new ViewModelLocator()).Main, "OpenLocalisation")); }