diff --git a/src/Orchard.Web/Core/Shapes/Views/User.cshtml b/src/Orchard.Web/Core/Shapes/Views/User.cshtml index 6054c9adf9c..806cc83c784 100644 --- a/src/Orchard.Web/Core/Shapes/Views/User.cshtml +++ b/src/Orchard.Web/Core/Shapes/Views/User.cshtml @@ -3,7 +3,7 @@
@if (WorkContext.CurrentUser != null) { - @T("Welcome, {0}!", "" + @Html.ItemDisplayText(WorkContext.CurrentUser) + "") + @T("Welcome, {0}!", Html.Raw("" + Html.ItemDisplayText(WorkContext.CurrentUser) + "")) @Html.ActionLink(T("Sign Out").ToString(), "LogOff", new { Controller = "Account", Area = "Orchard.Users", ReturnUrl = Context.Request.RawUrl }, new { rel = "nofollow" }) diff --git a/src/Orchard.Web/Modules/Orchard.Localization/Views/EditorTemplates/Parts/Localization.ContentTranslations.Edit.cshtml b/src/Orchard.Web/Modules/Orchard.Localization/Views/EditorTemplates/Parts/Localization.ContentTranslations.Edit.cshtml index b4e9126e9ac..2e85cadbb62 100644 --- a/src/Orchard.Web/Modules/Orchard.Localization/Views/EditorTemplates/Parts/Localization.ContentTranslations.Edit.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Localization/Views/EditorTemplates/Parts/Localization.ContentTranslations.Edit.cshtml @@ -1,22 +1,117 @@ @model Orchard.Localization.ViewModels.EditLocalizationViewModel -
-@if (Model.ContentItem.ContentItem.Id > 0 && Model.SelectedCulture != null && Model.ContentLocalizations.Localizations.Count() > 0) { +@using System.Globalization +@{ Style.Require("LocalizationAdmin"); -
- -
@T("This is the {0} variation of {1}.", - Html.Encode(Model.SelectedCulture), - Html.ItemEditLink(Model.MasterContentItem ?? Model.ContentItem))
- @Html.Hidden("SelectedCulture", Model.SelectedCulture) -
- if (Model.ContentLocalizations.Localizations.Count() > 0) { -
-
@T("Other translations:")
-
- @Html.UnorderedList(Model.ContentLocalizations.Localizations, (c, i) => Html.ItemEditLink(c.Culture.Culture, c), "localizations") -
-
- } -} -
@Html.ActionLink(T("+ New translation").Text, "Translate", "Admin", new { area = "Orchard.Localization", id = Model.ContentItem.Id }, null)
+} +
+ +
+ @*Brand new content item*@ + @if (Model.ContentItem.ContentItem.Id == 0) { + if (Model.MasterContentItem == null) { + @T("This is the {0} variation of the content", + BuildSelectedCultureList( + Html.FieldIdFor(m => m.SelectedCulture), + Html.FieldNameFor(m => m.SelectedCulture), + Model.MissingCultures, + Model.SelectedCulture)) + } + else { + @T("This is the {0} variation of {1}", + BuildSelectedCultureList( + Html.FieldIdFor(m => m.SelectedCulture), + Html.FieldNameFor(m => m.SelectedCulture), + Model.MissingCultures, + Model.SelectedCulture), + Html.ItemEditLink(Model.MasterContentItem)) + } + } + + @if (Model.ContentItem.ContentItem.Id > 0) { + if (string.IsNullOrEmpty(Model.SelectedCulture)) { + @T("This content currently has no culture associated to it, please select a culture to associate to this piece of content: {0}", + BuildSelectedCultureList( + Html.FieldIdFor(m => m.SelectedCulture), + Html.FieldNameFor(m => m.SelectedCulture), + Model.MissingCultures, + Model.SelectedCulture)) + } + else { + @T("This is the {0} variation of the content", + Html.Encode(Model.SelectedCulture)) + + if (Model.ContentLocalizations.Localizations.Any()) { +
+
@T("Other translations:")
+
+ @Html.UnorderedList(Model.ContentLocalizations.Localizations, (c, i) => + Html.ItemEditLink(c.Culture.Culture, c), "localizations") +
+
+ } + + if (Model.MissingCultures.Any()) { + var contentItemId = Model.MasterContentItem != null ? Model.MasterContentItem.Id : Model.ContentItem.Id; + +
@Html.ActionLink(T("+ New translation").Text, "Translate", "Admin", new {area = "Orchard.Localization", id = contentItemId}, null)
+ } + + @Html.Hidden(Html.FieldNameFor(m => m.SelectedCulture), Model.SelectedCulture) + } + } +
+ + + +@functions{ + private IHtmlString BuildSelectedCultureList(string id, string name, IEnumerable siteCultures, string culture) { + TagBuilder selectTag = new TagBuilder("select"); + selectTag.Attributes["id"] = id; + selectTag.Attributes["name"] = name; + + foreach (var siteCulture in siteCultures) { + TagBuilder optionTag = new TagBuilder("option"); + optionTag.Attributes["data-content-dir"] = CultureInfo.GetCultureInfo(siteCulture).TextInfo.IsRightToLeft ? "rtl" : "ltr"; + + if (siteCulture == culture) { + optionTag.Attributes["selected"] = "selected"; + } + optionTag.SetInnerText(Html.Encode(siteCulture)); + selectTag.InnerHtml += optionTag.ToString(); + } + + return Html.Raw(selectTag); + } +} +@using (Script.Foot()) { + +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.MediaLibrary/Views/EditorTemplates/Parts/WebSearch.WebSearchSettings.cshtml b/src/Orchard.Web/Modules/Orchard.MediaLibrary/Views/EditorTemplates/Parts/WebSearch.WebSearchSettings.cshtml index 1138cb701c8..6bfce428d32 100644 --- a/src/Orchard.Web/Modules/Orchard.MediaLibrary/Views/EditorTemplates/Parts/WebSearch.WebSearchSettings.cshtml +++ b/src/Orchard.Web/Modules/Orchard.MediaLibrary/Views/EditorTemplates/Parts/WebSearch.WebSearchSettings.cshtml @@ -7,7 +7,7 @@ @T("Your private key.")
- @T("Get a free API Key on {0}", "http://datamarket.azure.com/dataset/bing/search") + @T("Get a free API Key on {0}", Html.Raw("http://datamarket.azure.com/dataset/bing/search")) diff --git a/src/Orchard.Web/Orchard/Localization/Text.cs b/src/Orchard.Web/Orchard/Localization/Text.cs new file mode 100644 index 00000000000..82ddc75d932 --- /dev/null +++ b/src/Orchard.Web/Orchard/Localization/Text.cs @@ -0,0 +1,62 @@ +using System; +using System.Globalization; +using System.Linq; +using System.Web; +using Orchard.Localization.Services; +using Orchard.Logging; + +namespace Orchard.Localization { + public class Text : IText { + private readonly string _scope; + private readonly IWorkContextAccessor _workContextAccessor; + private readonly ILocalizedStringManager _localizedStringManager; + + public Text(string scope, IWorkContextAccessor workContextAccessor, ILocalizedStringManager localizedStringManager) { + _scope = scope; + _workContextAccessor = workContextAccessor; + _localizedStringManager = localizedStringManager; + Logger = NullLogger.Instance; + } + + public ILogger Logger { get; set; } + + public LocalizedString Get(string textHint, params object[] args) { + Logger.Debug("{0} localizing '{1}'", _scope, textHint); + + var workContext = _workContextAccessor.GetContext(); + + if (workContext != null) { + var currentCulture = workContext.CurrentCulture; + var localizedFormat = _localizedStringManager.GetLocalizedString(_scope, textHint, currentCulture); + + return args.Length == 0 + ? new LocalizedString(localizedFormat, _scope, textHint, args) + : new LocalizedString( + String.Format(GetFormatProvider(currentCulture), localizedFormat, args.Select(Encode).ToArray()), + _scope, + textHint, + args); + } + + return new LocalizedString(textHint, _scope, textHint, args); + } + + private static IFormatProvider GetFormatProvider(string currentCulture) { + try { + return CultureInfo.GetCultureInfoByIetfLanguageTag(currentCulture); + } + catch { + return null; + } + } + + static object Encode(object arg) + { + if (arg is IFormattable || arg is IHtmlString) { + return arg; + } + + return HttpUtility.HtmlEncode(arg); + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Themes/TheAdmin/Views/Title.cshtml b/src/Orchard.Web/Themes/TheAdmin/Views/Title.cshtml index 730480609bc..ecd04b226ff 100644 --- a/src/Orchard.Web/Themes/TheAdmin/Views/Title.cshtml +++ b/src/Orchard.Web/Themes/TheAdmin/Views/Title.cshtml @@ -1 +1 @@ -

@Model.Title.ToString()

\ No newline at end of file +

@Model.Title

\ No newline at end of file