Home > Uncategorized > Transparent Localisation

Transparent Localisation

I’ve just launched one website, in four different languages all in the same path, with the same files & database under IIS.
    www.sms-txt.co.uk (english)
   www.handyspruche.com (german)
   www.envoyezsms.com (french)
  www.mensajetexto.com (Spanish).
 
How did I do it?
 

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")

 
Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s