Esempio n. 1
0
        /// <summary>
        /// Este método traduce al lenguaje de destino, todas las palabras del lenguaje origen
        /// </summary>
        /// <param name="idiomaOrigen"></param>
        /// <param name="idiomaDestino"></param>
        public int TraducirIdiomaCompleto(IdiomaBE idiomaOrigen, IdiomaBE idiomaDestino)
        {
            int retVal = 0;

            try
            {
                IdiomaMapper   m            = new IdiomaMapper();
                List <TextoBE> textosOrigen = ListarTextosDelIdioma(idiomaOrigen);
                HttpClient     client       = new HttpClient();
                //Por las dudas borro antes lo del destino, por si reutilizo esta función en otro momento
                m.EliminarTextosDeIdioma(idiomaDestino);
                foreach (TextoBE text in textosOrigen)
                {
                    string requestStr = String.Format("?q={0}&langpair={1}|{2}", text.Texto, idiomaOrigen.CodIdioma, idiomaDestino.CodIdioma);

                    TranslationResponse.Rootobject tResponse = new TranslationResponse.Rootobject();
                    string jsonResp = client.GetStringAsync("https://api.mymemory.translated.net/get" + requestStr).Result;
                    tResponse = JsonConvert.DeserializeObject <TranslationResponse.Rootobject>(jsonResp);

                    if (tResponse != null)
                    {
                        //if matches.count??
                        TextoBE textoTraducido = new TextoBE();
                        textoTraducido.IdFrase = text.IdFrase;
                        textoTraducido.Texto   = tResponse.responseData.translatedText;
                        retVal += m.InsertarTexto(idiomaDestino, textoTraducido);
                    }
                }
            }
            catch (Exception ex)
            {
                //TODO: crear nueva excepción específica
                throw ex;
            }
            return(retVal);
        }
Esempio n. 2
0
        public List <TextoBE> ListarTextosDelIdioma(IdiomaBE idioma)
        {
            IdiomaMapper m = new IdiomaMapper();

            return(m.ListarTextosDelIdioma(idioma));
        }
Esempio n. 3
0
        public int Insertar(IdiomaBE idioma)
        {
            IdiomaMapper m = new IdiomaMapper();

            return(m.Insertar(idioma));
        }
Esempio n. 4
0
        public List <IdiomaBE> ListarIdiomas()
        {
            IdiomaMapper m = new IdiomaMapper();

            return(m.Listar());
        }
Esempio n. 5
0
 public IdiomaCrudFactory() : base()
 {
     mapper = new IdiomaMapper();
     dao    = SqlDao.GetInstance();
 }