How does it work?

All Translation Control

HOW TO USE:

  • Add cotrol and reference to this control to your ASP.NET page.
  • Add ASP:Button to your ASP page, name it "btnSave" and set Text = "Save".
  • Add event to this button: protected void btnSaveTranslation_Click(object sender, EventArgs e)
  • Set language list.
  • Set translate key.
  • Start your Web Application.
  • Fill TextBox.
  • Click "Save" button.

PROPERTIES:

  • public ArrayList ListLang - get or set list of Languges
  • public string TranslateKey - get or set current Translate Key

How to use ASP Translator in your application

ADDING ASPTRANSLATOR

To add ASPTranslator to your own application you should in MasterPage in void Page_PreRender:

  • create object of class aspTranslator.Translater using constructor: public Translater(string languageCode, System.Web.UI.ControlCollection controls) where langugeCode is code language you want translate to and controls is a collection of all controls. Next you should call out function translateAllControls().
  • create object of class aspTranslator.Translater using constructor: public Translater(System.Web.UI.ControlCollection controls) and next call out function translateAllControls with in parameter string with code current language and code language you want translate to.

It is a better practice to use second solution, for example:

protected void Page_PreRender(object sender, EventArgs e)
{
if (!IsPostBack)
{
string lang = null;
if (Session["lang"] != null) lang = Session["lang"].ToString();

if (string.IsNullOrEmpty(lang))
{
Session["lang"] = "key";
}
else
{
aspTranslator.Translater trans = new aspTranslator.Translater(this.Controls);
trans.translateAllControls("key", lang);
}
}
}

CHANGING LANGUAGE

To change language you should create object of class aspTranslator.Translater using constructor: public Translater(System.Web.UI.ControlCollection controls) and next call out function translateAllControls with in parameter string with code current language and code language you want translate to, for example:

protected void LinkButtonPL_Click(object sender, EventArgs e)
{
aspTranslator.Translater trans = new aspTranslator.Translater(this.Controls);

string lang = null;
if (Session["lang"] != null) lang = Session["lang"].ToString();

if (string.IsNullOrEmpty(lang))
{
trans.translateAllControls("key", "PL");
}
else
{
if (!lang.Equals("PL")) trans.translateAllControls(lang, "PL");
}

Session["lang"] = "PL";
}

All rights reserved for Netrosoft © 2007