EPiServer – get page property value in a specific language

I’m sending emails from EPiServer, and the email content is based on a language selection coming from the backend. As often the case in EPiServer implementations, I have a separate page for Email Settings and translations. I read the subjects, mail texts and other properties from the [CultureSpecific] properties.

How to do this programmatically? I found lengthy answers on the internet, but I want a short, quick answer. Here is how to get e.g. the Swedish translations:

var cultureInfo = CultureInfo.GetCultureInfo(“sv”);

var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>();

var emailSettingsPage = contentLoader.Get<EmailSettingsPage>(EmailPageReference.PageLink, cultureInfo);

var subject = emailSettingsPage.Subject ?? string.Empty;

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s