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

Forums / General Discussions / Language Selector Error

Language Selector Error

33 posts, 0 answered
  1. JV
    JV avatar
    74 posts
    Registered:
    15 Jun 2012
    22 Nov 2010
    Link to this post
    Hi,

    when i try to add the language selector widget to my template i receive one error. Please see the attached images.

    I have two languages PT and EN .
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    22 Nov 2010
    Link to this post
    Hi JV,

    I am not able to replicate this issue locally. Could you attach several screenshots

    1. Language settings screeen
    2. Pages configuration Sitefinity >> Administration >> Settings >> Advanced >> Pages and what has been set for

    3. On which language version you create a page.

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. JV
    JV avatar
    74 posts
    Registered:
    15 Jun 2012
    22 Nov 2010
    Link to this post
    Hi,

    I sent the images in attach.

    My homepage is created in PT and EN but i have other pages that are only created in PT.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    22 Nov 2010
    Link to this post
    Hello JV,

    I am not able to replicate the issue with these settings. There is a new build that we uploaded today. Could you download it and try to replicate the issue with it. Let me know if the problem persists and I will try to come up with other suggestions to narrow it down.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. JV
    JV avatar
    74 posts
    Registered:
    15 Jun 2012
    22 Nov 2010
    Link to this post

    Hi,

    I already made the download of the new release and run the upgrade in project manager.

    When i try to add the language selector to one page it works.

    When i try to add the language selector to one page template i get the error.

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    22 Nov 2010
    Link to this post
    Hi JV,

    The control cannot work on backend pages or templates. Its current implementation allows to use it only with FrontendSiteMap. We will add some logic to catch the exception. The problem should not persists for pages created under FrontendSiteMap

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. JV
    JV avatar
    74 posts
    Registered:
    15 Jun 2012
    23 Nov 2010
    Link to this post
    OK.
    The error disappear after applying the template to one frontendpage.

    I need to change the "tag" displayed in the language selector for example i don't whant "English" but i whant that "EN" appear to the user (Português --> PT). How can i achieve this, how can i costumize the language selector ?

    thanks,
    JV
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    23 Nov 2010
    Link to this post
    Hello JV,

    We use CultureInfo and NativeName property of the object. You can change the text of the HtmlGenericControl that us used by creating a custom class that inherits from LanguageSelectorControl. You should override InitializeControls method and rebind the Repeater control - LanguagesRepeater

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. JV
    JV avatar
    74 posts
    Registered:
    15 Jun 2012
    23 Nov 2010
    Link to this post
    Sorry i think i don't understand 100%.
    Could you send a litle sample in attach?

    thanks,
    JV
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    23 Nov 2010
    Link to this post
    Hello JV,

    Here is a sample code

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Telerik.Sitefinity.Localization.Web.UI;
    using System.Globalization;
    using Telerik.Sitefinity.Configuration;
    using Telerik.Sitefinity.Modules.Pages.Configuration;
    using Telerik.Sitefinity.Modules.Pages;
    using Telerik.Sitefinity.Abstractions;
    using Telerik.Sitefinity.Model;
    using System.Threading;
     
    namespace Telerik.Sitefinity.Samples
    {
        public class LanguageSelectorControlCustom : LanguageSelectorControl
        {
     
            protected override string LayoutTemplateName
            {
                get
                {
                    return LanguageSelectorControlCustom.customTemplate;
                }
            }
     
     
            protected override void InitializeControls(Web.UI.GenericContainer container)
            {
                //base.InitializeControls(container);
                var settings = ObjectFactory.Resolve<IAppSettings>();
                List<CultureInfo> languages = new List<CultureInfo>();
                if (this.MissingTranslationAction == NoTranslationAction.HideLink)
                {
                    languages.AddRange(this.usedLanguages);
                }
                else
                {
     
                    languages.AddRange(settings.DefinedFrontendLanguages);
                    PageManager pm = PageManager.GetManager();
                    var homePageId = Config.Get<PagesConfig>().HomePageId;
                    if (homePageId != Guid.Empty)
                    {
                        this.homePageNode = pm.GetPageNode(homePageId);
                    }
                }
                CultureInfo currentLanguage = Thread.CurrentThread.CurrentUICulture;
                IEnumerable<CultureInfo> shownLanguages;
                if (this.ShowCurrentLanguage == false && this.SelectorType != LanguageSelectorType.DropDown)
                {
                    shownLanguages = languages.Where(ci => ci.Equals(currentLanguage) == false);
                }
                else
                {
                    shownLanguages = languages;
                }
                this.LanguagesRepeater.DataSource = shownLanguages;
                this.LanguagesRepeater.ItemDataBound += new System.Web.UI.WebControls.RepeaterItemEventHandler(LanguagesRepeater_ItemDataBound);
                this.LanguagesRepeater.DataBind();
            }
     
            void LanguagesRepeater_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
            {
                CultureInfo ci = (CultureInfo)e.Item.DataItem;
                // here format the link you want to see.
            }
     
            // you can get the template through reflector.
            private const string customTemplate = "Telerik.Sitefinity.Samples.Templates.PublicControls.LanguageSelectorControl.ascx";
            private List<CultureInfo> usedLanguages;
            private Pages.Model.PageNode homePageNode;
        }
     
    }


    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. JV
    JV avatar
    74 posts
    Registered:
    15 Jun 2012
    23 Nov 2010
    Link to this post
    Thank you for the code.

    See the attached code please tell me what i'm doing wrong (i tried to sent one zip file but i was not allowed).
    Sorry but I don't have "Custom Control" experience.

    I registered the atached control in the toolbox but nothing appears.
  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    23 Nov 2010
    Link to this post
    Hello JV,

    1. You have not completed the logic inside ItemDataBound event of the repater

    2. You should use the template below.

    <%@ Control Language="C#" %>
    <%@ Register TagPrefix="sfFields" Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.Fields" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %>
     
    <div runat="server" id="controlWrapper">
     
        <asp:Panel ID="errorsPanel" runat="server" CssClass="sfErrorSummary" />
     
        <sf:ConditionalTemplateContainer ID="sfLangSelectorConditionalTemplateContainer" runat="server">
            <Templates>
                <sf:ConditionalTemplate Left="SelectorType" Operator="Equal" Right="Horizontal" runat="server">
                    <asp:Repeater ID="languagesRepeater" runat="server">
                        <HeaderTemplate>
                            <ul id="langsWrapper" class="sflanguagesHorizontalList">
                        </HeaderTemplate>
                        <ItemTemplate>
                            <li runat="server" id="langHolder" class="sflanguageItem">
                                <a runat="server" id="langLink" href=""><span runat="server" id="langName"></span></a>
                            </li>
                        </ItemTemplate>
                        <FooterTemplate>
                            </ul>
                        </FooterTemplate>
                    </asp:Repeater>
                </sf:ConditionalTemplate>
                <sf:ConditionalTemplate Left="SelectorType" Operator="Equal" Right="Vertical" runat="server">
                    <asp:Repeater ID="languagesRepeater" runat="server">
                        <HeaderTemplate>
                            <ul id="langsWrapper" class="sflanguagesVerticalList">
                        </HeaderTemplate>
                        <ItemTemplate>
                            <li runat="server" id="langHolder" class="sflanguageItem">
                                <a runat="server" id="langLink" href=""><span runat="server" id="langName"></span></a>
                            </li>
                        </ItemTemplate>
                        <FooterTemplate>
                            </ul>
                        </FooterTemplate>
                    </asp:Repeater>
                </sf:ConditionalTemplate>
                <sf:ConditionalTemplate Left="SelectorType" Operator="Equal" Right="DropDown" runat="server">
                    <div class="sflanguagesDropDown">
                        <asp:DropDownList runat="server" ID="langsSelect"></asp:DropDownList>
                    </div>
                </sf:ConditionalTemplate>
            </Templates>
        </sf:ConditionalTemplateContainer>
    </div>


    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  13. JV
    JV avatar
    74 posts
    Registered:
    15 Jun 2012
    23 Nov 2010
    Link to this post
    OK Thanks,

    Now in the  LanguagesRepeater_ItemDataBound  

    CultureInfo ci = (CultureInfo)e.Item.DataItem

    i get that  ci is null.

    But in debug mode i see that "shownLanguages" have two itens (English and Portuguese).
    What's wrong ?

    Another thing is that in debug i get that CultureInfo currentLanguage = Thread.CurrentThread.CurrentUICulture;
    is the english but mi page is backend is the PT translation page.

    thanks again.
  14. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    23 Nov 2010
    Link to this post
    Hi JV,

    You could check the e.Item.DataItem before you made the cast. Also this control cannot work on backend pages as I described in my previous posts. Since it inherits from the base class LanguageSelectorControl there could be some issues.
    CurrentUICulture shows the culture that is used by resource manager for the user interface.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  15. Millaneli
    Millaneli avatar
    20 posts
    Registered:
    08 Nov 2010
    09 Dec 2010
    Link to this post
    Hi,
    I have the same problem as you (The first problem).
    In fact, I do not understand how you solved it.
    Please, w
    ill you explain with mors details.
    Thanks.
  16. JV
    JV avatar
    74 posts
    Registered:
    15 Jun 2012
    09 Dec 2010
    Link to this post
    Hi,

    The exception only happens in the backend. If you ignore and publish the page and then navigate in the frontend the exception disappear.
  17. Millaneli
    Millaneli avatar
    20 posts
    Registered:
    08 Nov 2010
    09 Dec 2010
    Link to this post
    Hi,

    The exception exists if I put this url http://localhost:58632/nom_projet/ but if I put this url http://localhost:58632/nom_projet/fr/ or http://localhost:58632/nom_projet/en/ the exception does not exist.
  18. Sonya
    Sonya avatar
    205 posts
    Registered:
    09 Dec 2016
    11 Dec 2010
    Link to this post
    Hi Millaneli,

    We were able to reproduce this issue locally. This issue is valid only for  Sitefinitys’ projects that are stored on the local file system (not through IIS) and launched using the built-in web server.

    The issue is logged as a bug with ID  101947


    Greetings,
    Sonya
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  19. Stefano
    Stefano avatar
    29 posts
    Registered:
    14 Jun 2011
    29 Jun 2011
    Link to this post
    I have this error when I tried to set the path of my custom control and I lunch the page.
    Why?

    Stefano
  20. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    29 Jun 2011
    Link to this post
    Hello Stefano,

    Have you checked whether you have two controls with the same ID on the page or two instances  inside your control that use the same ID?

    Regards,
    Ivan Dimitrov
    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
  21. Stefano
    Stefano avatar
    29 posts
    Registered:
    14 Jun 2011
    29 Jun 2011
    Link to this post
    Can you show me step by step how can I implement this control to create the languageSelector IT- DE -EN ?
    Than you!

    Stefano
  22. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    29 Jun 2011
    Link to this post
    Hi Stefano,

    Most of the custom control is implemented here. What is not clear so I can provide further help?

    Best wishes,
    Ivan Dimitrov
    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
  23. Stefano
    Stefano avatar
    29 posts
    Registered:
    14 Jun 2011
    04 Jul 2011
    Link to this post
    I don't understand where i can insert the code of the template and where the code of the custom control that it isn't an User Control so I can't do from my folder "Custom" this operation: "Add -> NewItem -> Web User Control".
    I explained?
  24. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    04 Jul 2011
    Link to this post
    Hello Stefano,

    1. Do you have duplicate Ids in the template? The error says that there are two controls with the same ID

    2. As I see you use a user control, not a custom control which will not work. You need to create a class that inherits from LanguageSelectorControl.
    Then override LayoutTemplateName and LayoutTemplatePath and register the template through VirtualPathProvider

    Greetings,
    Ivan Dimitrov
    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
  25. Stefano
    Stefano avatar
    29 posts
    Registered:
    14 Jun 2011
    04 Jul 2011
    Link to this post
    Yes, I have the error:

    Parser Error

    Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

    Parser Error Message: The ID 'languagesRepeater' is already used by another control.

    What can I do?
  26. Stefano
    Stefano avatar
    29 posts
    Registered:
    14 Jun 2011
    06 Jul 2011
    Link to this post
    I attach all my source code. Can you help me to find the error?
  27. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    06 Jul 2011
    Link to this post
    Hello Stefano,

    When you are registering the control you are setting a namespace which your control does not have. Please set namespace of your class.

    All the best,
    Ivan Dimitrov
    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
  28. Stefano
    Stefano avatar
    29 posts
    Registered:
    14 Jun 2011
    07 Jul 2011
    Link to this post
    I have resolve the problem with the namespace but I have a new error.

    Stefano
  29. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    07 Jul 2011
    Link to this post
    Hi Stefano,

    Try using

    var settings = AppSettings.CurrentSettings;

    Best wishes,
    Ivan Dimitrov
    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
  30. Stefano
    Stefano avatar
    29 posts
    Registered:
    14 Jun 2011
    07 Jul 2011
    Link to this post
    Now I have this error. And I have this WARNING:

    Warning    1    Field 'LanguagesSelectorControl.WebControl.LanguageSelectorControlCustom.usedLanguages' is never assigned to, and will always have its default value null    C:\Program Files (x86)\Telerik\Sitefinity 4.1\Projects\LanguageSelectorControl\LanguageSelectorControl.cs    77    35    LanguagesSelectorControl.WebControl

    Warning    2    'LanguagesSelectorControl.WebControl.LanguageSelectorControlCustom.usedLanguages' hides inherited member 'Telerik.Sitefinity.Localization.Web.UI.LanguageSelectorControl.usedLanguages'. Use the new keyword if hiding was intended.    C:\Program Files (x86)\Telerik\Sitefinity 4.1\Projects\LanguageSelectorControl\LanguageSelectorControl.cs    77    35    LanguagesSelectorControl.WebControl

    Warning    3    'LanguagesSelectorControl.WebControl.LanguageSelectorControlCustom.homePageNode' hides inherited member 'Telerik.Sitefinity.Localization.Web.UI.LanguageSelectorControl.homePageNode'. Use the new keyword if hiding was intended.    C:\Program Files (x86)\Telerik\Sitefinity 4.1\Projects\LanguageSelectorControl\LanguageSelectorControl.cs    78    26    LanguagesSelectorControl.WebControl

33 posts, 0 answered
1 2