+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Language entry is in lowercase

Language entry is in lowercase

11 posts, 1 answered
  1. Geoff
    Geoff avatar
    25 posts
    Registered:
    17 Jul 2009
    02 Dec 2011
    Link to this post
    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
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    06 Dec 2011
    Link to this post
    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
  3. Geoff
    Geoff avatar
    25 posts
    Registered:
    17 Jul 2009
    06 Dec 2011
    Link to this post
    Hi Radoslav,

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

    Cheers,
    Geoff
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    09 Dec 2011
    Link to this post
    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
  5. Geoff
    Geoff avatar
    25 posts
    Registered:
    17 Jul 2009
    17 Dec 2011
    Link to this post

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

    Cheers,
    Geoff

  6. Geoff
    Geoff avatar
    25 posts
    Registered:
    17 Jul 2009
    04 Jan 2012
    Link to this post
    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
  7. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    04 Jan 2012
    Link to this post
    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
  8. Geoff
    Geoff avatar
    25 posts
    Registered:
    17 Jul 2009
    05 Jan 2012
    Link to this post

    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

  9. Geoff
    Geoff avatar
    25 posts
    Registered:
    17 Jul 2009
    09 Jan 2012
    Link to this post

    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

  10. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    12 Jan 2012
    Link to this post
    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
    Answered
  11. Geoff
    Geoff avatar
    25 posts
    Registered:
    17 Jul 2009
    12 Jan 2012
    Link to this post

    Hi Radislav,

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

    Cheers,
    Geoff

Register for webinar
11 posts, 1 answered