Switching between two (or more) languages

Topics: ASP.NET 2.0, Business Logic Layer, Controls
Mar 10, 2010 at 9:10 PM

Is it possible to configure BlogEngine.Net to display page in two (or more) languages... and switching between this languages... I have found another project "Enchanced BlogEngine" which has implemented "hack" for multilanguage, but it is based on old version of BlogEngine... and it is unstable and incompatible in many places (e.g. PageMenu from DarkTheme does not work). Is there some (very) easy way to achieve multilanguage  in BlogEngine? Please help me!...

Mar 11, 2010 at 9:40 AM

Do you mean switching languages for your blog content?  Or switching languages for the non-content items like labels, button text, links, etc?

I'm not sure what Enhanced BE does, but you can set the language for non-content items in Global.asax.  The language (or culture) is already being set in Application_PreRequestHandlerExecute().

If you had a dropdown list on your site for the person to choose a language, they could choose a language from the dropdown list and click a button.  You could then save their language choice in a cookie.  This could be done in your site.master file.  Then in Global.asax, you can check for this cookie and set the language preference stored in the cookie.

To get an idea on how to present the available languages/cultures, take a look at BindCultures() inside of Settings.aspx.cs in the admin\Pages folder.  BindCultures() populates the ddlCulture dropdown list in Settings.aspx.

Mar 11, 2010 at 11:31 AM

Thank You for quick answer. I would like to achieve swithching language of blog content and non-content items at the same time. E.g. if the language is set to French - the non-content items are in French and post contents are in French (of course not automaticaly translated - it would display in French if someone enter this post in French and English). If there no content in other languege the default (English) content is displayed... i was thinkig to add new children node for content tag in XML's:


<fr> Du texte ici </fr>

<en>Some text here </en>


Mar 11, 2010 at 2:52 PM

I have found nice plugin for WordPress CMS called mLanguage. It works like that... You define langauges ("Long language description" and "language code" /e,g "en"/), select default language... and while writing post content you can put different language content in tags e.g. " [ en ] English [ /en ] [ fr ] French [ /fr ] [ de ] German [ /de ] "... is it possible to do something like this in BlogEngine?

Mar 12, 2010 at 1:25 AM

Yes you can do something like this.  You just need to write code to do it.

For the posts themselves, you can either modify the Post class in BE so it can store multiple languages, or you can use tags like you show to delimit the language -- and continue to use the single 'Content' property that would contain all these languages.  If you do that, then you would need to modify code that displays the posts so it picks the appropriate language and only displays that one version.

This could actually probably be done with an Extension.  Extensions can control the content from a post that is served to the browser.  So the Extension could determine what the current language is for the user (possibly via a cookie), and parse the normal post content, and just serve the correct language, by extracting the appropriate language from the entire post Content.  You can take a look at the BreakPost extension (in App_Code\Extensions) as an example to see what it does.

Then when composing your posts, you would want to use delimiting syntax like [en] [/en], etc to put the corresponding language content in its correct position.

Mar 12, 2010 at 11:00 AM
Edited Mar 12, 2010 at 11:46 AM

I think that one content with tags for language would be better... so I'll try to write extension for this functionality... thanks for responses! :-)