e.g. my user account has set English as default display language

If you update web.title property trough the UI or via custom code, change your default display language to another language and load the site again, the web.title property won't be changed in this language.
You can use this piece of code to change the title property for all available languages of a site.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var ctx = new ClientContext(webUrl)) | |
{ | |
//get web and load required properties | |
var web = ctx.Web; | |
ctx.Load(web, w => w.SupportedUILanguageIds, w => w.TitleResource); | |
ctx.ExecuteQuery(); | |
//change site title for all supportedUILanguages. | |
var resource = web.TitleResource; | |
foreach (var culture in web.SupportedUILanguageIds) | |
{ | |
resource.SetValueForUICulture(new CultureInfo(culture).ToString(), newTitle); | |
} | |
web.Update(); | |
ctx.ExecuteQuery(); | |
} |
No comments:
Post a Comment