Mono Support Language Changer / Localization 

Viewed 8652 time(s), 4 post(s), 2/17/2014 1:21:42 PM - by panos.pag
2/17/2014 1:21:42 PM
390 Reputation 35 Total posts

Hello,

I would like to ask if there is a way to only have the homepage available in several languages. (To display the language changer only there and when navigating through pages to be back in, say, english)

In addition, 
could you give us a tip on how to create a dropdown menu instread of the flag images?

Thank you in advance,
Panos

1
2/18/2014 7:58:08 AM
15993 Reputation 2214 Total posts

Hi,

"I would like to ask if there is a way to only have the homepage available in several languages. (To display the language changer only there and when navigating through pages to be back in, say, english)"
Yes, you can place the language changer only on homepage and this will allow you to switch to and from any available language. You will also need to implement few lines of code in your e.g. BasePage to switch back to e.g. English for any other page.

"In addition, 
could you give us a tip on how to create a dropdown menu instread of the flag images?
"
You can build your own simple WebPart with drop down and these few lines of code to do the binding:

/// <summary>
/// Bind language.
/// </summary>
protected virtual void LanguageBind()
{
    MonoXCacheManager cacheManager = MonoXCacheManager.GetInstance(CacheKeys.Modules.LanguageChanger, this.CacheDuration);
    IEntityCollection2 dataSrc = cacheManager.Get<IEntityCollection2>();
    if (dataSrc == null)
    {
        dataSrc = LanguageEntity.GetLookup().Entities;
        cacheManager.Store(dataSrc);
    }
    languageChooser.DataSource = dataSrc;
    languageChooser.DataBind();
}
Regards

2
2/28/2014 9:46:27 AM
390 Reputation 35 Total posts

Hello Khorvat,

Could you give as a clue on how to implement this:
Yes, you can place the language changer only on homepage and this will allow you to switch to and from any available language. You will also need to implement few lines of code in your e.g. BasePage to switch back to e.g. English for any other page.
?

Thank's for all of your help :) ,
Panos

3
2/28/2014 2:47:09 PM
2218 Reputation 300 Total posts

This is just a general example for the BasePage implementation to demonstrate the approach:

protected override void OnInit(EventArgs e)
{
    // check if the current page is not the home page
    if (!(this.Page is HomePage))
    {                               
        // check the current language id against the default language id
        if (LocalizationUtility.GetCurrentLanguageId() != LocalizationUtility.GetDefaultLanguageId())
        {
            // perform a response redirect here                   
        }
    }                       
    base.OnInit(e);
}
Regards

4
This is a demo site for MonoX. Please visit Mono Software for more info.