Using Multi-Language System

Open the Quick Example project. Create a new file named: "english.language". You can add here all application strings:

#
# This is a coment, you can write what you want here...
#
# 
# English Language File
#
# Information section:
[INFO]
name=English
id=ENG
#
#Dictionary section:
[DICTIONARY]
# Format:
# [MyKey]=[Literal]
Test.ErrorMessage01=not file uploaded
Test.SavedMessage=%s saved!
Test.UploadedMessage=%s uploaded, you can click on 'send' button...


Now go to Menu -> Website -> Add New File, and select "Global Application Class". Open the Global.asax file:

You can do this:
...
    void Application_Start(object sender, EventArgs e) 
    {
        // Code that runs on application startup
        Application["Language"] = new Framework.Ajax.Language(Server.MapPath("english.language"));
    }
...

Or this:
...
    void Session_Start(object sender, EventArgs e) 
    {
        // Code that runs when a new session is started
        Session["Language"] = new Framework.Ajax.Language(Server.MapPath("english.language"));
    }
...

Edit Contained1.aspx.cs:
public partial class Contained1 : Framework.Ajax.UI.ContainedPage
{
...
    protected void btnSubmit_ServerClick(AjaxControl sender, string value)
    {
        System.Web.HttpPostedFile file = btnFile.File;
        if (!chkTest.Checked)
            return;

        if (file == null)
            DocumentAlert(lang["Test.ErrorMessage01"]);
        else
        {
            DocumentAlert(lang["Test.SavedMessage"].Replace("%s", file.FileName));
        }
    }
    protected void btnFile_ServerComplete(AjaxControl sender, string value)
    {
        DocumentAlert(lang["Test.UploadedMessage"].Replace("%s", value));
        btnSubmit.Disabled = false;
    }
}

Last edited Feb 5, 2010 at 2:28 PM by fescolar, version 2

Comments

No comments yet.