#18032: Removing Translation + if only 1 culture.

Work Item: 18032
This commit is contained in:
Nicholas Mayne
2014-08-20 17:02:38 +01:00
parent a60c9d4cbd
commit aa8269bb69

View File

@@ -22,6 +22,9 @@ namespace Orchard.Localization.Drivers {
}
protected override DriverResult Display(LocalizationPart part, string displayType, dynamic shapeHelper) {
if (!IsActivatable())
return null;
var masterId = part.MasterContentItem != null
? part.MasterContentItem.Id
: part.Id;
@@ -36,6 +39,9 @@ namespace Orchard.Localization.Drivers {
}
protected override DriverResult Editor(LocalizationPart part, dynamic shapeHelper) {
if (!IsActivatable())
return null;
var localizations = GetEditorLocalizations(part).ToList();
var model = new EditLocalizationViewModel {
SelectedCulture = part.Culture != null ? part.Culture.Culture : null,
@@ -50,6 +56,9 @@ namespace Orchard.Localization.Drivers {
}
protected override DriverResult Editor(LocalizationPart part, IUpdateModel updater, dynamic shapeHelper) {
if (!IsActivatable())
return null;
var model = new EditLocalizationViewModel();
if (updater != null && updater.TryUpdateModel(model, TemplatePrefix, null, null)) {
_localizationService.SetContentCulture(part, model.SelectedCulture);
@@ -58,6 +67,10 @@ namespace Orchard.Localization.Drivers {
return Editor(part, shapeHelper);
}
private bool IsActivatable() {
return _cultureManager.ListCultures().Count() > 1;
}
private IEnumerable<LocalizationPart> GetDisplayLocalizations(LocalizationPart part, VersionOptions versionOptions) {
return _localizationService.GetLocalizations(part.ContentItem, versionOptions)
.Select(c => {