|
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Localization {
/// <summary>
///
/// </summary>
/// <remarks>
/// Since the literal doesn't allow us to have child controls, I had to change this to a lable
/// However, I did create a LocalizedNoParameterLiteral control that takes a literal, but you won't
/// be able to use it to pass parameters.
/// </remarks>
public class LocalizedLiteral : Label, ILocalized {
#region fields and properties
private string key;
private bool colon = false;
public bool Colon {
get { return colon; }
set { colon = value; }
}
public string Key {
get { return key; }
set { key = value; }
}
#endregion
protected override void Render(HtmlTextWriter writer) {
string value = ResourceManager.GetString(key);
if (colon){
value += ResourceManager.Colon;
}
for (int i = 0; i < Controls.Count; i++){
Parameter parameter = Controls[i] as Parameter;
if(parameter != null){
string k = parameter.Key;
string v = parameter.Value;
value = value.Replace('{' + k.ToUpper() + '}', v);
}
}
base.Text = value;
base.Render(writer);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.