CodeCharge Studio All ASP PHP Perl ColdFusion Java C#.NET VB.NET

Translating Control Values via Custom Code

This example demonstrates how to retrieve a translation string by its key and assign it to a label using the Before Show event.

We will use the "CCS_Today" translation key from CCS project resources.

  1. Add the Before Show event to the Label control
  2. Enter the code below into the event:

    ASP

    Function Label1_BeforeShow(Sender) 
      Sender.Value = CCSLocales.GetText("CCS_Today", Empty)
    End Function

    PHP

    function Label1_BeforeShow(& $sender) {
    global $CCSLocales;
      $Component->SetValue($CCSLocales->GetText("CCS_Today"));
    }

    Perl

    sub Label1_BeforeShow() {
      $Label1->SetValue($CCSLocales->GetText("CCS_Today"));
    }

    ColdFusion

    <!--- Event: BeforeShow. Action: Custom Code. Control: Label1 --->
      <CFSET fldLabel1 = Request.CCSLocales.GetText("CCS_Today")>

    VB.Net

    • Net Framework 1.0, Net Framework 1.1:
      'Label Label1 Event BeforeShow
        Label1.Text = rm.GetString("CCS_Today")
    • Net Framework 2.0:
      'Label Label1 Event BeforeShow
        Label1.Text = Resources.strings.CCS_Today

    C#

    • Net Framework 1.0, Net Framework 1.1:
      //Label Label1 Event BeforeShow
        Label1.Text = rm.GetString("CCS_Today");
    • Net Framework 2.0:
      //Label Label1 Event BeforeShow
        Label1.Text = Resources.strings.CCS_Today;

    Java

    //Label1_BeforeShow 
      e.getControl().setValue(e.getPage().getResourceString("CCS_Today"));

See also


On-line, printable versions and updates