Transparent Localisation
public static string getGetSiteCulture()
{
string strUrl = System.Web.HttpContext.Current.Request.Url.ToString().ToLower();
string strCulture = "en-GB";
if (strUrl.IndexOf("mensajetexto")!=-1) {strCulture = "es-ES";}
if (strUrl.IndexOf("handyspruche")!=-1) {strCulture = "de-DE";}
if (strUrl.IndexOf("envoyezsms")!=-1){strCulture = "fr-FR";}
return strCulture;
}
Then I have 4 different Resource files, strings.es-ES.resx, strings.en-GB.resx etc.
public static string Translate(string ID)
{
rmTranslations.IgnoreCase =
true;
string strTranslation ="";
Thread.CurrentThread.CurrentCulture =
new CultureInfo(getGetSiteCulture());
Thread.CurrentThread.CurrentUICulture =
new CultureInfo(getGetSiteCulture());
try
{strTranslation= rmTranslations.GetString(ID);}
catch{
throw new Exception(ID + " not found");
}
return strTranslation;
}
Then in place of static text, I put Translations.Translate("Whatever")