예제 #1
0
 internal static void LocalizeNavigationNode(this Microsoft.SharePoint.Client.NavigationNode navigationNode, Web web, string token, TokenParser parser, PnPMonitoredScope scope)
 {
     if (CanUseAcceptLanguageHeaderForLocalization(web))
     {
         web.EnsureProperties(w => w.Language, w => w.IsMultilingual, w => w.SupportedUILanguageIds);
         if (web.IsMultilingual)
         {
             var context        = web.Context;
             var resourceValues = parser.GetResourceTokenResourceValues(token);
             foreach (var resourceValue in resourceValues)
             {
                 var translationculture = new CultureInfo(resourceValue.Item1);
                 if (web.SupportedUILanguageIds.Contains(translationculture.LCID))
                 {
                     // Save property with correct locale on the request to make it stick
                     // http://sadomovalex.blogspot.no/2015/09/localize-web-part-titles-via-client.html
                     context.PendingRequest.RequestExecutor.WebRequest.Headers["Accept-Language"] = resourceValue.Item1;
                     navigationNode.Title = resourceValue.Item2;
                     navigationNode.Update();
                     context.ExecuteQueryRetry();
                 }
             }
         }
         else
         {
             scope.LogWarning(CoreResources.Provisioning_Extensions_NavigationLocalization_NoMUI_Skip);
         }
     }
     else
     {
         // warning
         scope.LogWarning(CoreResources.Provisioning_Extensions_NavigationLocalization_Skip);
     }
 }
 internal static void LocalizeNavigationNode(this Microsoft.SharePoint.Client.NavigationNode navigationNode, Web web, string token, TokenParser parser, PnPMonitoredScope scope)
 {
     if (CanUseAcceptLanguageHeaderForLocalization(web))
     {
         web.EnsureProperties(w => w.Language, w => w.IsMultilingual, w => w.SupportedUILanguageIds);
         if (web.IsMultilingual)
         {
             var context        = web.Context;
             var resourceValues = parser.GetResourceTokenResourceValues(token);
             foreach (var resourceValue in resourceValues)
             {
                 var translationculture = new CultureInfo(resourceValue.Item1);
                 if (web.SupportedUILanguageIds.Contains(translationculture.LCID))
                 {
                     navigationNode.TitleResource.SetValueForUICulture(resourceValue.Item1, resourceValue.Item2);
                     navigationNode.Update();
                     context.ExecuteQueryRetry();
                 }
             }
         }
         else
         {
             scope.LogWarning(CoreResources.Provisioning_Extensions_NavigationLocalization_NoMUI_Skip);
         }
     }
     else
     {
         // warning
         scope.LogWarning(CoreResources.Provisioning_Extensions_NavigationLocalization_Skip);
     }
 }