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

Forums / General Discussions / Can I make generic content display the default language?

Can I make generic content display the default language?

4 posts, 0 answered
  1. Wakefly
    Wakefly avatar
    11 posts
    Registered:
    21 Sep 2006
    20 May 2009
    Link to this post
    I have setup the generic content to allow localization, but I would like to show the default English content until I have had the time to translate all of the content.  Is this possible?

    So if I am on a German page, and a specific generic content block on the page is blank for German, I would like the English content to show.
  2. Stoyanka Assenova
    Stoyanka Assenova avatar
    113 posts
    Registered:
    01 Dec 2016
    21 May 2009
    Link to this post
    Hi Wakefly,

    I regret to inform you that this is not possible at the moment.

    Regards,
    Stoyanka Assenova
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Wakefly
    Wakefly avatar
    11 posts
    Registered:
    21 Sep 2006
    21 May 2009
    Link to this post
    Is it possible to replace the content of a page with the content of another.

    For example, I currently have an IHttpModule setup to redirect to the English page when the page hasn't been created in the current language.

    Is there a way to keep the user on the current language page, and simply show the content of the english page?  So...

    instead of redirecting to...

    site/en/products.aspx

    show

    site/de/products.aspx

    but with everything from the English version.  That would allow the user to continue to browse the German site without having to switch back.
  4. Vlad
    Vlad avatar
    498 posts
    Registered:
    15 Jul 2016
    22 May 2009
    Link to this post
    Hi Dean,

    Unfortunately, such scenario is not considered by design.
    When using the localization, the information about the current culture is stored in the following context objects:

    HttpContext.Current.Items[Telerik.Cms.Web.UrlHelper.CultureKey]
    System.Threading.Thread.CurrentThread.CurrentUICulture

    The other components in the system get the current CultureInfo from them, to display the language specific data. If you change the values dynamically in the code, you may loose the state of the originally requested language.

    We cannot suggest you a bullet-proof approach for this scenario. However, you can try the following work around:
    1. Create a CustomInternalPage class in the App_Code:
    using System.Globalization; 
    using Telerik.Cms.Web; 
    using Telerik.Localization; 
     
    namespace Telerik.Sitefinity.Samples 
        public class CustomInternalPage : InternalPage 
        { 
            protected override void OnPreInit(System.EventArgs e) 
            { 
                base.OnPreInit(e); 
                if (this.CmsPage.HasCurrentLanguageVersion) 
                { 
                    CultureInfo culture; 
                    if (this.CmsPage.LangID == CultureInfo.InvariantCulture.LCID) 
                        culture = LocalizationManager.DefaultCulture; 
                    else 
                        culture = CultureInfo.GetCultureInfo(this.CmsPage.LangID); 
                     
                    System.Threading.Thread.CurrentThread.CurrentUICulture = culture; 
                } 
            } 
     
        } 
     

    NOTE that the HttpContext.Current.Items[Telerik.Cms.Web.UrlHelper.CultureKey] is not changed. This is because, we want that all URLs to be correctly resolved with the originally requested language, as the UrlHelper.ResolveURL method uses the CultureInfo from the HttpContext.Current.Items[Telerik.Cms.Web.UrlHelper.CultureKey] instead of System.Threading.Thread.CurrentThread.CurrentUICulture.

    2. Change the InternalPage type in the ~/Sitefintiy/cmsentrypoint.aspx:
    <%@ Page Inherits="Telerik.Sitefinity.Samples.CustomInternalPage" MasterPageFile="~/Sitefinity/Dummy.master" %> 

    Hope this is helpful.

    Regards,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Register for webinar
4 posts, 0 answered