About Me

My photo
a Dynamic and Energetic guy.....

Monday, August 8, 2011

Localization in SharePoint

It was a horrible week for me, because of a too critical task, i.e.LOCALIZATION

Finally i was able to do it :) :) :)

*** Added "ChanaApp.resx" to App_GlobalResources folder in [Port] folder
*** Added "ChanaApp.nl.resx" to same folder
*** Added a label to .ASPX page
*** Set the Expression of the label, set the TEXT property using "Resources"

*** If only one page we can use
 protected override void InitializeCulture()
        {
            string[] languages = HttpContext.Current.Request.UserLanguages;
            string language = languages[0].ToLowerInvariant().Trim();

            string selectedLanguage = language;
            Thread.CurrentThread.CurrentCulture =
                CultureInfo.CreateSpecificCulture(selectedLanguage);
            Thread.CurrentThread.CurrentUICulture = new
                CultureInfo(selectedLanguage);
            base.InitializeCulture();
        }

*** If for total web application then we have to use
protected void Application_BeginRequest(object sender, EventArgs e)
        {
            string[] languages = HttpContext.Current.Request.UserLanguages;
            string language = languages[0].ToLowerInvariant().Trim();
            string selectedLanguage = language;
            Thread.CurrentThread.CurrentCulture =
                CultureInfo.CreateSpecificCulture(selectedLanguage);
            Thread.CurrentThread.CurrentUICulture = new
                CultureInfo(selectedLanguage);
        }
in GLOBAL.ASAX file.
*** Change the Culture of browser will change the TEXT in the label

No comments:

My Masters