Ejemplo n.º 1
0
        public ActionResult Index(TranslateViewModel tvm)
        {
            tvm.MatchSettings.ShowSentences = false; // required for matching
            _settingsServiceFacade.UpdateSettings(tvm.MatchSettings, tvm.SampleSettings);
            tvm.LastSearch = tvm.Match.TextIn;

            var getmatch = _translateServiceFacade.GetMatchFor(tvm.Match);

            if (getmatch.MatchesSuccessfullyFound)
            {
                var screen = _translateServiceFacade.GetCurrentScreen();
                var clause = screen.ScreenModel as FullClauseScreenModel;

                // let's add to the existing list
                var tp = new TranslatePair
                {
                    Source = tvm.LastSearch,
                    Target = clause.Translation
                };

                tvm.Translations.Add(tp);
            }

            return(View(tvm));
        }
Ejemplo n.º 2
0
        public ActionResult Index()
        {
            var model = new TranslateViewModel()
            {
                TextRu = "test", TextPl = "test"
            };

            return(View("Index", model));
        }
Ejemplo n.º 3
0
        public IActionResult Index()
        {
            var vm = new TranslateViewModel
            {
                SourceLanguage = _appSettings.Value.DefaultLanguageInput
            };

            return(View(vm));
        }
        public IActionResult Index()
        {
            Service _service = Service.Instance(Options);

            TranslateViewModel lang = new TranslateViewModel {
                ListaIdiomas = _service.GetLanguages()
            };

            return(View(lang));
        }
Ejemplo n.º 5
0
        public MainWindow()
        {
            InitializeComponent();
            TranslateViewModel Vmodel = new TranslateViewModel();

            this.tranVmodel           = Vmodel;
            this.DataContext          = this.tranVmodel;
            txtOutput.IsEnabled       = false;
            lblInstruction.Visibility = Visibility.Hidden;
        }
Ejemplo n.º 6
0
        private ActionResult GetSpecificView(string passthrough)
        {
            ViewBag.Passthrough = passthrough;
            var settings = _settingsServiceFacade.GetSettings();
            var samples  = _settingsServiceFacade.GetSampleSettings();
            var tvm      = new TranslateViewModel {
                MatchSettings = settings, SampleSettings = samples
            };

            return(View("Index", tvm));
        }
Ejemplo n.º 7
0
        public ActionResult Index(string text)
        {
            var tvm = new TranslateViewModel
            {
                LastSearch     = text,
                Match          = _translateServiceFacade.GetText(text).Match,
                MatchSettings  = _settingsServiceFacade.GetSettings(),
                SampleSettings = _settingsServiceFacade.GetSampleSettings()
            };

            return(View(tvm));
        }
Ejemplo n.º 8
0
        private ActionResult CheckError(TranslateViewModel settings)
        {
            if (!TryUpdateModel(settings))
            {
                {
                    return(View(settings));
                }
            }

            _settingsServiceFacade.UpdateSettings(settings.MatchSettings, settings.SampleSettings);

            return(null);
        }
        public async Task <ActionResult> GetLanguages(TranslateViewModel model)
        {
            if (string.IsNullOrEmpty(model.Key))
            {
                throw new Exception("Empty API Key");
            }
            YandexTranslateSdk wrapper = new YandexTranslateSdk();

            wrapper.ApiKey  = model.Key;
            model.Languages = await wrapper.GetLanguages();

            TempData["Languages"] = model.Languages;
            return(View("Index", model));
        }
Ejemplo n.º 10
0
        public ActionResult English()
        {
            var model = new TranslateViewModel();

            var everything = _db.LanguageSet.ToList();

            foreach (var item in everything)
            {
                model.English.Add(new TranslateText()
                {
                    ID = item.Id, TextValue = item.English
                });
            }

            return(View(model));
        }
Ejemplo n.º 11
0
        public IActionResult Search(TranslateViewModel model)
        {
            Models.Translator dict        = new Models.Translator("dict.txt");
            string            translation = dict.Transalte(model.WordToTranslate.ToLower());
            var translaedWord             = new TranslateViewModel()
            {
                WordToTranslate = model.WordToTranslate, TranslatedWord = translation
            };

            if (String.IsNullOrEmpty(translation))
            {
                return(new NotFoundObjectResult(new { error = "Word not found", model.WordToTranslate })
                {
                    StatusCode = 404
                });
            }

            //return Content(translation);
            return(View("Translate", translaedWord));
        }
Ejemplo n.º 12
0
        // GET:
        public IActionResult Translate(string id)
        {
            Models.Translator dict        = new Models.Translator("dict.txt");
            string            translation = dict.Transalte(id);
            var translaedWord             = new TranslateViewModel()
            {
                WordToTranslate = id, TranslatedWord = translation
            };

            if (String.IsNullOrEmpty(translation))
            {
                return(new NotFoundObjectResult(new { error = "Word not found", id })
                {
                    StatusCode = 404
                });
            }

            //return Content(translation);
            return(View(translaedWord));
        }
        public async Task <IActionResult> Translate(TranslateViewModel model)
        {
            if (ModelState.IsValid)
            {
                YandexTranslateSdk wrapper = new YandexTranslateSdk();
                wrapper.ApiKey = model.Key;
                string inputLanguage = await wrapper.DetectLanguage(model.InputText);

                string outputLanguage = model.OutputLanguage;
                string direction      = inputLanguage + "-" + outputLanguage;
                model.OutputText = await wrapper.TranslateText(model.InputText, direction);

                model.Languages = new List <string>(TempData["Languages"] as string[]);

                ModelState.Clear();

                return(View("Index", model));
            }
            return(View("Index", model));
        }
 public TranslatePage()
 {
     InitializeComponent();
     translateViewModel = new TranslateViewModel(this);
     BindingContext     = translateViewModel;
 }
        public IActionResult Index()
        {
            TranslateViewModel model = new TranslateViewModel();

            return(View(model));
        }
Ejemplo n.º 16
0
        public ActionResult Translate(TranslateViewModel settings)
        {
            var errorResult = CheckError(settings);

            return(errorResult ?? RedirectToAction("Index", "Translate"));
        }