How to create a 2 languages web site? Thank You.

S

Shapper

Hello,

I am working on an ASP.NET / VB web site and I need to have 2 versions:
In English and French.

I could create two versions of the web site by duplicating all the
pages. Is that the right way?

All my contents come from a database so I can duplicate the the fields
so I can have 2 language content.

I also have a "French Version" or an "English Version" button in my
page. It should show only one.

Thank You,
Miguel
 
T

TDAVISJR

There is another method that seems to be much simpler. Doing it all with
user controls and dynamically loading them at runtime. This is the baisc
concept. You have 2 languages say english and french. You will have the
directory structure of:

MyWebsite
en (text in english)
header.ascx
|_ header.ascx.vb
content.ascx
|_ content.ascx.vb
footer.ascx
|_ footer.ascx.vb

fr (text in french)
header.ascx
content.ascx
footer.ascx

default.aspx
contentpage1.aspx

So, in the default.aspx you can ask the user which language they want. Then
store their language either in a persistant cookie or in a session variable.
Depending on what language they choose, dynamically load the user controls
from the folders that has the english or french in the contentpage1.aspx
page. One thing to note. Only the en foder will have the ascx file and the
ascx.vb codebehind file all the other languages will just have the ascx
file. The idea is that each of the usercontrols under each language folder
will have the EXACT same server contols or controls with the EXACT same name
in the ascx file. So, in the @Control directive at the top of the
usercontrol in source view you can tell it that it inherits from the ascx.vb
files located under the english folder. I guess its more to it than that
but this is a very easy way to get going if you need a more simpler
approach.
 
J

Juan T. Llibre

That's simpler ? ( Only half-kidding... )

If you're going to go that way, you don't even have to
store the language preference to get the job done.

Just redirecting to the appropiate language directory
will suffice, if you use relative URLs in the app.

I think the idea is to *avoid* having a duplicated directory
for each and every language you use, since that becomes
quite unmanageable, fast, as you add languages.

A slightly different approach would be to use XML files,
or database tables, for the different language contents.

It would be like creating a different "skin" for each language.

That's much easier to manage, from a data storage point of view.

I'd rather have a different XML file with all the localized strings,
or a different database column with all the localized strings,
than having different files, ascx controls, etc. for each language.
 
L

Lucas Tam

There is another method that seems to be much simpler. Doing it all
with user controls and dynamically loading them at runtime. This is
the baisc concept. You have 2 languages say english and french. You
will have the directory structure of:

It maybe simpler to build, but maintaince would be a nightmare. You have 2x
the amount of code to fix.

Image if you had to do a site redesign... You'll have to edit 2 sets of
tempaltes ; )
 
S

Shapper

Hello,

I have been reading all the help you sent me.

According to language I have to distinguish the following:
1. Menu Images Buttons.
2. Content from Database (Note. All the content is taken from a
database)
3. Other elements like input text box labels.

The solution I came up:
1. Images
I will create N folders the following way:
images/culture/... (Example: images/en-us)

And a common folder such as:
images/common/...

2. Database
I will have fields for each culture.
Example: (title_en-us) and (title_pt-pt)

3. For elements like input text box labels I can even create a small
function with cases which uses one text label or the other.
Or I can place the entire content in the database.

What do you think about this?

I am working in ASP.NET/VB and with Web Matrix.
I have 1 button in my web site which can show "French Version" or
"English Version". I know that I could set a cookie, URL parameter or
Session variable to set which version the user is using.

However I think this must be done in other way. This is what I don't
understand very well in the documents I read until now.

How can I determine which culture the user is using, how can I get it's
value in my page and how can I change when I user clicks a button?

Thanks,
Miguel
 
S

Shapper

Hi Again,

As far as I can see in the global.asax I can set:
1. Set the culture based on browser
2. Set a default culture

But how to I get the info in a page in which a culture is used?

Cheers,
Miguel
 
T

TDAVISJR

Try looking at the Request.UserLanguages property. Here is the link

http://msdn.microsoft.com/library/d...rlrfsystemwebhttprequestclassbrowsertopic.asp

The property returns a string array of user languages preferences set in the
browser. To obtain the primary preference, I guess you can do something
like this:

Dim userLanguages as String() = Request.UserLanguages
Dim primaryLanguage = userLanguage(0).ToString()

I have not tested; but I have to you the link to the Documentation. I hope
this helps.





--
TDAVISJR
aka - Tampa.NET Koder


Shapper said:
Hi Again,

As far as I can see in the global.asax I can set:
1. Set the culture based on browser
2. Set a default culture

But how to I get the info in a page in which a culture is used?

Cheers,
Miguel
 
T

TDAVISJR

CODE CORRECTION:

Dim primaryLanguage = userLanguages(0).ToString()

forgot the s on userLanguages


--
TDAVISJR
aka - Tampa.NET Koder


TDAVISJR said:
Try looking at the Request.UserLanguages property. Here is the link

http://msdn.microsoft.com/library/d...rlrfsystemwebhttprequestclassbrowsertopic.asp

The property returns a string array of user languages preferences set in
the browser. To obtain the primary preference, I guess you can do
something like this:

Dim userLanguages as String() = Request.UserLanguages
Dim primaryLanguage = userLanguage(0).ToString()

I have not tested; but I have to you the link to the Documentation. I
hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top