Beispiel #1
0
        public ActionResult Translate(int id, string culture)
        {
            var brand = _brandService.Find(id);
            var compared = new BrandModel
            {
                Id = brand.Id,
                Name = brand.Name,
                Description = brand.Description
            };

            var translated = new BrandModel
            {
                Id = brand.Id
            };

            var diff = new BrandModel
            {
                Id = brand.Id
            };

            var translation = _translationStore.Find(CultureInfo.GetCultureInfo(culture), EntityKey.FromEntity(brand));
            if (translation != null)
            {
                translated.Name = translation.GetTranslatedText("Name");
                translated.Description = translation.GetTranslatedText("Description");

                diff.Name = DiffHelper.GetDiffHtml(translation.GetOriginalText("Name"), brand.Name);
                diff.Description = DiffHelper.GetDiffHtml(translation.GetOriginalText("Description"), brand.Description);
            }

            ViewBag.Difference = diff;
            ViewBag.Compared = compared;

            return View(translated);
        }
Beispiel #2
0
        public ActionResult Translate(BrandModel model, string culture, string @return)
        {
            var brandKey = new EntityKey(typeof(Brand), model.Id);
            var brand = _brandService.Find(model.Id);

            var props = new List<PropertyTranslation>
            {
                new PropertyTranslation("Name", brand.Name, model.Name),
                new PropertyTranslation("Description", brand.Description, model.Description)
            };

            _translationStore.AddOrUpdate(CultureInfo.GetCultureInfo(culture), brandKey, props);

            return AjaxForm().RedirectTo(@return);
        }