On Thu, 29 Jul 2004 14:51:39 -0400, "Eric Sabine" <mopar41@hyotyt_mail_nounderscores.com> wrote:
I have a web site that needs to exist in English and German. I certainly
could write it twice in both languages (one page for each language), but
what is the preferred method for multiple languages? I could be required
later to add a few more.
Thanks,
Eric
Make all your text into labels. and then use a business layer class to read from the proper resx to fill out the label.text. Here is an
example of a localization class.
public class L10n
{
private static ResourceManager resourceManager = new ResourceManager("Business.L10n", Assembly.GetExecutingAssembly());
private static CultureInfo ci;
static L10n()
{
ci = GetCurrentCulture();
}
public static string GetString(string key)
{
resourceManager.IgnoreCase = true;
string text = resourceManager.GetString(key, ci);
if (text == null)
{
text = "String not found";
}
return text;
}
public static CultureInfo GetCurrentCulture()
{
string language = GetCurrentLanguageSetting();
switch (language.ToUpper())
{
default:
case "ENU":
return new CultureInfo("en-us");
case "CHS":
return new CultureInfo("zh-CN");
case "CHT":
return new CultureInfo("zh-TW");
case "FRA":
return new CultureInfo("fr-FR");
case "DEU":
return new CultureInfo("de-DE");
case "ITA":
return new CultureInfo("it-IT");
case "JPN":
return new CultureInfo("ja-JP");
case "PTB":
return new CultureInfo("pt-BR");
case "ESP":
return new CultureInfo("es-ES");
}
}
}
Bobby Ryzhy
bobby @ domain below
http://weekendtech.net