Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have two Label Controls with text property as "Name" and "Company". I want to change the text of these two Controls into Swedish language. For this, I created resource (.resx) file named "MyResource" under mapped folder. How i use this resource file in SPUtility.GetLocalizedString() method ? Can anybody explain about all the parameters used in this method ? Need one example e.g, with "Name" label Control ?

share|improve this question
1  
The MSDN entry on the subject explains it quite completely. –  TZHX Dec 10 '12 at 15:42
add comment

1 Answer

You mean like this?

using (SPSite site = new SPSite("http://localhost"))
        {
            using (SPWeb web = site.RootWeb)
            {
                if (web.IsMultilingual)
                {
                    IEnumerable<CultureInfo> cultures = web.SupportedUICultures;
                    foreach (CultureInfo culture in cultures)
                    {
                        // Print the value of a language resource in the current language.
                        string str = "$Resources:onet_TeamWebSite";
                        string locStr = SPUtility.GetLocalizedString(str, 
                                                                     "core", 
                                                                     (uint)culture.LCID);

                        Console.WriteLine("{0}  {1}", culture.Name, locStr);
                    }
                }
            }
        }

Reference: SPUtility.GetLocalizedString method

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.