문제

I'm building a system that uses SharePoint lists to present forms to our website visitors, and these visitors can select a language preference for our website, so the form should be presented in that language. When I create my list, I'm specifying columns like "firstname" and "email", which of courses uses these as field labels on the form. I'd like to change "firstname" to be "Prénom" and "Adresse E-mail" when the form is viewed in French.

Is there a way that can I add C# code to a custom form for this list, so that I can locate and change the field labels?

If I had a text file (or something similar) could this be done with JavaScript instead? The preference is C#, as I already have code that gets the translations from another list, but if I have to use a non-C# method, than that might be OK.

Cheers

도움이 되었습니까?

해결책

As I understand by Tag you use your custom form. If you can invoke methods into code behind you can try to use SPUtility.GetLocalizedString Method

string str = "$Resources:onet_TeamWebSite";
string locStr = SPUtility.GetLocalizedString(str, "core", (uint)culture.LCID);

For more info see this post.

If you use you custom list definishion you can try to localize fields by $Resources methods.

<Field ID="{fcc46300-de6e-481e-ac2c-5bc369946712}"
     Name="SubmittedBy"
     DisplayName="$Resources:SubmittedBy"
     Type="User" List="UserInfo" ShowField="NameWithPicture"
     UserSelectionMode="PeopleOnly" UserSelectionScope="0"
     Required="TRUE" />

For more info see this post

다른 팁

For this answer to help you'll need to be able to access the chosen language using javascript. If the language that has been chosen by the user is in the querystring, check out this post.

By adding a Content Editor Web Part to the form and referencing an HTML file that contains the necessary javascript / jquery, the NewForm.aspx labels can be updated. If you're new to working with jQuery in SharePoint, this blog shows how to setup this solution.

You could use this JQuery selector to find the email label and set it to the French version:

$('td.ms-formlabel h3.ms-standardheader nobr:contains("email")').text('Adresse E-mail');

If you haven't used it before, check out Internet Explorer Developer Tools. It will help you when writing other jQuery selectors (try hitting the F12 key when IE is open).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top