Multi-language support in SharePoint programs

Source: Internet
Author: User

The other day, kaneboy wrote a blog about SharePoint UI multi-language support: SharePoint 2010 multi-language UI and what developers need to pay attention to. this article provides some supplements and improvements to this blog.

Tu Zong's blog mainly introduces the multilingual settings about the list name, field name, and other content.ProgramWhen creating a list/field, in order to support multiple languages, the xxxresource attribute should be used to replace the xxx attribute (for example, titleresource instead of the title ). In fact, if we directly create this list/Field on the website, for example, in a Chinese website (default language), we create a field named "QQ number; when we switch to another language (such as English), we directly change this field to "QQ number", which does not overwrite the name of the Chinese language, instead, it only changes the field name settings in the current language. In this way, we can also use different names for the same field in different language environments.

Note that if we set "Overwrite translation" to "yes" in website settings-language settings, once we change the field name in the website of the default language, it overwrites the name setting of the website of other languages. We need to switch the language and set it again. See:

The following describes some object models related to SharePoint and multilingual programming.

1. How can I obtain some default texts in a website in different languages?

By using the static method getstring of spresouce, this method has two kinds of overloading:

1: Public Static StringGetstring (StringName,ParamsObject [] values );
 
2: Public Static StringGetstring (cultureinfo culture,StringName,ParamsObject [] values );

The first method is to obtain the specified string in the current language, and the second method is to obtain the specified string in the specified language (through the first parameter ).

The second parameter is the name of the resource string. For example, "languagenameinlocalizedlanguage" is the language in use. If the environment is simplified Chinese, the "Chinese-simplified" is obtained. if the environment is English, the obtained result is "English ".

The third parameter is the value used. If the string in the second parameter contains placeholders such as {0} and {1}, specify the specific values of these placeholders in the third parameter.

2. How do I know which language packs are installed on the server?

You can obtain the following two methods:

 
1:Spregionalsettings. installedlanguages;
 
2:Spregionalsettings. globalinstalledlanguages;

First, you must obtain a spregionalsettings object. You can use the regionalsettings attribute of spweb or directly use spcontext. Current. regionalsettings. Second, you can use a static attribute of spregionalsettings.

Both methods return objects of the splanguagecollection type. The lcid and display name of the language can be obtained by specifying the lcid and displayname attributes in the splanguage, the display name seems to be the display name in the default language and will not change with the current environment language)

3. How do I know the languages that the current website can use?

In website settings-language settings, you can select the language available for the current website, including the default language and the alternative language (if the corresponding alternative language is not selected here, even if the Language Pack is installed, it cannot be used on the website ).

You can use the supporteduicultures attribute of spweb to obtain the language available for the current website. This attribute is an ienumerable <cultureinfo> type object. Note that this attribute is unavailable in the sandbox solution.

4. How do I know the default website language?

In the background program, you can use the language attribute (INT type) of spweb to obtain the lcid of the default language.

In the front-end JavaScript program, you can obtain this lcid through _ sppagecontextinfo. weblanguage.

5. How do I know which language is being used on the current website?

In the background program, you can use thread. currentthread. currentuiculture to obtain the language and region settings of the current environment.

In the front-end JavaScript program, you can get the lcid of the current language through the variable g_wsalcid or _ sppagecontextinfo. currentlanguage.

 

In this case, how does a Sharepoint website support multiple languages?

One way is to use variants (only available in the server version) from 2007, which is to create an independent website for each language.

Another method is the addition of 2010, which supports multiple languages on the same website (also described above ). In this way, the website title, description, list title, description, field title, description, navigation node, and managed metadata are supported in multiple languages. If you want to make the content of a common list field support multiple languages (display different values in different language Environments), you need to develop a custom field type (in 2010, only the hosted metadata field type is supported by multiple languages. It is a single-line multi-language text developed:

Edit screen:

Display in Chinese:

Display in English:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.