Forums

Skip Navigation LinksHome / Developer Network / Forums / Sitefinity Older Versions (3.x): General Discussions > Language entry is in lowercase

Language entry is in lowercase

  • Geoff avatar

    Posted on Dec 1, 2011 (permalink)

    Hi,
    I added support to our Sitefinity 3.7 site for spanish. by
    adding the "es" culture to the localization line in the web.config.
    The Language entry appears as:
    "español"

    We would like to see
    "Español"

    How can we achieve that?

    Cheers,
    Geoff

    Reply

  • Radoslav Georgiev Radoslav Georgiev admin's avatar

    Posted on Dec 6, 2011 (permalink)

    Hello Geoff,

    We take the culture names from .NET and .NET is passing the culture name with lower case letters. If you need to use capital E then you have to inherit from the language dropdonw list control override its Render method and instead of rendering the lower case culture name find it in the string to be rendered and replace the string. Then render.

    All the best,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

    Reply

  • Geoff avatar

    Posted on Dec 6, 2011 (permalink)

    Hi Radoslav,

    I was afraid you would say something like that.
    Just curious, does the same issue affect 4.x ?

    Cheers,
    Geoff

    Reply

  • Radoslav Georgiev Radoslav Georgiev admin's avatar

    Posted on Dec 9, 2011 (permalink)

    Hi Geoff,

    This behavior by design exists in Sitefinity 4.x also, however there it is much easier to change the language selector control.

    Kind regards,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

    Reply

  • Geoff avatar

    Posted on Dec 16, 2011 (permalink)

    Hi Radoslav,
    Do you have a very simple example of extending a control in this way?

    Cheers,
    Geoff

    Reply

  • Geoff avatar

    Posted on Jan 3, 2012 (permalink)

    Hi Radoslav,

    I am still wrestling with this problem. I am trying to
    follow your example of extending a control in the
    Sitefinity 3.x documentation which extends the ContentView
    control.

    As I understand it, Part 1 is not applicatble since the
    new language control will not have any new meta fields.

    In Part 2 I also added a reference for Telerik.Localizaion
    in order to be able to inheret from
    Telerik.Localization.WebControls.LanguageList

    Part 3 has me confused though. There are no control templates
    that I can find for the LanguageList control. Is a control
    template required in my case?

    In Part 4, I am overriding the RenderContents(HtmlTextWriter output)
    method. I presume I have to build and output the new Dropdown list?
    How do I obtain the list of cultures we specified in the web.config?

    Any hints would be most helpful.

    Cheers,
    Geoff

    Reply

  • Radoslav Georgiev Radoslav Georgiev admin's avatar

    Posted on Jan 4, 2012 (permalink)

    Hi,

    For Sitefinity 3.x you must extend the Language Selector control and not ContentView control. You can find a sample which uses flags instead of dropdown. The principle is similar.

    Regards,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

    Reply

  • Geoff avatar

    Posted on Jan 4, 2012 (permalink)

    Hi Radoslav,

    Thanks for that. I am making progress. I was able to implement
    the flags control and indeed was able to make the alt text first
    character always be upper case. However, I fail to understand
    how to make the control render a dropdownlist instead of the
    flags.

    In the LanguageFlagList.FillItems method the listItems are already
    Hyperlinks. How do I make the ListItems be dropdownlist entries ?

    Cheers,
    Geoff

    Reply

  • Geoff avatar

    Posted on Jan 9, 2012 (permalink)

    Hi Guys,

    This is weird -according the thread statistics it looks like you posted a reply
    about 6 hours ago, but it does not show up here. Was there a forum glitch? Can
    you repost you response?

    Cheers,
    Geoff

    Reply

  • Answer Radoslav Georgiev Radoslav Georgiev admin's avatar

    Posted on Jan 12, 2012 (permalink)

    Hello,

    Substitute the built in LanguageBar control in the web.config with this custom one:
    /// <summary>
    /// This class inherits from LanguageList to extend it and add ImageUrls to the hyperlinks.
    /// It is used by LanguageBar to render the contents of the language selector control.
    /// </summary>
    public class CustomLanguageBar : LanguageBar
    {
        protected override void CreateChildControls()
        {
            this.Controls.Clear();
     
            this.container = new Container(this);
     
            string name = String.IsNullOrEmpty(this.ProviderName)
                ? ConfigHelper.Handler.DefaultProvider : this.ProviderName;
            if (this.provider == null || this.provider.Name != name)
                if (!LocalizationManager.Providers.TryGetValue(name, out this.provider))
                    throw new InvalidOperationException(Messages.InvalidProviderName);
     
            if (this.template == null)
                this.template = new DefaultTemplate();
            this.template.InstantiateIn(this.container);
     
            CultureInfo currNeu = LocalizationManager.GetNeutralCulture(CultureInfo.CurrentUICulture);
     
            this.container.LanguageList.AutoPostBack = false;
            if (this.container.LanguageList is LanguageList)
                ((LanguageList)this.container.LanguageList).SelectedLanguages = this.SelectedLanguages;
     
            int i = 0;
            foreach (CultureInfo info in LocalizationManager.Cultures.Values)
            {
                ListItem item = new ListItem(UppercaseFirst(info.NativeName), LocalizationManager.GetMappingKey(info.Name));
                if (info.Equals(currNeu) || info.Equals(CultureInfo.CurrentUICulture))
                    this.selectedIndex = i;
                this.container.LanguageList.Items.Add(item);
                i++;
            }
     
            this.Controls.Add(this.container);
        }
     
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            this.container.LanguageList.SelectedIndex = this.selectedIndex;
        }
     
        private string UppercaseFirst(string s)
        {
            // Check for empty string.
            if (string.IsNullOrEmpty(s))
            {
                return string.Empty;
            }
            // Return char and concat substring.
            return char.ToUpper(s[0]) + s.Substring(1);
        }
     
        #region Containers
     
        private class Container : GenericContainer<CustomLanguageBar>
        {
            public Container(CustomLanguageBar owner)
                : base(owner)
            {
            }
     
            public ListControl LanguageList
            {
                get
                {
                    if (this.languageList == null)
                        this.languageList = base.FindRequiredControl<ListControl>("languageList");
                    return this.languageList;
                }
            }
     
            private ListControl languageList;
        }
     
        #endregion
     
     
        #region Private Fields
     
        private ITemplate template;
        private Container container;
        private LocalizationProvider provider;
        private int selectedIndex;
     
        #endregion
     
        #region Templates
     
        private class DefaultTemplate : ITemplate
        {
            public void InstantiateIn(Control container)
            {
                DropDownList list = new DropDownList();
                list.CssClass = "cmsLangDropDown";
                list.ID = "languageList";
                container.Controls.Add(list);
            }
        }
     
        #endregion
    }


    Kind regards,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

    Reply

  • Geoff avatar

    Posted on Jan 12, 2012 (permalink)

    Hi Radislav,

    Wow. That'll work. -Thanks a lot!

    Cheers,
    Geoff

    Reply

  • Register for webinar
Skip Navigation LinksHome / Developer Network / Forums / Sitefinity Older Versions (3.x): General Discussions > Language entry is in lowercase