0
사용자가 토글 버튼을 클릭 할 때 내 웹 사이트의 문화 및 사용자 문화를 변경하기 위해 쿠키를 설정하려고합니다.resx 페이지간에 전환 할 언어 쿠키 설정
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
HttpCookie cookie = Request.Cookies["CurrentLanguage"];
if (!IsPostBack && cookie != null && cookie.Value != null)
{
if (cookie.Value.IndexOf("en-") >= 0)
{
// currently english
Culture = "fr-CA";
UICulture = "fr-CA";
}
else
{
//currently french
Culture = "en-CA";
UICulture = "en-CA";
}
}
...
}
}
과 토글 기능이 실행되면 또한
protected void toggle_lang(object sender, DirectEventArgs e)
{
if (Culture.ToString() == "English (Canada)")
{
HttpCookie cookie = new HttpCookie("CurrentLanguage");
cookie.Value = "fr-CA";
Response.SetCookie(cookie);
Response.Redirect(Request.RawUrl);
}
else
{
HttpCookie cookie = new HttpCookie("CurrentLanguage");
cookie.Value = "en-CA";
Response.SetCookie(cookie);
Response.Redirect(Request.RawUrl);
}
}
이 페이지 새로 고침하지만 문화와 cultureui가 업데이트되지 않습니다 ..
어떤 아이디어 : 이것은 내가 무엇을 가지고 ?
고마워요! 사람이 문화 및 UI 문화는 쿠키에 따라 설정, 내 코드를보고 싶어하면
시도 : 그리고 위의 함수는 다음과 같이 페이지 언어를 설정 돌봐셔서, 새로 고침 System.Threading.Thread.CurrentThread.'CurrentUICulture 'insted o f 'UICulture'. 중립 문화를 사용하는 것이 좋습니다. 장래에 문제를 일으킬 수 있습니다. – Svmurvj