manees
  •  manees
  • 54.2% (Neutral)
  • YAF Forumling Topic Starter
2011-09-19T09:20:31Z
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
2011-09-19T10:09:31Z
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.
UserPostedImage
manees
  •  manees
  • 54.2% (Neutral)
  • YAF Forumling Topic Starter
2011-09-19T11:32:41Z
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 <head></head> section to call on .css file.



tha_watcha
2011-09-19T12:13:38Z
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
UserPostedImage
manees
  •  manees
  • 54.2% (Neutral)
  • YAF Forumling Topic Starter
2011-09-19T19:01:04Z
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

/// <summary>
/// Provides access to the Service Locatorer
/// </summary>
public IServiceLocator ServiceLocator
{
get
{
return this._contextLifetimeContainer.Resolve<IServiceLocator>(); // Here goes the error.
}
}


in class public class YafContext : UserPageBase, IDisposable, IHaveServiceLocator

Thanks for the support.

About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button

Project Twitter Updates

Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved