private async Task TranslateTextAsync() { if (translateTextProcessing) { return; } try { this.processingRing.IsActive = true; translateTextProcessing = true; string inputText = string.Empty; this.inputLanguage = this.inputLanguage ?? DefaultInputLanguage; switch (this.pivotControl.SelectedIndex) { case 0: inputText = this.inputText.Text; break; case 1: inputText = this.ocrTextBlock.Text; break; } var outputLanguage = this.outputLanguageComboBox.SelectedValue as Language; List <string> languageCodeList = outputLanguage != null ? new List <string>() { outputLanguage.Code } : new List <string>(); if (!string.IsNullOrEmpty(inputText) && languageCodeList.Any()) { TranslationTextResult translationTextResult = await this.translatorTextService?.TranslateTextAsync(inputText, languageCodeList); if (translationTextResult != null) { Translation translation = translationTextResult.Translations?.FirstOrDefault(t => t.To.Equals(outputLanguage.Code, StringComparison.OrdinalIgnoreCase)); this.outputText.Text = translation?.Text ?? string.Empty; } this.previousTranslatedText = inputText; // Provides alternative translations for a word and a small number of idiomatic phrases await UpdateAlternativeTranslationsAsync(inputText, this.inputLanguage.Code, outputLanguage.Code); } else { ClearOutputData(); } } catch (Exception ex) { await Util.GenericApiCallExceptionHandler(ex, "Failure translating text"); } finally { translateTextProcessing = false; this.processingRing.IsActive = false; } }
void SetLanguage(string languageDictionary) { CurrentDictionary = JsonUtility.FromJson <LanguageDictionary>(languageDictionary); SubmitButton.GetComponentInChildren <Text>().text = CurrentDictionary.GetKeyValue("submit"); NextButton.GetComponentInChildren <Text>().text = CurrentDictionary.GetKeyValue("next"); PreviousButton.GetComponentInChildren <Text>().text = CurrentDictionary.GetKeyValue("previous"); CancelButton.GetComponentInChildren <Text>().text = CurrentDictionary.GetKeyValue("cancel"); }
public override void LoadTextsLanguage() { LanguageDictionary ld = LanguageService.GetLanguageDictionary(); if (ld.isLoaded) { this.buffName = ld.lifeItem; } }
public void LoadTextsLanguage() { LanguageDictionary ld = LanguageService.GetLanguageDictionary(); if (ld.isLoaded) { this.titleTxt.text = ld.resultPreMsgJackPot; } }
public static LanguageDictionary GetLanguageDictionary() { if (!_ld.isLoaded) { _ld = LoadDictionary(); } return(_ld); }
private void InputLanguageComboBoxSelectionChanged(object sender, SelectionChangedEventArgs e) { this.inputLanguage = this.inputLanguageComboBox.SelectedValue as LanguageDictionary; if (this.inputLanguage == null) { return; } UpdateOutputLanguageCombobox(this.inputLanguage); }
/// <summary> /// Translates a string /// </summary> /// <param name="id">The id of the translation value</param> /// <param name="field">The field of the translation value</param> /// <param name="def">The default value (sets to field if empty)</param> /// <returns>The string associated with the translation value</returns> public static string T(string id, string field = "Text", string def = "") { if (def == "") { def = field; } LanguageDictionary dictionary = LanguageDictionary.GetDictionary(LanguageContext.Instance.Culture); return((string)dictionary.Translate(id, field, def, typeof(string))); }
public void StartWrittenQuiz(LanguageDictionary languageDictionary, Form parentForm) { parentForm.Visible = false; currentDictionary = languageDictionary; WrittenQuizForm form = new WrittenQuizForm(this); form.FormClosing += delegate { parentForm.Visible = true; }; SetMutes(form); form.Show(); }
public void LoadTextsLanguage() { LanguageDictionary ld = LanguageService.GetLanguageDictionary(); if (ld.isLoaded) { subSelectorTitle.text = ld.chooseSubTitle; goText.text = ld.go; } }
public static List <LanguageDictionary> BuildDictionaries(string text) { var lines = ParseText(text); var lineCount = lines.Count; if (lineCount == Int.ZERO) { return(new List <LanguageDictionary>()); } var entityCount = lineCount - Int.ONE; //Build empty dictionaries: var headerRow = lines[Int.ZERO]; var headerChunks = ParseLine(headerRow); var languageCount = headerChunks.Count - Int.ONE; var dictionaries = new List <LanguageDictionary>(); for (var i = Int.ZERO; i < languageCount; i++) { var languageText = headerChunks[i + Int.ONE]; var dictionary = new LanguageDictionary { language = languageText, entities = new List <LanguageEntity>() }; dictionaries.Add(dictionary); } //Fill dictionaries: for (var i = Int.ZERO; i < entityCount; i++) { var line = lines[i + Int.ONE]; var chunks = ParseLine(line); var key = chunks[Int.ZERO]; if (!key.StartsWith("TXT")) { continue; } for (var j = Int.ZERO; j < languageCount; j++) { var dictionary = dictionaries[j]; var entity = new LanguageEntity { key = key, translation = chunks[j + Int.ONE] }; dictionary.entities.Add(entity); } } return(dictionaries); }
public void StartChooseAnswerQuiz(LanguageDictionary languageDictionary, bool timer, Form parentForm) { isTimerNeeded = timer; currentDictionary = languageDictionary; ChooseAnswerQuizForm qcForm = new ChooseAnswerQuizForm(this, timer); qcForm.FormClosing += delegate { parentForm.Visible = true; }; parentForm.Visible = false; qcForm.Show(); }
public ResultScreenViewModel(byte[] imageMemory, string languageOCR = "Auto") { translateLanguageCode = Settings.ReadSettings("General", "TransLang"); TargetLang = LanguageDictionary.GetTranslateLanguageByValue(translateLanguageCode); ORCLang = languageOCR != null ? languageOCR : "auto"; ParseImageAndTranslate(imageMemory); Timer.Elapsed += Timer_Elapsed; }
public void AddTranslation(Language language, string key, string translation) { if (String.IsNullOrEmpty(key) || String.IsNullOrEmpty(translation)) { throw new ArgumentNullException(); } if (!ExistsLanguage(language)) { _dictionary[language] = new LanguageDictionary(language); } _dictionary[language].AddTranslation(key, translation); }
public void AddTranslation(Language language, Dictionary <string, string> input) { if (language == null || input == null) { throw new ArgumentNullException(); } if (!ExistsLanguage(language)) { _dictionary[language] = new LanguageDictionary(language); } _dictionary[language].AddTranslation(input); }
public void Initialize() { m_diTaggedStrings = new TaggedStringDictionary(); m_diTimeTypes = new TimeTypeDictionary(); m_diScoreTypes = new ScoreTypeDictionary(); m_diBetTypes = new BetTypeDictionary(); m_diBetDomainTypes = new BetDomainTypeDictionary(); m_diGroups = new GroupDictionary(); m_diCompetitors = new CompetitorDictionary(); m_diCompetitorsToOutright = new CompetitorToOutrightDictionary(); m_diMatches = new MatchDictionary(); m_diMatchResults = new MatchResultDictionary(); m_diLiveMatchInfos = new LiveMatchInfoDictionary(); m_diMatchesToGroups = new MatchToGroupDictionary(); m_diBetDomains = new BetDomainDictionary(); m_diResources = new ResourceRepositoryDictionary(); m_diResourceAssignments = new ResourceAssignmentDictionary(); m_diCompetitorInfos = new CompetitorInfosDictionary(); m_diMatchesInfos = new MatchInfosDictionary(); m_diTournamentInfos = new TournamentInfosDictionary(); m_diLiabilities = new LiabilitiesDictionary(); m_diOdds = new OddDictionary(); m_diLanguages = new LanguageDictionary(); m_MultistringGroups = new MultistringGroupDictionary(); m_diTournamentMatchLocks = new TournamentMatchLocksDictionary(); m_diActiveTournaments = new ActiveTournamentsDictionary(); AddCollection(m_diTaggedStrings); AddCollection(m_diTimeTypes); AddCollection(m_diScoreTypes); AddCollection(m_diBetTypes); AddCollection(m_diBetDomainTypes); AddCollection(m_diGroups); AddCollection(m_diCompetitors); AddCollection(m_diCompetitorsToOutright); AddCollection(m_diMatches); AddCollection(m_diMatchResults); AddCollection(m_diMatchesToGroups); AddCollection(m_diLiveMatchInfos); AddCollection(m_diBetDomains); AddCollection(m_diResources); AddCollection(m_diResourceAssignments); AddCollection(m_diCompetitorInfos); AddCollection(m_diMatchesInfos); AddCollection(m_diTournamentInfos); AddCollection(m_diLiabilities); AddCollection(m_diOdds); AddCollection(m_diLanguages); AddCollection(m_MultistringGroups); AddCollection(m_diTournamentMatchLocks); AddCollection(m_diActiveTournaments); }
/// <summary> /// Send an email on asking a new password /// </summary> /// <param name="login"></param> /// <returns></returns> public UserRecord SendNewPassword(string login) { // ask for a new password due to forget password try { UserRecord user = _userManager.AskNewPassword(login); // read the multilingual dictionary LanguageDictionary ressources = new LanguageDictionary(Server?.MapPath(LanguageDictionary.DIRECTORY_IMAGE), ConfigurationManager.DefaultLanguage); ressources.Load(_userManager.Database, user.CustomerId); // Send an email to the user within a link towards the new password page MailMessage message = new MailMessage(); message.To.Add(new MailAddress(user.Email)); message.Subject = ressources.GetLabel(user.Language, "USER_NEW_PASSWORD"); string body; // TODO: Replace this code by a render HTML UserViewModel Model = new UserViewModel(ressources, user, false); // message.Body = RenderManager.RenderView("~/Areas/Administration/Views/User/MailNewPassword.cshtml", new UserViewModel(ressources, user, false)); body = $"<center><img src=\"{Model.UrlRoot}Content/Images/Areas/Administration/User/MailNewPassword/Logo.png\" width=\"200px\" height=\"50px\"/></center>" + "<p>" + "Pour réinitialiser le mot de passe, veuillez cliquer sur le lien suivant:" + "<ul>" + $"<li><a href=\"{Model.UrlRoot}Administration/User/NewPassword?key={Model.UserProfile.NewPasswordKey}\">Réinitialisation du mot de passe</a></li>" + $"<li>Identifiant : {Model.UserProfile.Login}</li>"; if (Model.Mode != "PROD") { body += $"<li>Instance : <a href=\"{Model.UrlRoot}\">{Model.UrlRoot}</a></li>"; body += $"<li>Mode : {Model.Mode}</li>"; } body += "</ul></p>"; message.Body = body; message.BodyEncoding = System.Text.Encoding.GetEncoding("iso-8859-1"); message.IsBodyHtml = true; using (var smtp = new SmtpClient()) smtp.Send(message); return(user); } catch (System.Exception ex) { Exception($"An exception occurs on asking for a new password due to {ex.Message}", ex); return(null); } }
public MainWindow() { var a = LanguageDictionary.RegisteredDictionaries; var cultures = a.Keys; foreach (var culture in cultures) { MV.Cultures.Add(LanguageDictionary.GetDictionary(culture)); } InitializeComponent(); InitializeMenus(); this.DataContext = MV; }
public void LoadTextsLanguage() { LanguageDictionary ld = LanguageService.GetLanguageDictionary(); if (ld.isLoaded) { buyBtnText.text = ld.buy; notEnoughMoneyMsg = ld.notEnoughFundsShop; subAlreadyBoughtMsg = ld.subAlreadyBoughtShop; itemMaxReachedMsg = ld.maxItemReachedShop; tryYourLuckBtnTxt.text = ld.tryYourLuckBtn; } }
private void SetResult(ConnectGamer gamer) { LanguageDictionary language = new LanguageDictionary(); GameMechanic game = gamer.Game.Game; List <JsonResult> results = game.Results().Select(x => new JsonResult() { Feature = x.Feature.Value(language.GetLanguage()), Id = x.Gamer.Id }).ToList(); Clients.Clients(GamersId(gamer)).SetResult(results, language.Get("Result")); }
public static void Update(Note note) { if (note == null) { throw new Exception(LanguageDictionary.GetValue("UpdateNoteOperationInputDataError")); } var connection = SingltoneConnection.GetInstance(); var result = connection.Update(note, typeof(Note)); if (result == 0) { throw new Exception(LanguageDictionary.GetValue("UpdateNoteOperationUnknownError")); } }
public void LoadTextsLanguage() { LanguageDictionary ld = LanguageService.GetLanguageDictionary(); if (ld.isLoaded) { newGameBtnText.text = ld.newGameMainMenu; selectSubBtnText.text = ld.selectSubMainMenu; shopBtnText.text = ld.shopMainMenu; rateUsBtnText.text = ld.rateUs; postPoneRateUsBtnText.text = ld.rateUsPostpone; ratingRequestText.text = ld.rateUsRequest; } }
/// <summary> /// Registers the dictionaries while startup of the application. /// </summary> /// <param name="e">The eventarguments.</param> protected override void OnStartup(StartupEventArgs e) { LanguageDictionary.RegisterDictionary( CultureInfo.GetCultureInfo("de-DE"), new XmlLanguageDictionary("Languages/de-DE.xml")); LanguageDictionary.RegisterDictionary( CultureInfo.GetCultureInfo("en-US"), new XmlLanguageDictionary("Languages/en-US.xml")); LanguageContext.Instance.Culture = CultureInfo.GetCultureInfo("de-DE"); base.OnStartup(e); }
private void UpdateOutputLanguageCombobox(LanguageDictionary inputLanguage) { if (inputLanguage != null && previousInputLanguage != inputLanguage) { // update output language combobox List <Language> outputLanguages = inputLanguage?.Translations?.OrderBy(v => v.Name).ToList() ?? new List <Language>(); OutputLanguageCollection.Clear(); OutputLanguageCollection.AddRange(outputLanguages); this.outputLanguageComboBox.SelectedValue = OutputLanguageCollection.FirstOrDefault(v => v.Name.Equals(outputLanguageName, StringComparison.OrdinalIgnoreCase)) ?? OutputLanguageCollection.FirstOrDefault(); } previousInputLanguage = inputLanguage; }
public static void Delete(int id) { if (id < 0) { throw new Exception(LanguageDictionary.GetValue("DeleteNoteOperationInputError")); } var connection = SingltoneConnection.GetInstance(); var rows = connection.Delete <Note>(id); if (rows == 0) { throw new Exception(LanguageDictionary.GetFormatValue("DeleteNoteOperationUnknownError", id)); } }
public void LoadLanguageDictionaries() { List <LanguageDictionary> result = new List <LanguageDictionary>(); var all_dictionary_files = Directory.GetFiles(ResourcesFolder + DictionaryPath); foreach (var f in all_dictionary_files) { //Get the file info for this file FileInfo f_info = new FileInfo(f); //Instantiate a new language dictionary object LanguageDictionary d = new LanguageDictionary(); string filename = Path.GetFileNameWithoutExtension(f_info.Name); List <string> separated_parts = filename.Split(new char[] { '_' }).ToList(); d.ForeignLanguageName = separated_parts[0].ToLower(); if (separated_parts.Count >= 3) { d.NativeLanguageName = separated_parts[2].ToLower(); } else { d.NativeLanguageName = "english"; } if (separated_parts.Count >= 4) { d.MetaData = separated_parts[3].ToLower(); } //Load the dictionary file List <string> file_lines = ConfigurationFileLoader.LoadConfigurationFile(f); for (int i = 0; i < file_lines.Count; i++) { string this_line = file_lines[i]; string[] split_string = this_line.Split(new char[] { '\t' }, 2); string key = split_string[0].Trim(); string value = split_string[1].Trim(); d.DictionaryWordPairs.Add(new Tuple <string, string>(key, value)); } result.Add(d); } //Set the class property with the result LanguageDictionaries = result; }
/// <summary> /// Generates the example json string. Use it to create template for the lockit /// </summary> public static string GenerateExampleText() { var file = new LockitDict(); var eng = new LanguageDictionary(); eng.lang = "en_US"; eng.EntriesDictionary.Add("OV_EXAMPLE", "This is an example entry in dictionary"); file.languages.Add("en_US", eng); var pol = new LanguageDictionary(); pol.lang = "pol_PL"; pol.EntriesDictionary.Add("OV_EXAMPLE", "Przykładowy wpis do lockitu"); file.languages.Add("pol_PL", pol); return(JsonConvert.SerializeObject(file, Formatting.Indented)); }
/// <summary> /// Find a item by name in a specific language. /// </summary> /// <param name="items">A array of items.</param> /// <param name="name">The name of the item.</param> /// <param name="language">The specific language.</param> /// <returns>The item if found, or null.s</returns> public static Item Find(Item[] items, string name, string language = "English") { // TODO: use the Helpers.Find class here. foreach (Item item in items) { LanguageDictionary itemName = DictionariesHelper.ContainsKey(item.name, language); if (itemName.value == name && itemName != null) { return(item); } } Debug.LogError($"This item \"{name}\" doesn't exist."); return(null); }
public static Note Get(int id) { if (id < 0) { throw new Exception(LanguageDictionary.GetValue("GetNoteOperationInputError")); } var connection = SingltoneConnection.GetInstance(); var res = connection.Table <Note>().FirstOrDefault(o => o.Id == 2); if (res == null) { throw new Exception(LanguageDictionary.GetFormatValue("GetNoteOperationUnknownError", id)); } return(res); }
public Object Convert(Object value, Type targetType, Object parameter, CultureInfo culture) { String[] parameters = parameter.ToString().Split('.'); String viewName = parameters[0]; String elementName = parameters[1]; LanguageDictionary languagePack = value as LanguageDictionary; // Use DependencyProperty.UnsetValue to indicate conversion failure // In this case, the FallbackValue property will be used return((languagePack != null && languagePack.ContainsSection(viewName) && languagePack[viewName].ContainsKey(elementName)) ? languagePack[viewName][elementName] : DependencyProperty.UnsetValue); }
public static void Insert(Note newNote) { if (newNote == null) { throw new Exception(LanguageDictionary.GetValue("AddNoteOperationInputDataError")); } var connection = SingltoneConnection.GetInstance(); var result = connection.Insert(newNote); if (result == 0) { throw new Exception(LanguageDictionary.GetValue("AddNoteOperationUnknownError")); } }