umbraco.ui is GONE :)
This commit is contained in:
@@ -8,6 +8,7 @@ using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Services;
|
||||
using umbraco;
|
||||
using umbraco.interfaces;
|
||||
using Umbraco.Core.Models;
|
||||
|
||||
namespace Umbraco.Web
|
||||
{
|
||||
@@ -71,12 +72,12 @@ namespace Umbraco.Web
|
||||
sender,
|
||||
entity,
|
||||
action.Letter.ToString(CultureInfo.InvariantCulture),
|
||||
ui.Text("actions", action.Alias),
|
||||
applicationContext.Services.TextService.Localize("actions", action.Alias),
|
||||
umbracoContext.HttpContext,
|
||||
(mailingUser, strings) => ui.Text("notifications", "mailSubject", strings, mailingUser),
|
||||
(mailingUser, strings) => applicationContext.Services.TextService.Localize("notifications/mailSubject", mailingUser.GetUserCulture(applicationContext.Services.TextService), strings),
|
||||
(mailingUser, strings) => UmbracoConfig.For.UmbracoSettings().Content.DisableHtmlEmail
|
||||
? ui.Text("notifications", "mailBody", strings, mailingUser)
|
||||
: ui.Text("notifications", "mailBodyHtml", strings, mailingUser));
|
||||
? applicationContext.Services.TextService.Localize("notifications/mailBody", mailingUser.GetUserCulture(applicationContext.Services.TextService), strings)
|
||||
: applicationContext.Services.TextService.Localize("notifications/mailBodyHtml", mailingUser.GetUserCulture(applicationContext.Services.TextService), strings));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,7 @@ namespace Umbraco.Web.WebServices
|
||||
//if all are successful then just say it was successful
|
||||
if (statuses.All(x => ((int) x.StatusType) < 10))
|
||||
{
|
||||
return ui.Text("publish", "nodePublishAll", doc.Name, UmbracoUser);
|
||||
return Services.TextService.Localize("publish/nodePublishAll", new[] { doc.Name});
|
||||
}
|
||||
|
||||
//if they are not all successful the we'll add each error message to the output (one per line)
|
||||
@@ -79,24 +79,23 @@ namespace Umbraco.Web.WebServices
|
||||
{
|
||||
case PublishStatusType.Success:
|
||||
case PublishStatusType.SuccessAlreadyPublished:
|
||||
return ui.Text("publish", "nodePublish", status.ContentItem.Name, UmbracoUser);
|
||||
return Services.TextService.Localize("publish/nodePublish", new[] { status.ContentItem.Name});
|
||||
case PublishStatusType.FailedPathNotPublished:
|
||||
return ui.Text("publish", "contentPublishedFailedByParent",
|
||||
string.Format("{0} ({1})", status.ContentItem.Name, status.ContentItem.Id), UmbracoUser);
|
||||
return Services.TextService.Localize("publish/contentPublishedFailedByParent",
|
||||
new [] { string.Format("{0} ({1})", status.ContentItem.Name, status.ContentItem.Id) });
|
||||
case PublishStatusType.FailedHasExpired:
|
||||
case PublishStatusType.FailedAwaitingRelease:
|
||||
case PublishStatusType.FailedIsTrashed:
|
||||
return "Cannot publish document with a status of " + status.StatusType;
|
||||
case PublishStatusType.FailedCancelledByEvent:
|
||||
return ui.Text("publish", "contentPublishedFailedByEvent",
|
||||
string.Format("{0} ({1})", status.ContentItem.Name, status.ContentItem.Id), UmbracoUser);
|
||||
return Services.TextService.Localize("publish/contentPublishedFailedByEvent",
|
||||
new [] { string.Format("{0} ({1})", status.ContentItem.Name, status.ContentItem.Id) });
|
||||
case PublishStatusType.FailedContentInvalid:
|
||||
return ui.Text("publish", "contentPublishedFailedInvalid",
|
||||
return Services.TextService.Localize("publish/contentPublishedFailedInvalid",
|
||||
new []{
|
||||
string.Format("{0} ({1})", status.ContentItem.Name, status.ContentItem.Id),
|
||||
string.Join(",", status.InvalidProperties.Select(x => x.Alias))
|
||||
},
|
||||
UmbracoUser);
|
||||
});
|
||||
default:
|
||||
return status.StatusType.ToString();
|
||||
}
|
||||
|
||||
@@ -483,7 +483,7 @@ namespace umbraco.cms.presentation.Trees
|
||||
/// <returns></returns>
|
||||
public static string GetTreeHeader(string alias)
|
||||
{
|
||||
string treeCaption = ui.Text(alias);
|
||||
string treeCaption = ApplicationContext.Current.Services.TextService.Localize(alias);
|
||||
//this is a hack. the tree header title should be in the language files, however, if it is not, we're just
|
||||
//going to make it equal to what is specified in the db.
|
||||
if (treeCaption.Length > 0 && treeCaption.Substring(0, 1) == "[")
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace umbraco.presentation.dialogs
|
||||
// populate the message
|
||||
mail.Subject = Services.TextService.Localize("translation/mailSubject", Translator.UserEntity.GetUserCulture(Services.TextService), subjectVars);
|
||||
mail.IsBodyHtml = false;
|
||||
mail.Body = ui.Text("translation", "mailBody", bodyVars, Translator);
|
||||
mail.Body = Services.TextService.Localize("translation/mailBody", Translator.UserEntity.GetUserCulture(Services.TextService), bodyVars);
|
||||
try
|
||||
{
|
||||
SmtpClient sender = new SmtpClient();
|
||||
|
||||
@@ -9,6 +9,7 @@ using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Services;
|
||||
using Action = Umbraco.Web.LegacyActions.Action;
|
||||
|
||||
namespace umbraco.presentation.umbraco.dialogs
|
||||
@@ -42,7 +43,7 @@ namespace umbraco.presentation.umbraco.dialogs
|
||||
ArrayList actions = Action.GetAll();
|
||||
foreach (interfaces.IAction a in actions)
|
||||
{
|
||||
return ui.Text(action);
|
||||
return Services.TextService.Localize(action);
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<table id="Table1" width="100%">
|
||||
<tr>
|
||||
<th width="15%">
|
||||
<%=umbraco.ui.Text("name", base.getUser())%>
|
||||
<%=Services.TextService.Localize("name")%>
|
||||
</th>
|
||||
<td>
|
||||
<asp:TextBox ID="NameTxt" Width="200px" runat="server"></asp:TextBox>
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.4927
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace umbraco.settings
|
||||
save.ButtonType = uicontrols.MenuButtonType.Primary;
|
||||
|
||||
Literal txt = new Literal();
|
||||
txt.Text = "<p>" + ui.Text("dictionaryItem", "description", currentItem.key, Security.CurrentUser) + "</p><br/>";
|
||||
txt.Text = "<p>" + Services.TextService.Localize("dictionaryItem/description", new[] { currentItem.key }) + "</p><br/>";
|
||||
p.addProperty(txt);
|
||||
|
||||
foreach (cms.businesslogic.language.Language l in cms.businesslogic.language.Language.getAll)
|
||||
|
||||
@@ -101,9 +101,9 @@ namespace umbraco.cms.presentation.settings
|
||||
SaveButton.CssClass = "client-side";
|
||||
|
||||
Panel1.Text = Services.TextService.Localize("edittemplate");
|
||||
pp_name.Text = ui.Text("name", UmbracoUser);
|
||||
pp_alias.Text = ui.Text("alias", UmbracoUser);
|
||||
pp_masterTemplate.Text = ui.Text("mastertemplate", UmbracoUser);
|
||||
pp_name.Text = Services.TextService.Localize("name");
|
||||
pp_alias.Text = Services.TextService.Localize("alias");
|
||||
pp_masterTemplate.Text = Services.TextService.Localize("mastertemplate");
|
||||
|
||||
|
||||
// Editing buttons
|
||||
|
||||
@@ -51,8 +51,8 @@ namespace umbraco.cms.presentation.settings.stylesheet
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
Panel1.Text = Services.TextService.Localize("stylesheet/editstylesheet");
|
||||
pp_name.Text = ui.Text("name", UmbracoUser);
|
||||
pp_path.Text = ui.Text("path", UmbracoUser);
|
||||
pp_name.Text = Services.TextService.Localize("name");
|
||||
pp_path.Text = Services.TextService.Localize("path");
|
||||
|
||||
var stylesheet = Services.FileService.GetStylesheetByName(filename);
|
||||
if (stylesheet == null) // not found
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace umbraco.cms.presentation.user
|
||||
{
|
||||
if (UmbracoContext.UmbracoUser.IsAdmin() || ut.Alias != "admin")
|
||||
{
|
||||
ListItem li = new ListItem(ui.Text("user", ut.Name.ToLower(), UmbracoUser), ut.Id.ToString());
|
||||
ListItem li = new ListItem(Services.TextService.Localize("user", ut.Name.ToLower()), ut.Id.ToString());
|
||||
if (ut.Id == u.UserType.Id)
|
||||
li.Selected = true;
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace umbraco.cms.presentation.user
|
||||
pp.addProperty(Services.TextService.Localize("user/username"), uname);
|
||||
pp.addProperty(Services.TextService.Localize("user/loginname"), lname);
|
||||
pp.addProperty(Services.TextService.Localize("user/password"), passw);
|
||||
pp.addProperty(ui.Text("email", UmbracoUser), email);
|
||||
pp.addProperty(Services.TextService.Localize("email"), email);
|
||||
pp.addProperty(Services.TextService.Localize("user/usertype"), userType);
|
||||
pp.addProperty(Services.TextService.Localize("user/language"), userLanguage);
|
||||
|
||||
@@ -205,7 +205,7 @@ namespace umbraco.cms.presentation.user
|
||||
|
||||
sectionValidator.ServerValidate += new ServerValidateEventHandler(sectionValidator_ServerValidate);
|
||||
sectionValidator.ControlToValidate = lapps.ID;
|
||||
sectionValidator.ErrorMessage = ui.Text("errorHandling", "errorMandatoryWithoutTab", Services.TextService.Localize("user/modules"), UmbracoUser);
|
||||
sectionValidator.ErrorMessage = Services.TextService.Localize("errorHandling/errorMandatoryWithoutTab", new[] { Services.TextService.Localize("user/modules") });
|
||||
sectionValidator.CssClass = "error";
|
||||
sectionValidator.Style.Add("color", "red");
|
||||
|
||||
@@ -249,7 +249,7 @@ namespace umbraco.cms.presentation.user
|
||||
{
|
||||
if (UmbracoContext.UmbracoUser.IsAdmin() || currentUserApps.Contains(";" + app.alias + ";"))
|
||||
{
|
||||
ListItem li = new ListItem(ui.Text("sections", app.alias), app.alias);
|
||||
ListItem li = new ListItem(Services.TextService.Localize("sections", app.alias), app.alias);
|
||||
if (!IsPostBack) foreach (Application tmp in uapps) if (app.alias == tmp.alias) li.Selected = true;
|
||||
lapps.Items.Add(li);
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace umbraco.cms.presentation.user
|
||||
|
||||
foreach (IAction ai in Action.GetPermissionAssignable()) {
|
||||
|
||||
ListItem li = new ListItem(umbraco.ui.Text(ai.Alias, Security.CurrentUser), ai.Letter.ToString());
|
||||
ListItem li = new ListItem(Services.TextService.Localize(ai.Alias), ai.Letter.ToString());
|
||||
|
||||
if(CurrentUserTypeActions.Contains(ai))
|
||||
li.Selected = true;
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<li>
|
||||
<input type="checkbox" name='<%#"chkPermission" + DataBinder.Eval(Container, "ItemIndex").ToString() %>' id='<%#"chkPermission" + DataBinder.Eval(Container, "ItemIndex").ToString() %>' value='<%#((AssignedPermission)Container.DataItem).Permission.Letter %>' <%#(((AssignedPermission)Container.DataItem).HasPermission ? "checked='true'" : "") %> />
|
||||
<label for='<%#"chkPermission" + DataBinder.Eval(Container, "ItemIndex").ToString() %>' class='checkbox inline <%#(((AssignedPermission)Container.DataItem).HasPermission ? "activePermission" : "") %>'>
|
||||
<%# umbraco.ui.GetText(((AssignedPermission)Container.DataItem).Permission.Alias) %>
|
||||
<%# Services.TextService.Localize(((AssignedPermission)Container.DataItem).Permission.Alias) %>
|
||||
</label>
|
||||
</li>
|
||||
</ItemTemplate>
|
||||
|
||||
@@ -1,356 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Web.Caching;
|
||||
using System.Xml;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using File = System.IO.File;
|
||||
using User = umbraco.BusinessLogic.User;
|
||||
|
||||
namespace umbraco
|
||||
{
|
||||
|
||||
//TODO: Make the User overloads obsolete, then publicize the IUser object
|
||||
|
||||
/// <summary>
|
||||
/// The ui class handles the multilingual text in the umbraco back-end.
|
||||
/// Provides access to language settings and language files used in the umbraco back-end.
|
||||
/// </summary>
|
||||
[Obsolete("Use the ILocalizedTextService instead which is on the ApplicationContext.Services.TextService")]
|
||||
public class ui
|
||||
{
|
||||
private static readonly string UmbracoDefaultUiLanguage = Umbraco.Core.Configuration.GlobalSettings.DefaultUILanguage;
|
||||
private static readonly string UmbracoPath = SystemDirectories.Umbraco;
|
||||
|
||||
private static string GetLanguage()
|
||||
{
|
||||
return "en-US";
|
||||
throw new NotImplementedException("NOTHING WILL WORK UNTIL WE REPLACE ALL USAGES OF THE ui CLASS");
|
||||
}
|
||||
|
||||
private static string GetLanguage(User u)
|
||||
{
|
||||
if (u != null)
|
||||
{
|
||||
return u.Language;
|
||||
}
|
||||
return GetLanguage("");
|
||||
}
|
||||
|
||||
private static string GetLanguage(IUser u)
|
||||
{
|
||||
if (u != null)
|
||||
{
|
||||
return u.Language;
|
||||
}
|
||||
return GetLanguage("");
|
||||
}
|
||||
|
||||
private static string GetLanguage(string userLanguage)
|
||||
{
|
||||
if (userLanguage.IsNullOrWhiteSpace() == false)
|
||||
{
|
||||
return userLanguage;
|
||||
}
|
||||
var language = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
|
||||
if (string.IsNullOrEmpty(language))
|
||||
language = UmbracoDefaultUiLanguage;
|
||||
return language;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns translated UI text with a specific key based on the specified user's language settings
|
||||
/// </summary>
|
||||
/// <param name="Key">The key.</param>
|
||||
/// <param name="u">The user.</param>
|
||||
/// <returns></returns>
|
||||
public static string Text(string Key, User u)
|
||||
{
|
||||
if (ApplicationContext.Current == null) return "[" + Key + "]";
|
||||
|
||||
return ApplicationContext.Current.Services.TextService.Localize(Key, GetCultureFromUserLanguage(GetLanguage(u)));
|
||||
}
|
||||
|
||||
internal static string Text(string key, IUser u)
|
||||
{
|
||||
if (ApplicationContext.Current == null) return "[" + key + "]";
|
||||
|
||||
return ApplicationContext.Current.Services.TextService.Localize(key, GetCultureFromUserLanguage(GetLanguage(u)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns translated UI text with a specific key based on the logged-in user's language settings
|
||||
/// </summary>
|
||||
/// <param name="Key">The key.</param>
|
||||
/// <returns></returns>
|
||||
public static string Text(string Key)
|
||||
{
|
||||
if (ApplicationContext.Current == null) return "[" + Key + "]";
|
||||
|
||||
return ApplicationContext.Current.Services.TextService.Localize(Key, GetCultureFromUserLanguage(GetLanguage()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns translated UI text with a specific key and area, based on the specified users language settings
|
||||
/// </summary>
|
||||
/// <param name="Area">The area.</param>
|
||||
/// <param name="Key">The key.</param>
|
||||
/// <param name="u">The user.</param>
|
||||
/// <returns></returns>
|
||||
public static string Text(string Area, string Key, User u)
|
||||
{
|
||||
if (ApplicationContext.Current == null) return "[" + Key + "]";
|
||||
|
||||
return ApplicationContext.Current.Services.TextService.Localize(
|
||||
string.Format("{0}/{1}", Area, Key),
|
||||
GetCultureFromUserLanguage(GetLanguage(u)));
|
||||
}
|
||||
|
||||
public static string Text(string area, string key, IUser u)
|
||||
{
|
||||
if (ApplicationContext.Current == null) return "[" + key + "]";
|
||||
|
||||
return ApplicationContext.Current.Services.TextService.Localize(
|
||||
string.Format("{0}/{1}", area, key),
|
||||
GetCultureFromUserLanguage(GetLanguage(u)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns translated UI text with a specific key and area, based on the logged-in users language settings
|
||||
/// </summary>
|
||||
/// <param name="Area">The area.</param>
|
||||
/// <param name="Key">The key.</param>
|
||||
/// <returns></returns>
|
||||
public static string Text(string Area, string Key)
|
||||
{
|
||||
if (ApplicationContext.Current == null) return "[" + Key + "]";
|
||||
|
||||
return ApplicationContext.Current.Services.TextService.Localize(
|
||||
string.Format("{0}/{1}", Area, Key),
|
||||
GetCultureFromUserLanguage(GetLanguage()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns translated UI text with a specific area and key. based on the specified users language settings and variables array passed to the method
|
||||
/// </summary>
|
||||
/// <param name="Area">The area.</param>
|
||||
/// <param name="Key">The key.</param>
|
||||
/// <param name="Variables">The variables array.</param>
|
||||
/// <param name="u">The user.</param>
|
||||
/// <returns></returns>
|
||||
public static string Text(string Area, string Key, string[] Variables, User u)
|
||||
{
|
||||
if (ApplicationContext.Current == null) return "[" + Key + "]";
|
||||
|
||||
return ApplicationContext.Current.Services.TextService.Localize(
|
||||
string.Format("{0}/{1}", Area, Key),
|
||||
GetCultureFromUserLanguage(GetLanguage(u)),
|
||||
ConvertToDictionaryVars(Variables));
|
||||
}
|
||||
|
||||
internal static string Text(string area, string key, string[] variables)
|
||||
{
|
||||
if (ApplicationContext.Current == null) return "[" + key + "]";
|
||||
|
||||
return ApplicationContext.Current.Services.TextService.Localize(
|
||||
string.Format("{0}/{1}", area, key),
|
||||
GetCultureFromUserLanguage(GetLanguage()),
|
||||
ConvertToDictionaryVars(variables));
|
||||
}
|
||||
|
||||
internal static string Text(string area, string key, string[] variables, IUser u)
|
||||
{
|
||||
if (ApplicationContext.Current == null) return "[" + key + "]";
|
||||
|
||||
return ApplicationContext.Current.Services.TextService.Localize(
|
||||
string.Format("{0}/{1}", area, key),
|
||||
GetCultureFromUserLanguage(GetLanguage(u)),
|
||||
ConvertToDictionaryVars(variables));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns translated UI text with a specific key and area based on the specified users language settings and single variable passed to the method
|
||||
/// </summary>
|
||||
/// <param name="Area">The area.</param>
|
||||
/// <param name="Key">The key.</param>
|
||||
/// <param name="Variable">The variable.</param>
|
||||
/// <param name="u">The u.</param>
|
||||
/// <returns></returns>
|
||||
public static string Text(string Area, string Key, string Variable, User u)
|
||||
{
|
||||
if (ApplicationContext.Current == null) return "[" + Key + "]";
|
||||
|
||||
return ApplicationContext.Current.Services.TextService.Localize(
|
||||
string.Format("{0}/{1}", Area, Key),
|
||||
GetCultureFromUserLanguage(GetLanguage(u)),
|
||||
ConvertToDictionaryVars(new[] { Variable }));
|
||||
}
|
||||
|
||||
internal static string Text(string area, string key, string variable)
|
||||
{
|
||||
if (ApplicationContext.Current == null) return "[" + key + "]";
|
||||
|
||||
return ApplicationContext.Current.Services.TextService.Localize(
|
||||
string.Format("{0}/{1}", area, key),
|
||||
GetCultureFromUserLanguage(GetLanguage()),
|
||||
ConvertToDictionaryVars(new[] { variable }));
|
||||
}
|
||||
|
||||
internal static string Text(string area, string key, string variable, IUser u)
|
||||
{
|
||||
if (ApplicationContext.Current == null) return "[" + key + "]";
|
||||
|
||||
return ApplicationContext.Current.Services.TextService.Localize(
|
||||
string.Format("{0}/{1}", area, key),
|
||||
GetCultureFromUserLanguage(GetLanguage(u)),
|
||||
ConvertToDictionaryVars(new[] { variable }));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns translated UI text with a specific key based on the logged-in user's language settings
|
||||
/// </summary>
|
||||
/// <param name="key">The key.</param>
|
||||
/// <returns></returns>
|
||||
public static string GetText(string key)
|
||||
{
|
||||
return ApplicationContext.Current.Services.TextService.Localize(key, GetCultureFromUserLanguage(GetLanguage()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns translated UI text with a specific key and area based on the logged-in users language settings
|
||||
/// </summary>
|
||||
/// <param name="area">The area.</param>
|
||||
/// <param name="key">The key.</param>
|
||||
/// <returns></returns>
|
||||
public static string GetText(string area, string key)
|
||||
{
|
||||
if (ApplicationContext.Current == null) return "[" + key + "]";
|
||||
|
||||
return ApplicationContext.Current.Services.TextService.Localize(
|
||||
string.Format("{0}/{1}", area, key),
|
||||
GetCultureFromUserLanguage(GetLanguage()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns translated UI text with a specific key and area based on the logged-in users language settings and variables array send to the method.
|
||||
/// </summary>
|
||||
/// <param name="area">The area.</param>
|
||||
/// <param name="key">The key.</param>
|
||||
/// <param name="variables">The variables.</param>
|
||||
/// <returns></returns>
|
||||
public static string GetText(string area, string key, string[] variables)
|
||||
{
|
||||
if (ApplicationContext.Current == null) return "[" + key + "]";
|
||||
|
||||
return ApplicationContext.Current.Services.TextService.Localize(
|
||||
string.Format("{0}/{1}", area, key),
|
||||
GetCultureFromUserLanguage(GetLanguage()),
|
||||
ConvertToDictionaryVars(variables));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns translated UI text with a specific key and area matching the variable send to the method.
|
||||
/// </summary>
|
||||
/// <param name="area">The area.</param>
|
||||
/// <param name="key">The key.</param>
|
||||
/// <param name="variable">The variable.</param>
|
||||
/// <returns></returns>
|
||||
public static string GetText(string area, string key, string variable)
|
||||
{
|
||||
if (ApplicationContext.Current == null) return "[" + key + "]";
|
||||
|
||||
return ApplicationContext.Current.Services.TextService.Localize(
|
||||
string.Format("{0}/{1}", area, key),
|
||||
GetCultureFromUserLanguage(GetLanguage()),
|
||||
ConvertToDictionaryVars(new[] { variable }));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns translated UI text with a specific key, area and language matching the variables send to the method.
|
||||
/// </summary>
|
||||
/// <param name="area">The area (Optional)</param>
|
||||
/// <param name="key">The key (Required)</param>
|
||||
/// <param name="variables">The variables (Optional)</param>
|
||||
/// <param name="language">The language (Optional)</param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>This is the underlying call for all Text/GetText method calls</remarks>
|
||||
public static string GetText(string area, string key, string[] variables, string language)
|
||||
{
|
||||
if (ApplicationContext.Current == null) return "[" + key + "]";
|
||||
|
||||
return ApplicationContext.Current.Services.TextService.Localize(
|
||||
string.Format("{0}/{1}", area, key),
|
||||
GetCultureFromUserLanguage(GetLanguage()),
|
||||
ConvertToDictionaryVars(variables));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the language file as a xml document.
|
||||
/// </summary>
|
||||
/// <param name="language">The language.</param>
|
||||
/// <returns></returns>
|
||||
[Obsolete("This is no longer used and will be removed from the codebase in future versions, to get the contents of language text use ILocalizedTextService.GetAllStoredValues")]
|
||||
public static XmlDocument getLanguageFile(string language)
|
||||
{
|
||||
var cacheKey = "uitext_" + language;
|
||||
|
||||
var file = IOHelper.MapPath(UmbracoPath + "/config/lang/" + language + ".xml");
|
||||
if (File.Exists(file))
|
||||
{
|
||||
return ApplicationContext.Current.ApplicationCache.GetCacheItem(
|
||||
cacheKey,
|
||||
CacheItemPriority.Default,
|
||||
new CacheDependency(IOHelper.MapPath(UmbracoPath + "/config/lang/" + language + ".xml")),
|
||||
() =>
|
||||
{
|
||||
using (var langReader = new XmlTextReader(IOHelper.MapPath(UmbracoPath + "/config/lang/" + language + ".xml")))
|
||||
{
|
||||
try
|
||||
{
|
||||
var langFile = new XmlDocument();
|
||||
langFile.Load(langReader);
|
||||
return langFile;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogHelper.Error<ui>("Error reading umbraco language xml source (" + language + ")", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert an array of strings to a dictionary of indicies -> values
|
||||
/// </summary>
|
||||
/// <param name="variables"></param>
|
||||
/// <returns></returns>
|
||||
internal static IDictionary<string, string> ConvertToDictionaryVars(string[] variables)
|
||||
{
|
||||
if (variables == null) return null;
|
||||
if (variables.Any() == false) return null;
|
||||
|
||||
return variables.Select((s, i) => new {index = i.ToString(CultureInfo.InvariantCulture), value = s})
|
||||
.ToDictionary(keyvals => keyvals.index, keyvals => keyvals.value);
|
||||
}
|
||||
|
||||
private static CultureInfo GetCultureFromUserLanguage(string userLang)
|
||||
{
|
||||
return CultureInfo.GetCultureInfo(userLang.Replace("_", "-"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -189,9 +189,6 @@
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="StateHelper.cs" />
|
||||
<Compile Include="ui.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="User.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
||||
Reference in New Issue
Block a user