2016-11-18 50 views
0

在我的asp .net mvc4應用程序中,我需要實現以支持「英文」和「阿拉伯文」。在Global.asac.cs中,我設定了這樣的文化。 「ar」在這裏被硬編碼爲顯示目的。我正在使用cookie來選擇語言。Localize @ Html.EditorFor

protected void Application_PreRequestHandlerExecute() 
     { 
      Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("ar"); 
      Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("ar"); 
     } 

對於阿拉伯語每個HTML控件一樣編輯網頁,不顯示阿拉伯字母時,用戶打字。我如何通過語言更改來解決這個問題。

+0

[檢查此鏈接](http://geekswithblogs.net/shaunxu/archive/2010/05/06/localization -in-asp.net-MVC-ndash的-3天查-1-day.aspx)。這可能有幫助。 – Nitin

回答

0

可以捕捉到keydown事件,並用這樣的替換字符:

$('textarea').on('keydown', function(e){ 

    console.log(e.keyCode); 
    if(e.keyCode == 90){ 
     e.preventDefault(); 
     $(this).append('y').focus(); 
    } 
    if(e.keyCode == 89){ 
     e.preventDefault(); 
     $(this).append('z').focus(); 
    } 

});​