1

Where does the largegalleryButton picks the value from ?

In other words how do i customize it ?

from where does it pick the value denmark from as in the screenshot?

enter image description here

6

It's the command Sitecore.Shell.Framework.Commands.Ribbon.Languages which has GetIcon method.

<command name="ribbon:languages"
    type="Sitecore.Shell.Framework.Commands.Ribbon.Languages,Sitecore.Kernel"/>

Code for icon:

public override string GetIcon(CommandContext context, string icon)
{
  Assert.ArgumentNotNull((object) context, nameof (context));
  Assert.ArgumentNotNullOrEmpty(icon, nameof (icon));
  if (context.Items.Length == 1)
  {
    Item obj = context.Items[0];
    string icon1 = LanguageService.GetIcon(obj.Language, obj.Database);
    if (!string.IsNullOrEmpty(icon1))
      return icon1;
  }
  return base.GetIcon(context, icon);
}

And header text:

public override string GetHeader(CommandContext context, string header)
{
  Assert.ArgumentNotNull((object) context, nameof (context));
  Assert.ArgumentNotNull((object) header, nameof (header));
  if (context.Items.Length == 1)
  {
    CultureInfo cultureInfo = context.Items[0].Language.CultureInfo;
    if (cultureInfo.IsNeutralCulture)
      cultureInfo = Language.CreateSpecificCulture(cultureInfo.Name);
    using (new ThreadCultureSwitcher(Context.Language.CultureInfo))
    {
      string displayName = cultureInfo.DisplayName;
      if (!string.IsNullOrEmpty(displayName))
        return displayName;
    }
  }
  return base.GetHeader(context, header);
}

enter image description here

0

If you are looking at the Language Name, then it should be from the

System.Globalization.CultureInfo.GetCultureInfo.DisplayName
0

I think what you looking for is to display the name of the foreign language in the native language. For that, instead of using DisplayName you have to NativeName in the method.

var culture = Thread.CurrentThread.CurrentCulture.NativeName;

So you need to override the standard implementation with your custom one. One of the way could be to make a copy of Sitecore.Shell.Framework.Commands.Ribbon.Languages command and update the method GetHeader to display NativeName, update your config file and Sitecore Item to point towards the new method and you should be good.

public override string GetHeader(CommandContext context, string header) { Assert.ArgumentNotNull((object) context, nameof (context)); Assert.ArgumentNotNull((object) header, nameof (header)); if (context.Items.Length == 1) { CultureInfo cultureInfo = context.Items[0].Language.CultureInfo; if (cultureInfo.IsNeutralCulture) cultureInfo = Language.CreateSpecificCulture(cultureInfo.Name); using (new ThreadCultureSwitcher(Context.Language.CultureInfo)) { string displayName = cultureInfo.NativeName;//change this line if (!string.IsNullOrEmpty(displayName)) return displayName; } } return base.GetIcon(context, header); }

As default, Sitecore uses ASP.NET globalization ISO code and language names . The Sitecore predefined languages are coming from the configuration file located at /App_Config/LanguageDefinitions.config.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.