Can missing language-specific pages fallback to default lang

Posted by Community Admin on 03-Aug-2018 07:23

Can missing language-specific pages fallback to default language?

All Replies

Posted by Community Admin on 15-Jun-2015 00:00

We've added a new language. We want missing pages to be redirected to the English equivalent. For example, if ~/zh/Services is missing, we want them redirected to ~/en/Services. Right now the user gets a 404 error.

We don't want to have to do this manually for every page. Is there some global setting we can use, or some code we can add?

 

Hm, no replies? So...is our only choice to manually instantiate zh versions of every page, and have each redirect to the existing en version?

Posted by Community Admin on 17-Jun-2015 00:00

Hi Chris,

You can try redirecting to the desired page in the Application_Error event in global.asax. E.g:

protected void Application_Error(object sender, EventArgs e)
       
           var ex = Server.GetLastError() as HttpException;
           if (ex != null)
           
               int httpCode = ex.GetHttpCode();
               if (httpCode == 404)
               
                    
                   string urlSegment = this.Context.Request.Url.Segments[this.Context.Request.Url.Segments.Length-1];
 
                   this.Context.Response.Redirect("/en/" + urlSegment);
               
           
 
       


Regards,
Junior Dominguez
Telerik
 
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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 19-Jun-2015 00:00

Thanks, I'll try that!

EDIT: Not working yet.

I added the global.asax,  added your code to the Application_Error handler, and rebuilt. I made one change, because I think a true 404 would otherwise cause an infinite loop:

if (httpCode == 404)
    if (this.Context.Request.Url.Segments[1] == "zh/")
    
        string urlSegment = this.Context.Request.Url.Segments[this.Context.Request.Url.Segments.Length - 1];
        this.Context.Response.Redirect("/en/" + urlSegment);
    

But this hasn't made a difference, I still see the 404 page with the same missing URL. (I also restarted IIS, just to be sure.)

Posted by Community Admin on 24-Jun-2015 00:00

Hi Chris,

Can you please provide some feedback about your results ? What happen when you debug it ? Is it redirecting to another location? 

Best Regards,
Junior Dominguez
Telerik

 
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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 07-Apr-2016 00:00

Is there another solution to this problem?

I do not like the "Application_Error" solution - I should not have to manually redirect to the English version of the page.

 

Furthermore, redirecting to the "en" version, will put Sitefinity in English mode.  This causes problems if you are using a language-specific .resx file.  For example, if a user requests "/fr/home" and I redirect them to "/en/home" it means that the English version of my .resx files will be chosen, which is not the desired result.

Posted by Community Admin on 14-Apr-2016 00:00

Hi Patrick,

You may consider the alternatives described in the following link of our documentation and customize the error message depending on the culture in the widget:

http://docs.sitefinity.com/administration-custom-error-pages

Best Regards,

Junior Dominguez
Telerik
 
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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 17-Aug-2016 00:00

Hi Guys,

What i did was I created a Redirect Widget and put it inside the page. So this translated page will redirect to wherever i like.

Just a quick fix i can't find a solution to this right now. Any suggestion?

Thanks

This thread is closed