MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

Language Changer / Localization  (Mono Support )

Viewed 4430 time(s), 4 post(s) 2/17/2014 1:21:42 PMby panos.pag
panos-pag

panos.pag

2/17/2014 1:21:42 PM
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
This content has not been rated yet. 
390 Reputation 35 Total posts
khorvat

khorvat

2/18/2014 7:58:08 AM
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
This content has not been rated yet. 
15993 Reputation 2214 Total posts
panos-pag

panos.pag

2/28/2014 9:46:27 AM
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
This content has not been rated yet. 
390 Reputation 35 Total posts
mzilic

mzilic

2/28/2014 2:47:09 PM
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
This content has not been rated yet. 
2218 Reputation 300 Total posts