DNN websites, modules, skins and support

Menu: Blog ยป Code

Changing the DNN default language

By:

From our list of things that are not in DNN, but would come in handy every now and then if they where.... Changing the default language of a portal. With Content localization switch on, that is.

At 40Fingers, we know DNN quite well and we have run into all sorts of issues involved with content localization. So I figured I'd give it a shot.

Content localization in the database

First off, we need to know how tabs (pages, but since the table is called "Tabs", I'm using "tabs") and modules are actually tied together in DNN, between languages. Let's focus on the tabs first.

The Tabs table contains a few fields that are involved in this localization process:

  • UniqueId: a GUID that is unique for each tab
  • DefaultLanguageGuid: a GUID that is set to:
    • NULL for tabs in the portal default language
    • NULL for neutral language-tabs
    • NULL for tabs that do not occur in the default language
    • The GUID of the related tab in the default language for tabs with several languages correctly tied together
  • CultureCode: obviously indication the language of each tab

So what's needed here to change the default language, is to:

  • change the value of DefaultLanguageGuid of each tab to contain the UniqueId of the same tab in the new default language
  • change the value of DefaultLanguageGuid to NULL for the tab in the new default language

Up to this point, things are exactly the same for TabModules. Same thing, different table.

Solving issues in our DNN Portal

A SQL script for this transition wasn't all that hard. But I came across a few issues when actually trying to run it. The main one, and the only one I consider "normal" to occur on a website:

  • Some tabs where translated but did not have a version in the new default language

Since this happened to only a few pages, I corrected that in the database manually and didn't try to automate that.For tabmodules, there where a few more, but still very much alike, issues:

  • Tabmodules not linked to the same module on translated tabs (so the module exists on pages in other languages, but the DefaultLanguageGuid is not set to the UniqueId of the module on the default language tab)
  • TabModules linked to the same module on a translated tab, but not on the tab that is linked to the tab the module is on. This happened with some modules that are referenced between pages: a module on tab A would have a DefaultLanguageGuid set to the UniqueId of a module in the defaultlanguage of tab B.

On the site there where about 200 modules with one of these issues. But fortunately, they had one thing in common: The DefaultLanguageGuid was either empty when it should not be, or was wrong. So I wrote a few queries for these cases to empty all of the DefaultLanguageGuids. At that point I only had 1 issue left: modules that are not linked to their counterpart in the default language.

At this point, most tabs looked like this on the tab localization settings page (click on the image for the readable big thing):

 

Note that the modules I marked with squared should have been on the row where the arrows points. And this goes for most modules in the "other" languages. This is also a feature that DNN soesn't support. The only thing you can do, is check the Copy Module checkbox, update translations and then manually copy over the content to the new module.

Obviously, that's not what I wanted.

Adding functionality to DNN Language module

What I did here, was to take the DNNLanguage module from DNN's source and add a nifty little feature to it. Notice the "Move File" icon next to the red and purple squares? If I click that, a "Paste" icon will appear on the places where a "Copy Module" checkobx is, for modules of the same ModuleDefinition (so you can't accidentally link an OpenContent module to an HTML/Text module). Click the paste icon, the page refreshes and the module is now linked and visible in it's correct spot.

Since I had a few hundred of these, I did do about 90% of them with a few SQL queries though.

When all this was done, I was finally ready to run the script. The only thing I needed to add, was to actually change the DefaulLanguage setting in DNN. That was added to the script too, of course.

Resources:

I do realize this is not something every site administrator would (or even should) be happy to perform on a DNN portal. Of course, we're happy to assist. Just contact us.