public string Translate(string input, Language toLanguage)
        {
            Text     text         = Text.OneWhere(t => t.Value == input, TranslationDatabase);
            Language fromLanguage = null;

            if (text != null && text.LanguageOfLanguageId != null)
            {
                fromLanguage = text.LanguageOfLanguageId;
            }
            else
            {
                fromLanguage = DetectLanguage(input);
                LanguageDetection detection = new LanguageDetection();
                detection.LanguageId = fromLanguage.Id;

                text            = new Text();
                text.Value      = input;
                text.LanguageId = fromLanguage.Id;
                text.Save(TranslationDatabase);
                detection.TextId   = text.Id;
                detection.Detector = this.GetType().FullName;
                detection.Save(TranslationDatabase);
            }

            return(Translate(fromLanguage, toLanguage, input));
        }
Beispiel #2
0
        private static LanguageDetection CreateFromFilter(IQueryFilter filter, Database database = null)
        {
            Database db  = database ?? Db.For <LanguageDetection>();
            var      dao = new LanguageDetection();

            filter.Parameters.Each(p =>
            {
                dao.Property(p.ColumnName, p.Value);
            });
            dao.Save(db);
            return(dao);
        }
Beispiel #3
0
 public ActionResult Update(Bam.Net.Translation.LanguageDetection dao)
 {
     try
     {
         dao.Save();
         return(Json(new { Success = true, Message = "", Dao = dao.ToJsonSafe() }));
     }
     catch (Exception ex)
     {
         return(GetErrorResult(ex));
     }
 }