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 am new to SharePoint. I am creating a custom application page (small registration form). I want to give users a facility to change language of the registration form. Is this functionality is provided by SharePoint ? Or i have to write code for this this ?

share|improve this question
add comment

3 Answers 3

up vote 1 down vote accepted

You can use Resource (.resx) files that hold the text of the interface, one for each language, and call the resources from within your Application Page markup.

For example, you will need the base resource file, let us call it SpResources.resx which contains the default value.

Then, for each language you with to support, create another resource file, following the following naming convention: SpResources. + LanguageCode + .resx. e.g. SpResources.en-US.resx.

This will involve some repetitive calls in the code-behind, imagining you have a Label field called lblName in the ASPX and wanted to populate it with the value stored in SP_Resources_Name in your resource file, you would need to call the following line:

lblName.Text = SPUtility.GetLocalizedString("$Resources:SpResources,SP_Resources_Name", "$Resources:SpResources", SPContext.Current.Web.Language);

You'd need to call this somewhere in the Page_Load method, or a method called by that, and do similarly for each control you want to localise.

share|improve this answer
    
Ok! I need some more clarification. 1. SpResources is the name of resource file, right ? But what is this SP_Resource_Name ? –  SPBeginer Dec 10 '12 at 15:18
    
In that example, SP_Resources_Name is the key of the value in the resources file. –  TZHX Dec 10 '12 at 15:34
add comment

For Label Control for example, we can do like this:

<'asp:Label ID="Label2" runat="server" Text="<%$Resources:SomeResources,String1 %>"><'/asp:Label>

where SomeResources is the resource file name and String1 is the Key of the value in resource file

share|improve this answer
add comment

You can use resource files to allow our custom application page to be available when users switch languages. Check a very good example on how to do it

But just make sure SharePoint 2010 installation has different language packs deploy. It can easily be checked If you jump into Site Actions > Site Settings you should have a link under the ‘Site Administration’ heading for ‘Language settings’.

enter image description here

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.