public IActionResult Details(string id = null, string lang = null)
        {
            Guid parsedId;

            if (id == null || lang == null || !Guid.TryParse(id, out parsedId))
            {
                return(RedirectToAction("Index"));
            }

            var sourceDoc = marcellCorpus.GetDocument(lang, parsedId);

            TranslationViewModel result = new TranslationViewModel
            {
                Result       = GetResultFromDocument(sourceDoc, false),
                Translations = new List <ParagraphLanguagePair>()
            };

            foreach (var section in sourceDoc.Sections)
            {
                foreach (var paragraph in section.Paragraphs)
                {
                    result.Translations.Add(new ParagraphLanguagePair
                    {
                        SourceParagraph   = paragraph.Text,
                        SourceParagraphId = paragraph.InternalId,
                        SourceLanguage    = lang,
                    });
                }
            }

            return(View(result));
        }
Esempio n. 2
0
        private void AddNewTranslation(object sender, RoutedEventArgs e)
        {
            var combo = (AvailableLanguages.SelectedItem as ComboBoxItem);

            if (combo != null)
            {
                var langID = (int)combo.Tag;
                var vm     = new TranslationViewModel()
                {
                    Translation    = "Translation",
                    Pronounciation = "Pronounce",
                    Significance   = 1.0,
                };

                if (Translations.ContainsKey(langID))
                {
                    Translations[langID].Add(vm);
                }
                else
                {
                    Translations.Add(langID, new List <TranslationViewModel>()
                    {
                        vm
                    });
                }

                FilteredTranslations.Add(vm);
            }
        }
        public TranslationViewModel GetNewTranslation(int cat, int productId, int?id, Lang lang, Product product, string subCategory)
        {
            var translation = new TranslationViewModel();

            if (id != null)
            {
                translation               = this.GetTranslationById((int)id);
                translation.IsUpdate      = true;
                translation.Text          = product.Details;
                translation.Title         = product.Name;
                translation.Lang          = lang;
                translation.SubCategory   = subCategory;
                translation.SubCategoryId = cat;
                translation.Product       = product;
                return(translation);
            }

            translation.IsUpdate         = false;
            translation.Product          = product;
            translation.Title            = this.sanitizer.Sanitize(product.Name);
            translation.TitleTranslation = this.sanitizer.Sanitize(product.Name);
            translation.Text             = product.Details;
            translation.Lang             = lang;
            translation.SubCategory      = subCategory;
            translation.SubCategoryId    = cat;
            return(translation);
        }
Esempio n. 4
0
        public async Task <TranslationViewModel> TranslatePartial(String tekstZaPreveduvanje)
        {
            //Da se napravi detectLanguage(tekstZaPreveduvanje)
            TranslationViewModel result = await MacedonianCroatianEnglishGermanTranslation.DeEnCroMk(tekstZaPreveduvanje, _googleCloudPlatformProjectName.Value.ProjectName, _logger, _googleTranslateApiCredentials);

            return(result);
        }
        public IActionResult AddEditTranslations(TranslationViewModel translationIn)
        {
            if (this.ModelState.IsValid)
            {
                if (translationIn.Id == null)
                {
                    try
                    {
                        this.products.SaveTranslationAsync(translationIn);
                        return(this.RedirectToAction("Index", "Home", new { active_subCategory = translationIn.SubCategoryId, toastr = "New translation has been created successfully." }));
                    }
                    catch
                    {
                        return(this.RedirectToAction("Index", "Home", new { active_subCategory = translationIn.SubCategoryId, toastr = "ERROR: No translation has been created. Try again." }));
                    }
                }
                else
                {
                    try
                    {
                        this.products.UpdateTranslation(translationIn);
                        return(this.RedirectToAction("Index", "Home", new { active_subCategory = translationIn.SubCategoryId, toastr = "The translation has been updated successfully" }));
                    }
                    catch
                    {
                        return(this.RedirectToAction("Index", "Home", new { active_subCategory = translationIn.SubCategoryId, toastr = "ERROR: Translation hasn't been updated. Try again." }));
                    }
                }
            }

            this.ViewBag.Message = translationIn.Id != null ? "Edit Translation" : "New Translation";
            return(this.View(translationIn));
        }
Esempio n. 6
0
        public LanguageField(string Key, TranslationViewModel TranslationViewModel)
        {
            this.Key = Key;

            _translationViewModel = TranslationViewModel;

            _translationViewModel.PropertyChanged += (S, E) => RaisePropertyChanged(nameof(Value));
        }
Esempio n. 7
0
        public TranslationViewModel AutoTranslate(string key)
        {
            var translation = Translate(key);
            var vm          = new TranslationViewModel(translation);

            _autoTranslations.Add(key, vm);

            return(vm);
        }
Esempio n. 8
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            TranslationViewModel startViewModel        = new TranslationViewModel();
            IWindowContext       startViewModelContext = WindowManager.Instance.CreateWindow(startViewModel);

            startViewModelContext.Closed += (sender, args) => Shutdown();
            startViewModelContext.Show();
        }
Esempio n. 9
0
        public IActionResult IndexPost(TranslationViewModel vm)
        {
            if (!string.IsNullOrEmpty(vm.Source))
            {
                vm.Result = HaagsTranslator.Translator.Translate(vm.Source);
            }

            return(View("Home", vm));
        }
Esempio n. 10
0
        public JsonResult TranslateApi([FromQuery] string text)
        {
            var vm = new TranslationViewModel
            {
                Source = text,
                Result = string.IsNullOrEmpty(text) ? null : HaagsTranslator.Translator.Translate(text)
            };

            return(Json(vm));
        }
        public CreateTranslationPage(int complexStringId, TranslationViewModel translation)
        {
            BindingContext = translation;

            ComplexStringId = complexStringId;
            Translation     = translation;
            User            = UserService.CurrentUser;

            InitializeComponent();
        }
Esempio n. 12
0
        public TranslationViewModel GetTranslationById(int id)
        {
            var translation = this.translationRepository.All().FirstOrDefault(x => x.Id == id);
            var result      = new TranslationViewModel
            {
                Id               = translation.Id,
                Translation      = translation.Text,
                TitleTranslation = translation.Title,
                Active           = translation.Active,
            };

            return(result);
        }
Esempio n. 13
0
        public TvProgramme ConvertTranslation(TranslationViewModel viewModel)
        {
            var programme = new TvProgramme()
            {
                Name            = viewModel.Name + " (" + _userService.GetUser().TvStaff.Channel.Name + ")",
                Duration        = viewModel.Duration,
                AvatarUrl       = "/Image/Television/live.jpg",
                Channel         = null,
                ContentRating   = ContentRating.PG13,
                TypeOfProgramme = TypeOfProgramme.Live
            };

            _programmeRepository.Save(programme);
            return(programme);
        }
Esempio n. 14
0
        public async Task SaveTranslationAsync(TranslationViewModel translationIn)
        {
            ProductLang productTranslation = new ProductLang
            {
                Title     = translationIn.TitleTranslation,
                Text      = translationIn.Translation,
                Active    = translationIn.Active,
                Lang      = translationIn.Lang,
                ProductId = translationIn.ProductId,
            };

            await this.translationRepository.AddAsync(productTranslation);

            this.productRepository.SaveChanges();
        }
Esempio n. 15
0
        public void SaveSchedule(TranslationViewModel viewModel)
        {
            var programme = ConvertTranslation(viewModel);

            programme.Channel = _userService.GetUser().TvStaff.Channel;
            var schedule = new TvSchedule()
            {
                AiringTime    = viewModel.AiringTime,
                Programme     = programme,
                EndAiringTime = viewModel.AiringTime.AddMinutes(programme.Duration)
            };

            CheckingTime(schedule.AiringTime, schedule.EndAiringTime);

            SaveInScheduleRepository(schedule);
        }
        public VisualizerDialog(Func <object> translationFactory)
        {
            _translationFactory = translationFactory;
            ColourTable         = new VisualizerDialogColourTable(this);
            _renderer           = new VisualizerDialogRenderer(this);
            _themeableControls  = new List <Control>();

            base.Text     = "ReadableExpressions v" + VersionNumber.FileVersion;
            StartPosition = FormStartPosition.CenterScreen;
            MinimizeBox   = false;
            AutoSizeMode  = AutoSizeMode.GrowAndShrink;

            var screenRectangle = RectangleToScreen(ClientRectangle);

            _titleBarHeight = screenRectangle.Top - Top;

            using (var graphics = CreateGraphics())
            {
                WidthFactor  = graphics.DpiX / 72;
                HeightFactor = graphics.DpiY / 72;
            }

            ViewModel = new TranslationViewModel();

            ToolTip    = AddToolTip();
            Viewer     = AddViewer();
            _menuStrip = AddMenuStrip();
            _toolbar   = AddToolbar();

            SetViewerSizeLimits();
            SetTranslation();

            Application.Idle += LazyLoadMenus;

            Shown += (sender, args) =>
            {
                var dialog = (VisualizerDialog)sender;
                dialog.Viewer.HandleShown(dialog.ViewModel.Translation);
            };

            Resize += (sender, args) => ((VisualizerDialog)sender).HandleResize();
        }
Esempio n. 17
0
        public bool UpdateTranslation(TranslationViewModel translationIn)
        {
            bool result;

            try
            {
                var translation = this.translationRepository.All().FirstOrDefault(x => x.Id == translationIn.Id);
                translation.Title  = translationIn.TitleTranslation;
                translation.Text   = translationIn.Translation;
                translation.Active = translationIn.Active;
                this.translationRepository.Update(translation);
                this.translationRepository.SaveChanges();
                result = true;
            }
            catch
            {
                result = false;
            }

            return(result);
        }
Esempio n. 18
0
 public IActionResult Add(TranslationViewModel viewModel)
 {
     _translationPresentation.Save(viewModel);
     return(View());
 }
Esempio n. 19
0
        public void Save(TranslationViewModel viewModel)
        {
            var model = _mapper.Map <Translation>(viewModel);

            _translationRepository.Save(model);
        }
Esempio n. 20
0
        public async void UpdateLanguage(string lang)
        {
            var            uri     = new Uri("http://backend.wilkinson-sword.com.pl/data/products");
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);

            request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

            string result = string.Empty;

            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                using (Stream stream = response.GetResponseStream())
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        result = reader.ReadToEnd();

                        dynamic json = JsonConvert.DeserializeObject(result);

                        Lang currentLang = Lang.Slovakian;
                        switch (lang)
                        {
                        case "en": currentLang = Lang.English; break;

                        case "bg": currentLang = Lang.Bulgarian; break;

                        case "rs": currentLang = Lang.Serbian; break;

                        case "ro": currentLang = Lang.Romanian; break;

                        case "pl": currentLang = Lang.Polish; break;

                        case "al": currentLang = Lang.Albanian; break;

                        case "kv": currentLang = Lang.Kosovo; break;

                        case "mk": currentLang = Lang.Macedonian; break;
                        }

                        foreach (var item in json[lang].products)
                        {
                            string curruntProduct = item.ToString();
                            var    record         = JsonConvert.DeserializeObject <ProductFromDatabaseViewModel>(curruntProduct);
                            try
                            {
                                var product     = this.GetAll().FirstOrDefault(x => x.Name == record.name && x.IsDeleted == false).Id;
                                var translation = this.GetAllTranslations().FirstOrDefault(x => x.Title == record.name && x.ProductId == product && x.Lang == currentLang);

                                if (translation == null)
                                {
                                    var transl = new TranslationViewModel
                                    {
                                        ProductId        = product,
                                        Translation      = record.content + "<br>" + record.characteristics[0],
                                        Lang             = currentLang,
                                        TitleTranslation = record.name,
                                    };

                                    await this.SaveTranslationAsync(transl);
                                }
                                else
                                {
                                    var transl = new TranslationViewModel
                                    {
                                        Id               = translation.Id,
                                        Translation      = record.content + "<br>" + record.characteristics[0],
                                        ProductId        = product,
                                        Lang             = currentLang,
                                        TitleTranslation = record.name,
                                    };
                                    translation.Text = record.content + "<br>" + record.characteristics[0];
                                    this.UpdateTranslation(transl);
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
        }
Esempio n. 21
0
        public async Task <IActionResult> WordExamples(WordExamplesViewModel wordExamplesViewModel,
                                                       int?pageNumber)
        {
            if (!ModelState.IsValid)
            {
                return(null);
            }
            int    pageSize    = 5;
            String Word        = wordExamplesViewModel.Word;
            var    SessionWord = HttpContext.Session.GetString(_SessionWord);

            if (!String.IsNullOrEmpty(SessionWord))
            {
                if (SessionWord.Equals(wordExamplesViewModel.Word))
                {
                    //Вчитај примери текст поле за вчитување преводи
                    //Ako requestot e od istiot korisni i veke e prevedeno zborceto
                    var SessionSenses                 = HttpContext.Session.GetObjectFromJson <List <TranslationViewModel> >(_SessionSenses);
                    var SessionTranslatedSenses       = HttpContext.Session.GetObjectFromJson <List <TranslationViewModel> >(_SessionTranslatedSenses);
                    var SessionTranslatedSensesSumary = HttpContext.Session.GetObjectFromJson <List <TranslationViewModel> >(_SessionTranslatedSensesSumary);
                    PaginatedList <TranslationViewModel> sessionPaginatedList = PaginatedList <TranslationViewModel> .Create(
                        SessionTranslatedSensesSumary,
                        pageNumber ?? 1, pageSize);

                    if (SessionSenses != null &&
                        SessionSenses.Count() > 0 &&
                        sessionPaginatedList.Any(m => m.TekstZaPreveduvanje == wordExamplesViewModel.Word && m.Hrvatski == null && m.Angliski == null))
                    {
                        wordExamplesViewModel.TranslaatedTextToReturn = PaginatedList <TranslationViewModel> .Create(
                            SessionSenses,
                            pageNumber ?? 1,
                            pageSize);

                        List <TranslationViewModel> Result = new List <TranslationViewModel>();
                        TranslationViewModel        result = new TranslationViewModel();
                        foreach (var tekst in wordExamplesViewModel.TranslaatedTextToReturn)
                        {
                            if (wordExamplesViewModel.selectLanguageTranslationListViewModel.SelectedPrevod.Equals("MkDe") && tekst.Hrvatski == null && tekst.Angliski == null)
                            {
                                result = await MacedonianCroatianEnglishGermanTranslation.MkCroEnDe(tekst.Makedonski, _googleCloudPlatformProjectName.Value.ProjectName, _logger, _googleTranslateApiCredentials);

                                result.TekstZaPreveduvanje = Word;
                                SessionTranslatedSenses.Add(tekst);
                                Result.Add(result);
                            }
                            else if (wordExamplesViewModel.selectLanguageTranslationListViewModel.SelectedPrevod.Equals("DeMk") && tekst.Hrvatski == null && tekst.Angliski == null)
                            {
                                result = await MacedonianCroatianEnglishGermanTranslation.DeEnCroMk(tekst.Germanski, _googleCloudPlatformProjectName.Value.ProjectName, _logger, _googleTranslateApiCredentials);

                                result.TekstZaPreveduvanje = Word;
                                SessionTranslatedSenses.Add(result);
                                Result.Add(result);
                            }
                        }
                        //wordExamplesViewModel.TranslaatedTextToReturn.Add(result);
                        for (int i = 0; i < Result.Count; i++)
                        {
                            for (int j = 0; j < SessionSenses.Count; j++)
                            {
                                if (SessionSenses[j].Germanski == Result[i].Germanski)
                                {
                                    SessionTranslatedSensesSumary[j].TekstZaPreveduvanje = Result[i].TekstZaPreveduvanje;
                                    SessionTranslatedSensesSumary[j].Makedonski          = Result[i].Makedonski;
                                    SessionTranslatedSensesSumary[j].Hrvatski            = Result[i].Hrvatski;
                                    SessionTranslatedSensesSumary[j].Angliski            = Result[i].Angliski;
                                    SessionTranslatedSensesSumary[j].Germanski           = Result[i].Germanski;

                                    SessionSenses[j].TekstZaPreveduvanje = Result[i].TekstZaPreveduvanje;
                                    SessionSenses[j].Makedonski          = Result[i].Makedonski;
                                    SessionSenses[j].Hrvatski            = Result[i].Hrvatski;
                                    SessionSenses[j].Angliski            = Result[i].Angliski;
                                    SessionSenses[j].Germanski           = Result[i].Germanski;
                                }
                            }
                        }

                        wordExamplesViewModel.TranslaatedTextToReturn = PaginatedList <TranslationViewModel> .Create(
                            SessionTranslatedSensesSumary,
                            pageNumber ?? 1,
                            pageSize);

                        HttpContext.Session.SetObjectAsJson(_SessionTranslatedSenses, SessionTranslatedSenses);
                        HttpContext.Session.SetObjectAsJson(_SessionTranslatedSensesSumary, SessionTranslatedSensesSumary);

                        return(PartialView("_sensesPartialView", wordExamplesViewModel));
                    }
                    else
                    {
                        wordExamplesViewModel.TranslaatedTextToReturn = PaginatedList <TranslationViewModel> .Create(
                            SessionTranslatedSensesSumary,
                            pageNumber ?? 1,
                            pageSize);

                        return(PartialView("_sensesPartialView", wordExamplesViewModel));
                    }
                }
            }

            if (String.IsNullOrEmpty(wordExamplesViewModel.Word))
            {
                return(null);
            }
            String UserWordToTranslate = wordExamplesViewModel.Word;

            if (wordExamplesViewModel.selectLanguageTranslationListViewModel.SelectedPrevod.Equals("MkDe"))
            {
                TranslationViewModel result = await MacedonianCroatianEnglishGermanTranslation.MkCroEnDe(wordExamplesViewModel.Word, _googleCloudPlatformProjectName.Value.ProjectName, _logger, _googleTranslateApiCredentials);

                wordExamplesViewModel.Word = result.Germanski;
            }

            wordExamplesViewModel.Word = await lemmas(wordExamplesViewModel.Word.ToLower());


            HttpClient httpClient = new HttpClient();

            httpClient.BaseAddress = new Uri("https://od-api.oxforddictionaries.com/api/v2/translations/de/en/" + HttpUtility.UrlEncode(wordExamplesViewModel.Word));

            Dictionary <string, string> queryString = new Dictionary <string, string>();

            queryString = new Dictionary <string, string>()
            {
                { "strictMatch", "true" },
                { "fields", "examples" }
            };

            var requestQueryString = QueryHelpers.AddQueryString("", queryString);
            var request            = new HttpRequestMessage(HttpMethod.Get, requestQueryString);

            request.Headers.Add("Accept", "application/json");
            request.Headers.Add("app_id", _oxfordDictionariesApi.Value.app_id);
            request.Headers.Add("app_key", _oxfordDictionariesApi.Value.app_key);

            var httpResponse = await httpClient.SendAsync(request);

            WordExamplesViewModel wordExamplesViewModelToReturn = wordExamplesViewModel;

            wordExamplesViewModelToReturn.Senses = new List <TranslationViewModel>();

            JObject data = new JObject();

            if (httpResponse.StatusCode == HttpStatusCode.OK)
            {
                data = await getRequestJson(httpResponse);
            }
            else if (httpResponse.StatusCode == HttpStatusCode.NotFound)
            {
                return(null);
            }

            //return new JsonResult(data["results"].Children()["lexicalEntries"].Children()["entries"].Children());

            foreach (var results in data["results"])
            {
                foreach (var lexicalEntries in results.Value <JToken>("lexicalEntries"))
                {
                    foreach (var entries in lexicalEntries.Value <JToken>("entries"))
                    {
                        foreach (var senses in entries.Value <JToken>("senses"))
                        {
                            foreach (var text in senses.Value <JToken>("examples"))
                            {
                                TranslationViewModel translationViewModel = new TranslationViewModel();
                                translationViewModel.Germanski           = text.Value <String>("text");
                                translationViewModel.TekstZaPreveduvanje = Word;
                                wordExamplesViewModelToReturn.Senses.Add(translationViewModel);
                            }
                        }
                    }
                }
            }
            PaginatedList <TranslationViewModel> tempPaginatedList = PaginatedList <TranslationViewModel> .Create(
                wordExamplesViewModelToReturn.Senses,
                pageNumber ?? 1, pageSize);

            List <TranslationViewModel> tempTranslationViewModel = new List <TranslationViewModel>();

            //prv pat zbor
            foreach (var tekst in tempPaginatedList)
            {
                TranslationViewModel result = await MacedonianCroatianEnglishGermanTranslation.DeEnCroMk(tekst.Germanski, _googleCloudPlatformProjectName.Value.ProjectName, _logger, _googleTranslateApiCredentials);

                result.TekstZaPreveduvanje = Word;
                tempTranslationViewModel.Add(result);
            }

            for (int i = 0; i < tempPaginatedList.Count; i++)
            {
                for (int j = 0; j < tempTranslationViewModel.Count; j++)
                {
                    if (tempPaginatedList[i].Germanski == tempTranslationViewModel[j].Germanski)
                    {
                        tempPaginatedList[j].Makedonski = tempTranslationViewModel[i].Makedonski;
                        tempPaginatedList[j].Hrvatski   = tempTranslationViewModel[i].Hrvatski;
                        tempPaginatedList[j].Angliski   = tempTranslationViewModel[i].Angliski;
                        tempPaginatedList[j].Germanski  = tempTranslationViewModel[i].Germanski;
                    }
                }
            }

            wordExamplesViewModelToReturn.TranslaatedTextToReturn = tempPaginatedList;

            List <TranslationViewModel> SessinTranslatedSensesSumary = wordExamplesViewModelToReturn.Senses;

            for (int i = 0; i < SessinTranslatedSensesSumary.Count; i++)
            {
                for (int j = 0; j < wordExamplesViewModelToReturn.TranslaatedTextToReturn.Count; j++)
                {
                    if (wordExamplesViewModelToReturn.TranslaatedTextToReturn[j].Germanski == SessinTranslatedSensesSumary[i].Germanski &&
                        wordExamplesViewModelToReturn.TranslaatedTextToReturn[j].Hrvatski != null && wordExamplesViewModelToReturn.TranslaatedTextToReturn[j].Angliski != null)
                    {
                        SessinTranslatedSensesSumary[i].Makedonski = wordExamplesViewModelToReturn.TranslaatedTextToReturn[j].Makedonski;
                        SessinTranslatedSensesSumary[i].Hrvatski   = wordExamplesViewModelToReturn.TranslaatedTextToReturn[j].Hrvatski;
                        SessinTranslatedSensesSumary[i].Angliski   = wordExamplesViewModelToReturn.TranslaatedTextToReturn[j].Angliski;
                        SessinTranslatedSensesSumary[i].Germanski  = wordExamplesViewModelToReturn.TranslaatedTextToReturn[j].Germanski;
                    }
                }
            }

            HttpContext.Session.SetObjectAsJson(_SessionSenses, wordExamplesViewModelToReturn.Senses);
            HttpContext.Session.SetObjectAsJson(_SessionTranslatedSenses, wordExamplesViewModelToReturn.TranslaatedTextToReturn);
            HttpContext.Session.SetObjectAsJson(_SessionTranslatedSensesSumary, SessinTranslatedSensesSumary);
            HttpContext.Session.SetString(_SessionWord, UserWordToTranslate);


            //return wordExamplesViewModelToReturn;
            return(PartialView("_sensesPartialView", wordExamplesViewModelToReturn));
        }
Esempio n. 22
0
        public async Task <TranslationViewModel> WordExamplesTextTranslate(String text)
        {
            TranslationViewModel translatedText = await MacedonianCroatianEnglishGermanTranslation.DeEnCroMk(text, _googleCloudPlatformProjectName.Value.ProjectName, _logger, _googleTranslateApiCredentials);

            return(translatedText);
        }
Esempio n. 23
0
        public async Task <IActionResult> Index(IndexViewViewModel indexViewViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(new IndexViewViewModel(new TranslationViewModel(), new SelectLanguageTranslationListViewModel())));
            }
            //_logger.LogInformation("_googleReCaptcha.Value.SecretKey");
            //_logger.LogInformation(_googleReCaptcha.Value.SecretKey);
            //_logger.LogInformation("_googleReCaptchaV3.Value.v3_secret");_
            //_logger.LogInformation(_googleReCaptchaV3.Value.v3_secret);

            /*
             *
             * var data = await verifyReCaptcha("v2", indexViewViewModel.GoogleReCaptchaResponse);
             * //_logger.LogInformation("data.IsHttpResponseOk" + data.IsHttpResponseOk.ToString());
             * //_logger.LogInformation("indexViewViewModel.GoogleReCaptchaResponse" + indexViewViewModel.GoogleReCaptchaResponse);
             * //_logger.LogInformation("data.reCaptchaVerifyResponse[\"success\"].ToString().ToLower()" + data.reCaptchaVerifyResponse["success"].ToString().ToLower());
             * //_logger.LogInformation("data.reCaptchaVerifyResponse[\"hostname\"].ToString()" + data.reCaptchaVerifyResponse["hostname"].ToString());
             *
             * if (data.IsHttpResponseOk && data.reCaptchaVerifyResponse["success"].ToString().ToLower().Equals("true") && (data.reCaptchaVerifyResponse["hostname"].ToString().Equals("clean-yew-270306.appspot.com")))
             * //|| data.reCaptchaVerifyResponse["hostname"].ToString().Equals("localhost")))
             * {*/
            //_logger.LogInformation("Verified ReCaptcha");
            // Write the log entry.
            //_logger.LogInformation("Post Index Method");
            // Add a handler to trace outgoing requests and to propagate the trace header.
            //indexViewViewModel.translationViewModel.TekstZaPreveduvanje = HttpUtility.HtmlEncode(indexViewViewModel.translationViewModel.TekstZaPreveduvanje);

            if (indexViewViewModel.selectLanguageTranslationListViewModel.SelectedPrevod.Equals("MkDe") && !String.IsNullOrEmpty(indexViewViewModel.translationViewModel.TekstZaPreveduvanje))
            {
                //_logger.LogInformation("if MkDe");
                //_logger.LogInformation("if MkDe : indexViewViewModel.translationViewModel.TekstZaPreveduvanje = " + indexViewViewModel.translationViewModel.TekstZaPreveduvanje);

                indexViewViewModel.translationViewModel.Makedonski = indexViewViewModel.translationViewModel.TekstZaPreveduvanje;

                TranslationViewModel result = await MacedonianCroatianEnglishGermanTranslation.MkCroEnDe(indexViewViewModel.translationViewModel.Makedonski, _googleCloudPlatformProjectName.Value.ProjectName, _logger, _googleTranslateApiCredentials);

                indexViewViewModel.translationViewModel = result;

                //indexViewViewModel.translationViewModel.Makedonski = HttpUtility.HtmlDecode(indexViewViewModel.translationViewModel.Makedonski);

                return(View("Index", indexViewViewModel));
            }
            else if (indexViewViewModel.selectLanguageTranslationListViewModel.SelectedPrevod.Equals("DeMk") && !String.IsNullOrEmpty(indexViewViewModel.translationViewModel.TekstZaPreveduvanje))
            {
                //_logger.LogInformation("else if DeMk");
                //_logger.LogInformation("else if DeMk : indexViewViewModel.translationViewModel.TekstZaPreveduvanje = " + indexViewViewModel.translationViewModel.TekstZaPreveduvanje);

                indexViewViewModel.translationViewModel.Germanski = indexViewViewModel.translationViewModel.TekstZaPreveduvanje;
                TranslationViewModel result = await MacedonianCroatianEnglishGermanTranslation.DeEnCroMk(indexViewViewModel.translationViewModel.Germanski, _googleCloudPlatformProjectName.Value.ProjectName, _logger, _googleTranslateApiCredentials);

                indexViewViewModel.translationViewModel = result;

                //indexViewViewModel.translationViewModel.Germanski = HttpUtility.HtmlDecode(indexViewViewModel.translationViewModel.Germanski);

                return(View("Index", indexViewViewModel));
            }

            /*}
             * else
             * {
             *  ViewData["error"] = "Invalid ReCaptcha";
             * }*/
            return(View(new IndexViewViewModel(new TranslationViewModel(), new SelectLanguageTranslationListViewModel())));
        }
Esempio n. 24
0
 public ActionResult Translation_Update([DataSourceRequest] DataSourceRequest request, TranslationViewModel translation)
 {
     if (translation != null && ModelState.IsValid)
     {
         var detail = _localizedTextService.FindById(translation.LocalizedTextId);
         if (detail != null)
         {
             detail.LocalizedTextId = translation.LocalizedTextId;
             detail.LanguageCode    = translation.LanguageCode;
             detail.TextKey         = translation.TextKey;
             // detail.value = translation.TranslatedText;
             _localizedTextService.UpdateLocalizedText(detail);
         }
     }
     return(Json(new[] { translation }.ToDataSourceResult(request, ModelState)));
     //return Json(ModelState.ToDataSourceResult());
 }
 public TranslationsPage(Translations translations)
 {
     BindingContext = new TranslationViewModel(translations);
     InitializeComponent();
 }