Bi-lingual site?

Topics: Business Logic Layer
Sep 9, 2009 at 7:39 PM
Edited Sep 9, 2009 at 7:45 PM

What is the best way to have (almost) the same site in 2 different languages?

My plan, is to have 2 different master-pages, each having links to a different set of categories.
(The English masterpage contains links to the English Categories, and hence pages in English, The French masterpage contains links to the French Categories, and hence pages in French, )

and somewhere, according to the category, change the culture's language

 

This code changes the labels generated by BlogEngine:

    protected override void OnPreInit(EventArgs e)
    {
        base.OnPreInit(e);
        Page.UICulture = /* logic to determine language and culture */;

        if( category == ... )
        base.MasterPageFile = "themes/freshcitrus/siteFR.master";
    } 

 

Any suggestion anyone?

 

 

Sep 12, 2009 at 10:02 PM

Actually, having 2 similar blogs would be a solution, 

I understood thought from the forum that this is not possible yet

Coordinator
Sep 13, 2009 at 12:29 AM

If each language will have a different set of categories, does that mean the posts themselves will be different too?

If the categories and posts will be different, than having two installations of BE is probably the cleanest and easiest approach.  You can do this by creating a sub-folder (e.g. french or fr) and mark that folder as an application (aka application starting point) in IIS, and install a second copy of BE into that sub-folder.  There's a few variations of this, but this is the general idea.

Sep 14, 2009 at 12:51 AM

different posts yes.

Your idea seems to be a good one. However I do NOT have access to IIS, I can just upload files.
Did you say I can have a sub-folder in an BE installation?
How would I be able to use that as a different application from within BE? (meaning, without creating a virtual directory on IIS)

and wouldnt the nested copy of the web.config complain, since it is not on the root?

Thank you

Coordinator
Sep 14, 2009 at 3:40 AM

Even if you don't have direct access to IIS, often times web hosts (if you're at web host) offer the ability to create an application starting point either through their control panel, or via a support request.

In this scenario, you have the main website.  And then under it, you have a separate 'application'.  The application is a sub-folder, and it's just like a new website.  You put a web.config file in there, BIN folder, App_Code folder, global.asax file, etc. etc.

If this is not possible to do where you have the site, then you will only have one application and you can only install BE once.  So then I think the only option is to filter posts (by language) depending on which language is selected at that time.

You can dynamically set the master page, like you were doing.  However, there's several other changes that you'll probably want to make to filter the posts / categories depending on the current language.  For example, on the blog home page, you'll probably want to only show the posts that are for the current language.  On the Archive page, you'll probably only want to show the posts and categories for the selected language.  Same with the Tag cloud widget, Categories List widget, Related Posts widget etc. etc.  And the RSS feed too.  You'll probably want to filter the RSS feed so only posts for the current language are shown.  Same with the Search functionality too.  There's really a lot that you would probably want to do to 'really' separate the content for the two languages.

That's why my first inclination is having two separate applications.  Just because it would be less effort in terms of changing several things in BE.

Sep 16, 2009 at 11:54 AM

Ouf, you are right, thank you for enlighting me... The best way to go is indeed to have 2 separate applications

I tried nesting applications, (I copied the whole application in a sub-folder called 'FR')
Like expected, I received a bunch of error message (which I can list of you want me to) 

I even tried having both applications in 2 different subfolders:
  Empty root 
    |__ EN
    |__ FR

That did not work neither...

Any ideas?

 

Sep 16, 2009 at 3:05 PM

 

The Enhanced BlogEngine.NET seems to answer my need... 
Thank you Jaroslav :)
Having said that, does anyone have a review or comment on it?

The Enhanced BlogEngine.NET seems to answer my need...  (http://enhancedblogengine.codeplex.com

Thank you Jaroslav :)

Having said that, does anyone have a review or comment on it?

 

Q1: Is there a way to direct the user to the homepage after changing a language, rather than to the blog?

Q2: back to my original question, what is the best way of choosing a MasterPageFile, depending on the language?
Here is my idea; In site.master:

    protected override void OnPreInit(EventArgs e)
    {
        base.OnPreInit(e);        

        if( Page.UICulture == /* logic to determine language and culture */;)
        base.MasterPageFile = "themes/freshcitrus/siteFR.master";
    } 

 

 

Coordinator
Sep 17, 2009 at 12:43 AM

I've not used Enhanced BE, but the code you came up with in OnPreInit seems to be good.