public static void InsertNewTerm(string term) { // I'm missing something here but could not figure it out right now! var item = new Translation { Phrase = term, TranslatedText = "", LanguageID = DEFAULT_LANGUAGE_ID }; db.Insert(TRANSLATION_TABLE, TRANSLATION_ID, true, item); }
//using the class liberary public static string TranslatePhrase(this HtmlHelper helper, string phrase) { phrase = phrase.Trim(); if (helper.ViewContext.HttpContext.User.Identity.IsAuthenticated) { string userName = helper.ViewContext.HttpContext.User.Identity.Name; userName = "******"; //for test ourpus TranslationService ts = new TranslationService(); var language = db.SingleOrDefault <UserProfile>("select * from UserProfile where UserName=@0", userName).LanguageCode; string str = ts.GetPhrase(language, phrase); if (str != null) { return(str); } else { // try to see if we can find this phrase in english //Transaction t = new Transaction(); Edge.Translation.Translation T = new Edge.Translation.Translation(); T.Phrase = phrase; T.LanguageID = language; T.TranslatedText = phrase; //translation.TranslatedText = text.Trim(); db.Insert(T); //untill implemented return(ts.GetPhrase(language, phrase)); } } else { return(phrase); } }
//using the class liberary public static string TranslatePhrase(this HtmlHelper helper, string phrase) { phrase = phrase.Trim(); if (helper.ViewContext.HttpContext.User.Identity.IsAuthenticated) { string userName = helper.ViewContext.HttpContext.User.Identity.Name; userName = "******"; //for test ourpus TranslationService ts = new TranslationService(); var language = db.SingleOrDefault<UserProfile>("select * from UserProfile where UserName=@0", userName).LanguageCode; string str = ts.GetPhrase(language, phrase); if (str != null) { return str; } else { // try to see if we can find this phrase in english //Transaction t = new Transaction(); Edge.Translation.Translation T = new Edge.Translation.Translation(); T.Phrase = phrase; T.LanguageID=language; T.TranslatedText = phrase; //translation.TranslatedText = text.Trim(); db.Insert(T); //untill implemented return ts.GetPhrase(language, phrase); } } else return phrase; }