This article describes how to show culture names in national languages when using the “language selection” web part. The same procedure can be used for “language selection with flags” web part.
Let´s say that you are using four cultures on your site:
Czech, English, French, Spanish. When using a default
Language selection web part, all these culture names are rendered in English language. You may want to show them in national languages instead, so, for example above, like this:
Česky, English, Español, Français. This makes a better sense for a user of appropriate culture. See the difference on the screenshots below.
Default behavior:
Modified behavior:
To ensure this, you will need to modify code-behind of appropriate web part, in our case, it is a language selection web part, which is located here:
<project folder>\CMSWebParts\General\languageselection.ascx.cs
By default, there is a following code:
foreach (DataRow dr in ds.Tables[0].Rows)
{
string cultureCode = dr["CultureCode"].ToString();
string cultureShortName = dr["CultureShortName"].ToString();
// the rest of the default code
You need to modify it by this way:
foreach (DataRow dr in ds.Tables[0].Rows)
{
string cultureCode = dr["CultureCode"].ToString();
string cultureShortName = "";
//// begin custom code
switch (cultureCode)
{
case "cs-CZ": cultureShortName = "Česky"; break;
case "en-US": cultureShortName = "English"; break;
case "es-MX": cultureShortName = "Español"; break;
case "fr-FR": cultureShortName = "Français"; break;
default: cultureShortName = dr["CultureShortName"].ToString(); break;
}
//// end custom code
You can, of course, add any other culture code and appropriate culture name in national language here.
See also:
Multilingual support and cultures overview
Applies to:
Kentico CMS 4.x
Created on
1/4/2010 4:18:02 AM in
Content Management