using System;
using System.Globalization;
using System.IO;
using System.Threading;
using System.Web.Mvc;


namespace Translator.Website.Utilities
{
    public class LocalizationAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (filterContext.RequestContext.HttpContext.Request.QueryString["lang"] != null)
            {

                string culture = filterContext.RequestContext.HttpContext.Request.QueryString["lang"] as string;

                if (!String.IsNullOrEmpty(culture))
                {
                    Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(culture);
                    Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);
                }
            }

            base.OnActionExecuting(filterContext);
        }
    }
}