469,572 Members | 1,287 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,572 developers. It's quick & easy.

Multiple-lanugage support in ASP.NET question

I know there is Culture feature with Asp.net, but what I want to know is
how to organize/design a web application that supports multiple languages.
What is the best approach? Do I use "If, then.." to display one block of
HTML in English, and then another block in French? Is there an easy way?

Also, "string" itself doesn't support multiple cultures, right? If I
write a "string" property in a class, how do I make the property support
multiple cultures?
Nov 19 '05 #1
3 1207
I will break this down into two parts :

- fixed strings for the UI could be taken from resources files. .NET
provides support for this. You could also take those values from a DB
(likely cached) or some other location in particular if translation should
be updatable "live" by someone... You'll have support for this in .NET 2.0.
See the doc for "resources".

- I'm not really sure about what you meant by the second part. If you meant
by the "property", a "data" entered by the user there is little you can do.
Either the application insulates each group of users (for example the app
manages multiple projects using each an official language). If not, the data
model for your application will have to make provision so that users are
able to entered a localized version for each of their "data"...

Patrice
--

"00_CuMPe3WaR3D12" <00**************@yahoo.com> a écrit dans le message de
news:pd********************@rogers.com...
I know there is Culture feature with Asp.net, but what I want to know is
how to organize/design a web application that supports multiple languages.
What is the best approach? Do I use "If, then.." to display one block of
HTML in English, and then another block in French? Is there an easy way?

Also, "string" itself doesn't support multiple cultures, right? If I
write a "string" property in a class, how do I make the property support
multiple cultures?

Nov 19 '05 #2
Tim
Hello,
This is a huge field (almost like saying "how do I make my ASP.Net app
secure?), but here are some things to get you started:
Your best bet may be to use Resource files. These are xml files of
name-value pairs that contain all the text-strings. The current culture of
the app then automatically picks which file to use.

Check out the Globalization Namespace
http://msdn.microsoft.com/library/de...balization.asp

Here are some tutorials to get you started:
http://samples.gotdotnet.com/quickstart/aspplus
http://msdn.microsoft.com/library/de...balization.asp
Also, "string" itself doesn't support multiple cultures, right? If I
write a "string" property in a class, how do I make the property support
multiple cultures? Depends. If your string just returns values from the Database, then you
don't need to do anything.
If it returns something that included concentation, dates, or currency
formats, then you'll need to pass the object the current culture, and send
that into the ToString() method used to generate the strings for your
property.

HTH,
Tim
http://timstall.dotnetdevelopersjournal.com/

"00_CuMPe3WaR3D12" wrote:
I know there is Culture feature with Asp.net, but what I want to know is
how to organize/design a web application that supports multiple languages.
What is the best approach? Do I use "If, then.." to display one block of
HTML in English, and then another block in French? Is there an easy way?

Also, "string" itself doesn't support multiple cultures, right? If I
write a "string" property in a class, how do I make the property support
multiple cultures?

Nov 19 '05 #3
Thanks for the "resources", I will look into that.

For Property.. this is what I meant, for example I am creating a Person
class:

public class Person
{
private string _FirstName;

public FirstName(string myFirstName)
{
_FirstName = myFirstName;
}
}

In ASP.NET, string, by default doesn't support multi-languages.

Person myPerson = new Person();
myPerson.FirstName("John");

// I want to do something like this:
myPerson.FirstName("Le John", new CultureInfo("fr-FR"));
myPerson.FirstName("John", new CultureInfo("en-US"));
My solution is to implement this by using Hash Table and Methods (not using
Properties), by putting CultureInfo name as the key of hashtable. It works,
but not sure if that's the best way. What do you think? Does ASP.NET has a
better way?

public class FirstName
{
private Hashtable _FirstName = new Hashtable();

public string GetFirstName(CultureInfo myCulture)
{
return _FirstName[myCulture.Name].ToString();
}

public void SetFirstName(string myFirstName, CultureInfo myCulture)
{
_FirstName[myCulture.Name] = myFirstName;
}
}
C.P.


"Patrice" <no****@nowhere.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I will break this down into two parts :

- fixed strings for the UI could be taken from resources files. .NET
provides support for this. You could also take those values from a DB
(likely cached) or some other location in particular if translation should
be updatable "live" by someone... You'll have support for this in .NET 2.0. See the doc for "resources".

- I'm not really sure about what you meant by the second part. If you meant by the "property", a "data" entered by the user there is little you can do. Either the application insulates each group of users (for example the app
manages multiple projects using each an official language). If not, the data model for your application will have to make provision so that users are
able to entered a localized version for each of their "data"...

Patrice
--

"00_CuMPe3WaR3D12" <00**************@yahoo.com> a écrit dans le message de
news:pd********************@rogers.com...
I know there is Culture feature with Asp.net, but what I want to know is how to organize/design a web application that supports multiple languages. What is the best approach? Do I use "If, then.." to display one block of HTML in English, and then another block in French? Is there an easy way?

Also, "string" itself doesn't support multiple cultures, right? If I
write a "string" property in a class, how do I make the property support
multiple cultures?


Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Rolf Wester | last post: by
66 posts views Thread by Darren Dale | last post: by
5 posts views Thread by Morgan Cheng | last post: by
6 posts views Thread by Ben Hallert | last post: by
5 posts views Thread by Neelesh Bodas | last post: by
2 posts views Thread by areef.islam | last post: by
1 post views Thread by abhishekhs | last post: by
35 posts views Thread by keerthyragavendran | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.