Last active
August 24, 2020 09:53
SF_10.1, SF_10.2, SF_11.0, SF_11.1, SF_11.2, SF_12.0, SF_12.1, SF_12.2, SF_13.0 - https://docs.sitefinity.com/for-developers-add-a-translation-to-a-localized-product
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Globalization; | |
using System.Linq; | |
using System.Text.RegularExpressions; | |
using Telerik.Sitefinity.Ecommerce.Catalog.Model; | |
using Telerik.Sitefinity.Model; | |
using Telerik.Sitefinity.Modules.Ecommerce.Catalog; | |
namespace Telerik.Sitefinity.Documentation.CodeSnippets.DevGuide.SitefinityEssentials.Multilingual | |
{ | |
public partial class MultilingualSnippets | |
{ | |
public static void TranslateProduct(Guid productId, string title, string description, string targetCulture) | |
{ | |
CultureInfo culture = CultureInfo.GetCultureInfo(targetCulture); | |
CatalogManager catalogManager = CatalogManager.GetManager(); | |
Product product = catalogManager.GetProduct(productId); | |
if (product != null) | |
{ | |
product.Title.SetString(culture, title); | |
product.GetString("Description").SetString(culture, description); | |
product.UrlName.SetString(culture, Regex.Replace(title.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-")); | |
catalogManager.Provider.RecompileItemUrls(product); | |
catalogManager.SaveChanges(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment