private static void loadTranslations() { // If file/directory doesn't exist if (!checkFiles()) { // Stop loading translations return; } // Create stream to go over file's data using (FileStream fileStream = File.Open(CurrentTranslationsPath, FileMode.Open, FileAccess.Read)) { LastUpdated = File.GetLastWriteTime(CurrentTranslationsPath); // Binary reader for parsing of data using (BinaryReader reader = new BinaryReader(fileStream)) { // Clear translations Translations.Clear(); // Get number of translations int count = reader.ReadInt32(); for (int i = 0; i < count; i++) { // Get translation header and format string header = reader.ReadString(); string format = reader.ReadString(); Translations.Add(header, format); } } } }
public void LoadTranslations() { Translations.Clear(); using (var sr = new StreamReader(Core.TranslationLoader.OpenScriptTranslation(FullPath))) { string line; while ((line = sr.ReadLine()) != null) { var trimmed = line.Trim(); if (trimmed.Length == 0 || trimmed.StartsWith(";")) { continue; } if (trimmed.StartsWith(VOICE_SUBTITLE_TAG)) { ParseVoiceSubtitle(trimmed); continue; } var parts = line.Split(new[] { '\t' }, StringSplitOptions.RemoveEmptyEntries); var orig = parts[0].Unescape(); var tl = parts.Length > 1 ? parts[1].Unescape() : null; Translations[orig] = tl; } } }
private void PopulateTranslations() { Translations.Clear(); foreach (var te in Entity.Translations.Where(t => !t.Deleted).OrderBy(t => t.Language)) { Translations.Add(ServiceProvider.Inject(new TranslationVM(this, te))); } }
public void RegisterTranslation(PlayerTranslation playerTranslation) { Translations.Enqueue(playerTranslation); if (Translations.Count > 100) { Translations.Clear(); } // Console.WriteLine(playerTranslation); }
public void Clear() { Languages.Clear(); Currencies.Clear(); StoreMappings.Clear(); CustomerRoleMappings.Clear(); Manufacturers.Clear(); Categories.Clear(); DeliveryTimes.Clear(); Translations.Clear(); CustomProperties.Clear(); }
private async Task TranslateAllProviders() { Translations.Clear(); var lst = await translationService.TranslateAllProviders(this._phrase); var translatedList = new ObservableCollection <TranslationResult>(lst); if (Translations.Count == 0) { Translations.AddRange(translatedList); } }
private void ImportHandler() { List <Language.Languages> languages = new List <Language.Languages>() { TranslationWPF.Model.Language.Languages.French, TranslationWPF.Model.Language.Languages.English }; Translations.Clear(); ImportView view = new ImportView(); ImportVM importView = new ImportVM(Translations, languages, rm, ci); view.DataContext = importView; view.RaiseCustomEvent += new EventHandler <CustomEventArgs>(view_RaiseCustomEvent); view.Show(); //this.Close(); }
private static void loadTranslations(BinaryReader reader) { Translations.Clear(); // Get number of translations int count = reader.ReadInt32(); for (int i = 0; i < count; i++) { // Get translation header/format string header = reader.ReadString(); string format = reader.ReadString(); // Add to global list Translations.Add(header, format); } }
private async void SentenceClick(string obj) { Translations.Clear(); Synonyms.Clear(); Antonyms.Clear(); Sentences.Clear(); var reply = await new OxfordDictionaryMVVMService().GetSentenceAsync(chosenSrc, obj); if (reply != null) { foreach (var result in reply.results) { foreach (var lexicalEntry in result.lexicalEntries) { foreach (var sentence in lexicalEntry.sentences) { Sentences.Add(sentence.text); } } } } // exception handling else if (ChosenSrc.ToString() != "en" && ChosenSrc.ToString() != "es") { var messageDialog = new MessageDialog("Sentences are not supported in this language at present.") { Title = "Warning" }; messageDialog.Commands.Add(new UICommand("Close")); await messageDialog.ShowAsync(); } else { var messageDialog = new MessageDialog("There is no example sentence for that word!") { Title = "Warning" }; messageDialog.Commands.Add(new UICommand("Close")); await messageDialog.ShowAsync(); } }
public static void LoadFromStream(Stream stream) { // Binary reader for parsing of data using (BinaryReader reader = new BinaryReader(stream)) { if (LoadingDefaults) { // Clear translations Translations.Clear(); } // Get number of translations int count = reader.ReadInt32(); for (int i = 0; i < count; i++) { // Get translation Translation translation = Translation.Parse(reader); if (LoadingDefaults) { // If loading defaults, just add and skip the searching Translations.Add(translation); continue; } // Search for matching header Translation match = Translations.FirstOrDefault(x => x.Header == translation.Header); // If no match was found if (match == null) { // Add translation to list Translations.Add(translation); } else { // Set format to read format from config match.Format = translation.Format; } } } }
public bool LoadTranslations(string sourceDirectory) { //Load each of the translation's DLL files if (!Directory.Exists(sourceDirectory)) { return(false); } Translations.Clear(); foreach (FileInfo file in new DirectoryInfo(sourceDirectory).GetFiles("*.dll")) { Assembly assembly = Assembly.LoadFile(file.FullName); if (assembly != null) { Type[] pluginTypes = assembly.GetTypes(); foreach (Type t in pluginTypes) { if (typeof(ITranslation).IsAssignableFrom(t)) { if (!t.IsAbstract && t.IsPublic) { //Load this plugin try { ITranslation newTranslation = (ITranslation)assembly.CreateInstance(t.FullName); Translations.Add(newTranslation); } catch { } } } } } } RefreshCurrentTranslation(); return(true); }
/// <summary> /// Load a language by its 2-digit ISO code like EN, DE, ... /// </summary> /// <param name="isoCode">2-digit ISO code like EN, DE, ...</param> public static void LoadLanguage(string isoCode) { var lan = Languages.FirstOrDefault(x => x.Key == isoCode.ToUpperInvariant()); Translations.Clear(); var content = GetTextResource(lan.Value); var lines = content.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach (var line in lines) { var s = line.Split('='); var p = new KeyValuePair <string, string>(s[0].Trim().ToUpperInvariant(), s[1].Trim()); Translations.Add(p); } }
private void GetWordToShow() { WordToLearn = GetWordToLearn.WordToLearn.GetNextWord(); if (WordToLearn == null) { return; } var wordTranslationDirection = _random.Next(1, 1000) < 501; if (wordTranslationDirection) { SetWordToDisplay(WordToLearn.Value, WordToLearn.Statistics.CorrectAnswers, WordToLearn.Statistics.WrongAnswers); Translations.Clear(); foreach (var t in WordToLearn.Translations) { Translations.Add(t.Value); } } else { var numberOfTrnaslations = WordToLearn.Translations.Count; var selectedTranslationNr = _random.Next(0, numberOfTrnaslations); if (selectedTranslationNr > -1) { var selectedTranslation = WordToLearn.Translations.ElementAt(selectedTranslationNr); if (selectedTranslation != null) { SetWordToDisplay(selectedTranslation.Value, WordToLearn.Statistics.CorrectAnswers, WordToLearn.Statistics.WrongAnswers); var otherTranslations = WordToLearn.Translations.Where(x => x.Id != selectedTranslation.Id); Translations.Clear(); Translations.Add(WordToLearn.Value); foreach (var t in otherTranslations) { Translations.Add(t.Value); } } } } OnPropertyChanged("WordToDisplay"); }
static partial void BeginInit() { Translations.Clear(); try { Adapters.Connector.BaseUri = "https://localhost:5001/api"; var connector = Adapters.Connector.Create <Contracts.Modules.Language.ITranslation, Models.Modules.Language.Translation>(); var tranlations = AsyncHelper.RunSync(() => connector.QueryAllAsync($"AppName.Equals(\"{nameof(QnSHolidayCalendar)}\")")); foreach (var translation in tranlations) { Translations.Add(translation.Key, translation.Value); } } catch (Exception ex) { Console.WriteLine($"Error in {MethodBase.GetCurrentMethod().Name}: {ex.Message}"); } }
private void NewWordCommandExec(object obj) { if (!string.IsNullOrWhiteSpace(NewWord)) { var sql = NHibernate.Criterion.Expression.Sql("lower({alias}.Value) = lower(?)", NewWord, NHibernate.NHibernateUtil.String); var reply = WordsService.GetData <Word>(sql); if ((reply == null || reply.Count == 0) && HasTranslation()) { var r = ModernDialog.ShowMessage("word not saved do you want to save it?", "save or update word", MessageBoxButton.YesNo); if (r == MessageBoxResult.Yes) { SaveWord(null); } } Translations.Clear(); NewWord = string.Empty; m_selectedWord = null; AddTranslation(null); OnPropertyChanged("NewWord"); OnPropertyChanged("SelectedWord"); } }
internal void UpdateTranslationInfo(bool bOnlyInstalled) { if (!bOnlyInstalled) { Translations.Clear(); } UpdateInstalledTranslations(); if (!bOnlyInstalled) { UpdateAvailableTranslations(); } if (PluginDebug.DebugMode) { List <string> lT = new List <string>(); foreach (var t in Translations) { lT.Add(t.ToString()); } PluginDebug.AddInfo("Plugin languages - " + Name, 0, lT.ToArray()); } }
private async void TranslateClick(string obj) { Translations.Clear(); Synonyms.Clear(); Antonyms.Clear(); Sentences.Clear(); var reply = await new OxfordDictionaryMVVMService().GetTranslationAsync(chosenSrc, obj, ChosenDest); if (reply != null) { foreach (var result in reply.results) { foreach (var lexicalEntry in result.lexicalEntries) { foreach (var entry in lexicalEntry.entries) { foreach (var sense in entry.senses) { if (sense.translations == null) // exception handling { return; } foreach (var translation in sense.translations) { Translations.Add(translation.text); } } } } } } // exception handling else if (ChosenSrc == null) { var messageDialog = new MessageDialog("Choose a source language!") { Title = "Error" }; messageDialog.Commands.Add(new UICommand("Close")); await messageDialog.ShowAsync(); } else if (ChosenDest == null) { var messageDialog = new MessageDialog("Choose a destination language!") { Title = "Error" }; messageDialog.Commands.Add(new UICommand("Close")); await messageDialog.ShowAsync(); } else { var messageDialog = new MessageDialog("There is no translation for that word!") { Title = "Warning" }; messageDialog.Commands.Add(new UICommand("Close")); await messageDialog.ShowAsync(); } }
private async void AntonymClick(string obj) { Translations.Clear(); Synonyms.Clear(); Antonyms.Clear(); Sentences.Clear(); var reply = await new OxfordDictionaryMVVMService().GetAntonymAsync(chosenSrc, obj); if (reply != null) { foreach (var result in reply.results) { foreach (var lexicalEntry in result.lexicalEntries) { foreach (var entry in lexicalEntry.entries) { foreach (var sense in entry.senses) { foreach (var anonym in sense.antonyms) { Antonyms.Add(anonym.text); } } } } } } // exception handling else if (ChosenSrc == null) { var messageDialog = new MessageDialog("Choose a source language!") { Title = "Error" }; messageDialog.Commands.Add(new UICommand("Close")); await messageDialog.ShowAsync(); } else if (ChosenSrc.ToString() != "en") { var messageDialog = new MessageDialog("Antonyms are not supported in this language at present.") { Title = "Warning" }; messageDialog.Commands.Add(new UICommand("Close")); await messageDialog.ShowAsync(); } else { var messageDialog = new MessageDialog("There is no antonym for that word!") { Title = "Warning" }; messageDialog.Commands.Add(new UICommand("Close")); await messageDialog.ShowAsync(); } }
private void ClearTranslations() { Translations.Clear(); }
public void Clear() { indexMap.Clear(); Translations.Clear(); RaisePropertyChanged("Translations"); }
public void Clear() { Translations.Clear(); SelectedTranslations.Clear(); }
private void RemoveTranslationFromSubtitles() { Translations translations = new Translations(); translations.Clear(subtitles); }
/// <summary> /// Removes all items from the <see cref="T:System.Collections.Generic.ICollection`1" />. /// </summary> /// <exception cref="T:System.NotSupportedException"> /// The <see cref="T:System.Collections.Generic.ICollection`1" /> is read-only. /// </exception> public void Clear() { Translations.Clear(); }