YAFLogo

manees
  • manees
  • 54.2% (Neutral)
  • YAF Forumling Topic Starter
10 years ago
I have given the permission to a forum user to change its language. There are two languages in my forum Arabic and English. I want to display the custom top menu of my forum according to the current selected language.

I can find the current language of the forum by following code.

<%if (CultureInfo.CurrentCulture.Name == "ar-SA"){ %>

--code--

<%}else if(CultureInfo.CurrentCulture.Name == "en-US"){%>

--code--

<%}%>

But the problem is this always shows CultureInfo.CurrentCulture.Name == "en-US" not Arabic while I have select Language Arabic.

Sponsor

tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 3.0.3
10 years ago
Try this instead...

YafContext.Current.CultureUser.IsSet() ? YafContext.Current.CultureUser :YafContext.Current.BoardSettings.Culture

This Returns the User Culture or if not defined the Board default Culture.

manees
  • manees
  • 54.2% (Neutral)
  • YAF Forumling Topic Starter
10 years ago
Thanks..

It is really helpful. Actually I have two .CSS files for English and Arabic. I have to load one based on current language. How I can write this code in section to call on .css file.

tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 3.0.3
10 years ago
you almost wrote the code yourself

<%
    var culture = YafContext.Current.CultureUser.IsSet()
                      ? YafContext.Current.CultureUser
                      : this.Get<YafBoardSettings>().Culture;
    
    if (culture.Equals("ar-SA"))
    {
        YafContext.Current.PageElements.RegisterCssInclude("arabic.css");
    }
    else if(culture.Equals("en-US"))
         {
        YafContext.Current.PageElements.RegisterCssInclude("english.css");
         }
         %>

You can add this Directlly to the Default.aspx

manees
  • manees
  • 54.2% (Neutral)
  • YAF Forumling Topic Starter
10 years ago
I am facing a compilation error. I have downloaded 1.9.6 Beta1 Src version. I opened it with VS 2010. Updated Connection strings. When I run the solution I get the following error:

{"Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it has already been disposed."}

at line

///

/// Provides access to the Service Locatorer

///

public IServiceLocator ServiceLocator

{

get

{

return this._contextLifetimeContainer.Resolve(); // Here goes the error.

}

}

in class public class YafContext : UserPageBase, IDisposable, IHaveServiceLocator

Thanks for the support.