mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
#17063: Making Widgets localizable
Work Item: 17063 --HG-- branch : 1.x
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.ContentManagement.Utilities;
|
||||
using Orchard.Localization.Records;
|
||||
|
||||
namespace Orchard.Localization.Models {
|
||||
public sealed class LocalizationPart : ContentPart<LocalizationPartRecord> {
|
||||
public sealed class LocalizationPart : ContentPart<LocalizationPartRecord>, ILocalizablePart {
|
||||
private readonly LazyField<CultureRecord> _culture = new LazyField<CultureRecord>();
|
||||
private readonly LazyField<IContent> _masterContentItem = new LazyField<IContent>();
|
||||
|
||||
@@ -25,5 +26,9 @@ namespace Orchard.Localization.Models {
|
||||
return Record.MasterContentItemId != 0;
|
||||
}
|
||||
}
|
||||
|
||||
string ILocalizablePart.Culture {
|
||||
get { return Culture == null ? null : Culture.Culture; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
@model Orchard.Localization.ViewModels.EditLocalizationViewModel
|
||||
@if (Model.ContentItem.ContentItem.Id > 0 && Model.SelectedCulture != null && Model.ContentLocalizations.Localizations.Count() > 0) {
|
||||
Style.Require("LocalizationAdmin");
|
||||
<fieldset class="localization culture-selection">
|
||||
@if (Model.ContentItem.ContentItem.Id > 0 && Model.SelectedCulture != null && Model.ContentLocalizations.Localizations.Count() > 0) {
|
||||
Style.Require("LocalizationAdmin");
|
||||
<fieldset class="culture-selected">
|
||||
<label for="SelectedCulture">@T("Content Localization")</label>
|
||||
<div>@T("This is the <em>{0}</em> variation of {1}.",
|
||||
@@ -9,7 +9,7 @@ Style.Require("LocalizationAdmin");
|
||||
Html.ItemEditLink(Model.MasterContentItem ?? Model.ContentItem))</div>
|
||||
@Html.Hidden("SelectedCulture", Model.SelectedCulture)
|
||||
</fieldset>
|
||||
@if (Model.ContentLocalizations.Localizations.Count() > 0) {
|
||||
if (Model.ContentLocalizations.Localizations.Count() > 0) {
|
||||
<dl class="content-localization">
|
||||
<dt>@T("Other translations:")</dt>
|
||||
<dd class="content-localizations">
|
||||
@@ -17,4 +17,6 @@ Style.Require("LocalizationAdmin");
|
||||
</dd>
|
||||
</dl>
|
||||
}
|
||||
</fieldset>}
|
||||
}
|
||||
<div class="add-localization">@Html.ActionLink(T("+ New translation").Text, "Translate", "Admin", new { area = "Orchard.Localization", id = Model.ContentItem.Id }, null)</div>
|
||||
</fieldset>
|
||||
|
@@ -70,6 +70,13 @@ namespace Orchard.Widgets.Filters {
|
||||
Logger.Warning("The widget '{0}' is has no assigned layer or the layer does not exist.", widgetPart.Title);
|
||||
continue;
|
||||
}
|
||||
|
||||
// ignore widget for different cultures
|
||||
var localizablePart = widgetPart.As<ILocalizablePart>();
|
||||
if (localizablePart == null || localizablePart.Culture != workContext.CurrentCulture) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (activeLayerIds.Contains(commonPart.Container.ContentItem.Id)) {
|
||||
var widgetShape = _contentManager.BuildDisplay(widgetPart);
|
||||
zones[widgetPart.Record.Zone].Add(widgetShape, widgetPart.Record.Position);
|
||||
|
@@ -0,0 +1,5 @@
|
||||
namespace Orchard.ContentManagement.Aspects {
|
||||
public interface ILocalizablePart : IContent {
|
||||
string Culture { get ; }
|
||||
}
|
||||
}
|
@@ -164,6 +164,7 @@
|
||||
<Compile Include="Caching\DefaultParallelCacheContext.cs" />
|
||||
<Compile Include="Caching\ICacheContextAccessor.cs" />
|
||||
<Compile Include="Caching\IParallelCacheContext.cs" />
|
||||
<Compile Include="ContentManagement\Aspects\ILocalizablePart.cs" />
|
||||
<Compile Include="ContentManagement\ContentIdentity.cs" />
|
||||
<Compile Include="ContentManagement\ContentItemBehavior.cs" />
|
||||
<Compile Include="ContentManagement\ContentPartBehavior.cs" />
|
||||
|
Reference in New Issue
Block a user