I one of our projects I had to list pages and show their properties like page name, author, publish date and version status. VersionStatus property is enum type. It would be better to display “Scheduled for Publish” instead of DelayedPublish text.
Server side
To convert VersionStatus enum to localizable text we could use LocalizationService class and get value for “/episerver/cms/versionstatus/[version status velue]” translation key. For example for CurrentPage:
1 2 |
var pageStatus = EPiServer.Framework.Localization.LocalizationService.Current.GetString("/episerver/cms/versionstatus/" + this.CurrentPage.Status.ToString().ToLower()); |
To test the solution I get all values from VersionStatus enum and display translation for english, norwegian and swedish.
1 2 3 4 5 |
var localizationService = EPiServer.Framework.Localization.LocalizationService.Current; foreach (var status in Enum.GetValues(typeof(VersionStatus))) { var statusText = localizationService.GetStringByCulture("/episerver/cms/versionstatus/" + status.ToString().ToLower(), cultureInfo); } |
All values were translated:
Status | Culture | ||
EN | NO | SV | |
VersionStatus.NotCreated | – | – | – |
VersionStatus.Rejected | Rejected | Avvist | Avvisad |
VersionStatus.CheckedOut | Draft | Kladd | Utkast |
VersionStatus.CheckedIn | Ready to Publish | Klar for publisering | Klar att publicera |
VersionStatus.Published | Published | Publisert | Publicerad |
VersionStatus.PreviouslyPublished | Previously Published | Tidligere publisert | Tidigare publicerad |
VersionStatus.DelayedPublish | Scheduled for Publish | Tidsstyrt publisering | Schemalagd för publicering |
Client side
I want to translate VersionStatus in dojo component we could use “epi-cms/contentediting/ContentActionSupport” dependency. It has getVersionStatus method which takes one integer number parameter. The number is VersionStatus value casted as integer.
1 |
var statusText = ContentActionSupport.getVersionStatus(value); |