Άν και οφείλω να ομολογήσω οτι δεν έχει δεί ακόμα το String Resource Tool, ποιά η διαφορά του απο το να φτιάξεις κατευθείαν τα Resource Files μόνος σου, και να κάνεις derive τις φόρμες σου (web ή windows) απο μία η οποία στο page load καλεί μια μέθοδο σαν αυτή παρακάτω:
/// <summary>
/// Internationalizes the text of controls, recursively scanning any
/// possible child controls as well
/// </summary>
/// <param name="ctrl">The original control</param>
private void HandleControl(System.Web.UI.Control ctrl){
if(ctrl.HasControls()){
foreach(System.Web.UI.Control c in ctrl.Controls)
HandleControl(c);
}else{
if(ctrl is System.Web.UI.WebControls.Label){
Label lbl = (Label)ctrl;
// Log the label into a text file for easier translation
//this.Logger.Log(lbl.ID+","+lbl.Text);
string strLabelStr = UIUtils.GetFriendlyName(lbl.ID);
if(strLabelStr!=null)
lbl.Text = strLabelStr;
}else
if(ctrl is System.Web.UI.WebControls.Button){
Button btn = (Button)ctrl;
// Log the label into a text file for easier translation
//this.Logger.Log(btn.ID+","+btn.Text);
string strLabelStr = UIUtils.GetFriendlyName(btn.ID);
if(strLabelStr!=null)
btn.Text = strLabelStr;
}
else
if(ctrl is System.Web.UI.HtmlControls.HtmlButton){
System.Web.UI.HtmlControls.HtmlButton btn = (System.Web.UI.HtmlControls.HtmlButton)ctrl;
// Log the label into a text file for easier translation
//this.Logger.Log(btn.ID+","+btn.Attributes["value"]);
string strLabelStr = UIUtils.GetFriendlyName(btn.ID);
if(strLabelStr!=null)
btn.Attributes["value"] = strLabelStr;
}
else
if(ctrl is System.Web.UI.WebControls.BaseValidator){
System.Web.UI.WebControls.BaseValidator vld = (System.Web.UI.WebControls.BaseValidator)ctrl;
// Log the label into a text file for easier translation
//this.Logger.Log(vld.ID+","+vld.ErrorMessage);
string strLabelStr = UIUtils.GetFriendlyName(vld.ID);
if(strLabelStr!=null)
vld.ErrorMessage = strLabelStr;
}
}
}
Προσωπικά αυτό κάνω, κι έχω σχεδόν ξεχάσει πλέον το όλο θέμα, όπως και οι υπόλοιποι εδώ γύρω ... όσον αφορά το actual handling του resource string, η μέθοδος
που καλείται είναι η
GetFriendlyName(string strItem) , και το μόνο που κάνει είναι κάτι τέτοιο:
/// <summary>Returns the friendly name of a UI Component control. This name is retrieved from the friendly names file.
/// </summary>
/// <param name="strUIComponent">The name of the UI Component to which the control belongs.</param>
/// <param name="strUIItem">The name of the control (Item) for which the friendly name will be retrieved.</param>
/// <returns>Returns a string value.</returns>
public static string GetFriendlyName(string strItem)
{
System.Resources.ResourceManager rm = new System.Resources.ResourceManager("ESTIA.Components.Helper.EstiaFriendlyNames", typeof(clsConfig).Assembly);
return rm.GetString(strItem);
}
Για να είμαι και πιο ακριβής, ο ResourceManager είναι static μεταβλητή, απλώς το έγραψα έτσι για να είναι προφανές
Angel
O:]