<commit_before>using Signum.Engine;
using Signum.Engine.Authorization;
using Signum.Engine.Basics;
using Signum.Engine.Operations;
using Signum.Entities;
using Signum.Entities.Authorization;
using Signum.Entities.Basics;
using Signum.React.Filters;
using Signum.Utilities;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting;
using System.ComponentModel.DataAnnotations;

namespace Signum.React.Translation
{
    [ValidateModelFilter]
    public class CultureController : ControllerBase
    {
        IHostingEnvironment _env;
        public CultureController(IHostingEnvironment env)
        {
            _env = env;
        }

        [HttpGet("api/culture/cultures"), AllowAnonymous]
        public List<CultureInfoEntity> GetCultures()
        {
            return CultureInfoLogic.CultureInfoToEntity.Value.Values.ToList();
        }

        [HttpGet("api/culture/currentCulture"), AllowAnonymous]
        public CultureInfoEntity CurrentCulture()
        {
            return CultureInfo.CurrentCulture.TryGetCultureInfoEntity() ?? CultureInfoLogic.CultureInfoToEntity.Value.Values.FirstEx();
        }

        [HttpPost("api/culture/setCurrentCulture"), AllowAnonymous]
        public string SetCurrentCulture([Required, FromBody]Lite<CultureInfoEntity> culture)
        {
            var ci = ExecutionMode.Global().Using(_ => culture.Retrieve().ToCultureInfo());

            if (UserEntity.Current != null && !UserEntity.Current.Is(AuthLogic.AnonymousUser)) //Won't be used till next refresh
            {
                var user = UserEntity.Current.ToLite().Retrieve();
                user.CultureInfo = culture.Retrieve();

                using (AuthLogic.Disable())
                using (OperationLogic.AllowSave<UserEntity>())
                {
                    UserEntity.Current = user;
                    user.Save();
                }
            }

            ControllerContext.HttpContext.Response.Cookies.Append("language", ci.Name);
            return ci.Name;
        }
    }
}<commit_msg>set an expires date, so that the cookie does not expire immediatly in IE11.<commit_after>using System;
using Signum.Engine;
using Signum.Engine.Authorization;
using Signum.Engine.Basics;
using Signum.Engine.Operations;
using Signum.Entities;
using Signum.Entities.Authorization;
using Signum.Entities.Basics;
using Signum.React.Filters;
using Signum.Utilities;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Http;

namespace Signum.React.Translation
{
    [ValidateModelFilter]
    public class CultureController : ControllerBase
    {
        IHostingEnvironment _env;
        public CultureController(IHostingEnvironment env)
        {
            _env = env;
        }

        [HttpGet("api/culture/cultures"), AllowAnonymous]
        public List<CultureInfoEntity> GetCultures()
        {
            return CultureInfoLogic.CultureInfoToEntity.Value.Values.ToList();
        }

        [HttpGet("api/culture/currentCulture"), AllowAnonymous]
        public CultureInfoEntity CurrentCulture()
        {
            return CultureInfo.CurrentCulture.TryGetCultureInfoEntity() ?? CultureInfoLogic.CultureInfoToEntity.Value.Values.FirstEx();
        }

        [HttpPost("api/culture/setCurrentCulture"), AllowAnonymous]
        public string SetCurrentCulture([Required, FromBody]Lite<CultureInfoEntity> culture)
        {
            var ci = ExecutionMode.Global().Using(_ => culture.Retrieve().ToCultureInfo());

            if (UserEntity.Current != null && !UserEntity.Current.Is(AuthLogic.AnonymousUser)) //Won't be used till next refresh
            {
                var user = UserEntity.Current.ToLite().Retrieve();
                user.CultureInfo = culture.Retrieve();

                using (AuthLogic.Disable())
                using (OperationLogic.AllowSave<UserEntity>())
                {
                    UserEntity.Current = user;
                    user.Save();
                }
            }

            ControllerContext.HttpContext.Response.Cookies.Append("language", ci.Name, new CookieOptions
            {
                Expires = DateTimeOffset.MaxValue
            });
            return ci.Name;
        }
    }
}
{'fraction_non_alphanumeric': 0.09554280670785525, 'fraction_numerical': 0.000441306266548985, 'mean_word_length': 2.6409638554216865, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6886000', 'n_tokens_mistral': 1180, 'n_tokens_neox': 1173, 'n_words': 217}