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

Forums / General Discussions / Stopping redirect to translated pages

Stopping redirect to translated pages

8 posts, 0 answered
  1. Developer
    Developer avatar
    2 posts
    Registered:
    07 Mar 2008
    01 Sep 2008
    Link to this post
    Hi Guys - This is sort of urgent. We went live with our site that is available in English, Spanish, and German. The Spanish and German content is currently in translation i.e. it is not ready for everyone to see. When a user in Spain goes to www.mydomain.com, the user automaticaly gets redirected to the spanish pages. How do we stop this? Basically, we only want them to go to the English pages. When the Spanish translation is done, only then do we want them to be sent to the Spanish pages. I am assuming the users browser language characterset is being read and accordingly the redirect is happening. Please advice. Thanks.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    01 Sep 2008
    Link to this post
    Hi Developer,

    Sitefinity is always redirecting the requests to the default culture set in the web.config file.
    Could you take a look at your web.config file and check out the defaultCulture value?
    <localization defaultProvider="Sitefinity" persistenceMode="PathPrefix" defaultCulture="en" cultures="en, es, fr, de, bg"

    You may find the following KB articles useful:Changing the default site language and Using strict language versions of pages.

    Hope this helps.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Developer
    Developer avatar
    2 posts
    Registered:
    07 Mar 2008
    02 Sep 2008
    Link to this post
    Thanks Ivan. I took a look at the articles but I don't believe it helps. My setting in the web.config is-

    <localization defaultProvider="Sitefinity" persistenceMode="PathPrefix" defaultCulture="en" allowSpecificCultures="True" cultures="en, es, fr, de">


    My site is available in English, Spanish, and German. The Spanish and German pages are still being translated. If a user from Spain goes to the site, since their browser language preference is set to Spanish, the site automatically gets redirected to the spanish translated page e.g. http://site/es/home.aspx but this page home.aspx is not fully translated into Spanish. The pages in Spanish and German are a work in progress. We don't want the public to be able to see these pages or get redirected to these pages. Internally, we want to continue translating pages into Spanish and German. Does this make sense?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    04 Sep 2008
    Link to this post
    Hi Developer,

    Please add one more property to the same node in the web.config.

    <localization defaultProvider="Sitefinity" autoSetClientLanguage="false" persistenceMode="PathPrefix" defaultCulture="en" cultures="en, es, fr, de, bg"

    This will prevent the undesired forward. When your pages will be translated and you are able to publish the whole project you could set the property value to "true".

    Hope this helps.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. J
    J avatar
    20 posts
    Registered:
    05 Feb 2008
    04 Sep 2008
    Link to this post
    Hi Ivan - I logged a support ticket since there seem to be issues with this. Can you please take a look at the support ticket titled "Problems with Internationalization"
    Thanks.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    04 Sep 2008
    Link to this post
    Hello J,


    We are closing this thread and will follow up in the support ticket.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  7. Anthony
    Anthony avatar
    1 posts
    Registered:
    04 Mar 2011
    11 Jul 2011
    Link to this post

    Hello support,

    I'm having the same problem and the page is not ready yet. All I need to know is that how I can redirect it to www.domain.com/en/index.aspx for time being.

    Thanks.
    AI
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    12 Jul 2011
    Link to this post
    Hello Anthony,

    There are two options

    1. Override the behavior of Internal page class and its OnPreInit.

    - set useStrictLanguageVersions property of cms node to true

    Copy Code
    <cms defaultProvider="Sitefinity"  pageExtension=".aspx" disabled="false" projectName="test" pageEditorUIMode="Overlay" useStrictLanguageVersions="true">

    - override OnPreInit of the internal page and add the following logic to your custom class

    Copy Code
    if (LocalizationManager.PersistenceMode != Telerik.Localization.Configuration.PersistenceMode.None && ConfigHelper.Handler.UseStrictLanguageVersions
    && !LocalizationHelper.GetPageCulture(cmsPage).Equals(CultureInfo.CurrentUICulture))
     // HERE MAKE RESPONSE REDIRECT
     // context.Response.Redirect("somepage.aspx");


    - replace the default internal page with your custom one inside  Sitefinity\cmsentrypoint.aspx

    Copy Code
    <%@ Page Inherits="InternalPageCustom" MasterPageFile="~/Sitefinity/Dummy.master" %>

    Use Manager.GetPage where you have to pass the page ID and add the following helper class

    sample

    Copy Code
    internal class LocalizationHelper
       {
           internal static CultureInfo GetPageCulture(IPageContent page)
           {
               CultureInfo culture;
               if (page.LangID == CultureInfo.InvariantCulture.LCID)
                   culture = LocalizationManager.DefaultCulture;
               else
                   culture = CultureInfo.GetCultureInfo(page.LangID);
               return culture;
           }
       }

    Finally the if loop should look as shown below

    sample

    Copy Code
    CmsManager Manager;
          ICmsPage cmsPage = Manager.GetPage(cmsUrlContext.PageID);
          if (Telerik.Localization.LocalizationManager.PersistenceMode != Telerik.Localization.Configuration.PersistenceMode.None
              && Telerik.Cms.Configuration.ConfigHelper.Handler.UseStrictLanguageVersions &&
              !LocalizationHelper.GetPageCulture(cmsPage).Equals(CultureInfo.CurrentUICulture))
          {
     
          }




    2. The second option is creating a custom HttpModule and inside BeginRequest you have to get the current page and check whether it has localized version of not . If the current page does not have localized version for the culture that has been requested you have to make response redirect from the context. You can use the same code as this one from option 1 - OnPreInit. You can get the current page from the context

    Copy Code
    ICmsUrlContext pageKey = (ICmsUrlContext)this.Context.Items[Telerik.Cms.Web.UrlHelper.CmsPageKey];
    Guid currentPageID = pageKey.PageID;



    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
Register for webinar
8 posts, 0 answered