예제 #1
0
        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));
        }
예제 #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);
        }
예제 #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));
     }
 }
예제 #4
0
 public ActionResult Delete(long id)
 {
     try
     {
         string msg = "";
         Bam.Net.Translation.LanguageDetection dao = Bam.Net.Translation.LanguageDetection.OneWhere(c => c.KeyColumn == id);
         if (dao != null)
         {
             dao.Delete();
         }
         else
         {
             msg = string.Format("The specified id ({0}) was not found in the table (LanguageDetection)", id);
         }
         return(Json(new { Success = true, Message = msg, Dao = "" }));
     }
     catch (Exception ex)
     {
         return(GetErrorResult(ex));
     }
 }
예제 #5
0
 public ActionResult Create(Bam.Net.Translation.LanguageDetection dao)
 {
     return(Update(dao));
 }