Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1554
  • Last Modified:

Creating a dual language web site.

Hi experts,

I am creating a web site for a large company and they want the user to choose either Greek or English. I do know about asp.net localization etc but the content is coming from a database and is not static content.

At the moment my database tables are like this.

page_id, page_id_en, page_id_el

And i wanto draw out the information based on user selection. At the moment i am using cookies so when the user selects greek it will get the greek content. I think cookies are o.k but obviously some users turn them off.

What is the best way to achieve this ? is it cookies or something else? i know microsofts web sites are like this www.microsoft.com/FR/thispage etc.. is this a good way?
0
thomasmutton
Asked:
thomasmutton
  • 6
  • 3
  • 3
2 Solutions
 
Type25Commented:
I would recommend you still use localization which is built in to .NET.

have a look here:

http://msdn2.microsoft.com/en-us/library/aa905797.aspx

which will show you how to still store your localized strings a db
0
 
thomasmuttonAuthor Commented:
thankyou, i will look at that link and get back to you..
0
 
thomasmuttonAuthor Commented:
O.k i understand that. So basically what I should do is have the web site in 2 sections. one for /en and one for /el . That makes sense to me but before i accept your answer i would like to hear other peoples suggestions. thankyou.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
jinn_hnnlCommented:
I wouldn't recommend you to use localization. It is a nice feature of MS VS but it does almost nothing special except saving your time. But it will mess your code up and you will so much depend on the local file.

Take a look at this:
http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_22488914.html

This is the idea, writen in VB. I hope even if you using C# you still can get proper view of this code. Otherwise feel free to ask.

In your case, you will have to deal with 2 different language so you might find it easy implementing it in both way. But if there are more languages required. Localization files will be a nightmare (I have tried it out).

Jinni ^^

0
 
jinn_hnnlCommented:
SOrry I need to express more of your case:

For label or another appearance texts on your site, you can use the language class like in the example. And to display information upon the database (column page_id_en, page_id_el) It is even easier I guess.

<"So basically what I should do is have the web site in 2 sections. one for /en and one for /el ">

Just load your page upon your language setting. If you want to use the session. Take care of the expiration time of the session. Or you can use Application[] (similar with session).

Hope this helps
0
 
thomasmuttonAuthor Commented:
I was thinking of using sessions actually. The web site is by default greek and on the header it has 2 links

"Greek / English" So when the user clicks english, my external class will return "en"

        HttpContext context = HttpContext.Current;

        string strLanguage = context.Request.Cookies["userInfo"]["userLang"].ToString();
        string strGreek = "el";
        string strEnglish = "en";

        if (strLanguage != null)
        {
            if (strLanguage == "English")
            {
                return strEnglish;
               
            }
            else if (strLanguage == "Greek")
            {
                return strGreek;
               
            }
        }
        else if (strLanguage == null)
        {
            return strGreek;
        }


so on the database code i just say
Convert.ToString(objData["Product_Image_" + LanguageSelection.GetLanguage()]);

I know this all works its just i didnt wanto use cookies because people have them disabled and sessions  (in my use of them) expired quite quickly.

So do you think sessions are the likely solution to this? because i dont really want to have 2 folders, 1 for each language, it will make it hard to update the code.. I think if i can find out how to prolong the sessions for lets say 1 or 2 hours that would be great.
0
 
Type25Commented:
You can set the session timeout in IIS.
0
 
thomasmuttonAuthor Commented:
ok, i will look into this. Is it possible to set the session timeout for a particular session in the code behind.
0
 
Type25Commented:
I believe the lowest level you can go is the web.config.

0
 
thomasmuttonAuthor Commented:
O.k well thankyou both for your help. :)
0
 
jinn_hnnlCommented:
Of course you can set session time out in the Web.Configure file easily. You definitely don't  have to use 2 different folders for it. It should be dynamic.

A lot of way to simply archive the current language selection of user (by cookies, session, or application).
WIth application you don't  have to bother about the time out.

You don't  even need class for such thing cause you can just have to set:

Application["Language"] = "English";
or Session["Language"] = "English";
Everytime user click on the English Flag

And when you need to load something,  you just need to pass the language as paramater:

Assume you have

LoadWelcomepageContent(string language)
{
    ... load from database
}

Then call it in PageLoad for example:

LoadWelcomepageContent( Application["Language"].ToString());

Hope this helps,

JINNI
0
 
thomasmuttonAuthor Commented:
I see, but i read in my asp.net book that application state can be "viewed by any client". The application state  is only really good for a hit counter for instance.

But yes, i will use sessions. thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 6
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now