Sometimes, when using Web services, we will inevitably use the Region ID of the SharePoint website. For example, Update values to the list based on different languages. Or call the background application page for different languages.
If hard-coded LCID into the code, it will obviously limit the scope of use of our program. It is not in line with our professionalism. Then how can we get LCID through SharePoint Web Service?
In fact, it is not difficult at all.
sitedataservice.SiteData sd;
sd = new sitedataservice.SiteData();
sd.Url = baseUrl + "/_vti_bin/sitedata.asmx";
sd.Credentials = System.Net.CredentialCache.DefaultCredentials;
sitedataservice._sWebMetadata webMetaData;
sitedataservice._sWebWithTime[] arrWebWithTime;
sitedataservice._sListWithTime[] arrListWithTime;
sitedataservice._sFPUrl[] arrUrls;
string roles; string[] roleUsers; string[] roleGroups;
uint i = sd.GetWeb(out webMetaData, out arrWebWithTime, out arrListWithTime, out arrUrls, out roles, out roleUsers, out roleGroups);
uint lcid = webMetaData.Language;
The key is:
1. Call SiteData. asmx provided by SharePoint
2. WebMetadata contains the LCID we need (there is a lot of useful information for us, such as Web ID, user, etc)
3. For websites with standby languages, you can see that someone uses the method of reading the Title of the list that comes with SharePoint. For example, "calendar ". If it is "Calendar", it is Chinese; if it is "Calendar", it is English. This is also a solution to this multilingual website.
References
Understanding the Multilingual User Interface (MUI)
How to get current Sharepoint site LCID in silverlight web part