Beispiel #1
0
 public bool DeleteLocalizedText(LocalizedText item)
 {
     if (item == null) return false;
     _unitOfWork.LocalizedTextRepository.Delete(item);
     _unitOfWork.Save();
     return true;
 }
 public ActionResult Edit(LocalizedText localizedText)
 {
     if (ModelState.IsValid)
     {
         _localizedTextService.UpdateLocalizedText(localizedText);
         return RedirectToAction("Index");
     }
     return View(localizedText);
 }
 public ActionResult EditTranslation(LocalizedText localizedText)
 {
     //localizedText.Value = amharicText;
     if (ModelState.IsValid)
     {
         _localizedTextService.UpdateLocalizedText(localizedText);
         return RedirectToAction("Index");
     }
     return View(localizedText);
 }
Beispiel #4
0
 public bool AddLanguage(Language language)
 {
     _unitOfWork.LanguageRepository.Add(language);
     var texts = _unitOfWork.LocalizedTextRepository.FindBy(m=>m.LanguageCode=="EN");
     foreach (var localizedText in texts)
     {
         var newText = new LocalizedText()
             {
                 LanguageCode = language.LanguageCode,
                 TextKey = localizedText.TextKey
             };
         _unitOfWork.LocalizedTextRepository.Add(newText);
     }
     _unitOfWork.Save();
     return true;
 }
 public ActionResult Create()
 {
     var localizedText = new LocalizedText();
     ViewBag.LanguageCode = new SelectList(_localizedTextService.GetAllLocalizedText(), "LanguageCode", "LanguageCode").Distinct().ToList();
     return View(localizedText);
 }
Beispiel #6
0
        public string Translate(string key, string languageCode)
        {
            try
            {
                List<LocalizedText> list = FindBy(f => f.TextKey == key && f.LanguageCode == languageCode).ToList();
                if (list.Count >= 1)
                {
                    return list[0].TranslatedText;
                }
            }
            catch (Exception exception)
            {
                return key;
            }

            // The requested key do not exist for the language 'languageCode' so add it to translated text tables
            var newtxt = new LocalizedText { LanguageCode = languageCode, TextKey = key, TranslatedText = key };
               // AddLocalizedText(newtxt);
            return key;
        }
Beispiel #7
0
 public bool AddLocalizedText(LocalizedText item)
 {
     _unitOfWork.LocalizedTextRepository.Add(item);
     _unitOfWork.Save();
     return true;
 }