久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <i id='Kw1jc'><tr id='Kw1jc'><dt id='Kw1jc'><q id='Kw1jc'><span id='Kw1jc'><b id='Kw1jc'><form id='Kw1jc'><ins id='Kw1jc'></ins><ul id='Kw1jc'></ul><sub id='Kw1jc'></sub></form><legend id='Kw1jc'></legend><bdo id='Kw1jc'><pre id='Kw1jc'><center id='Kw1jc'></center></pre></bdo></b><th id='Kw1jc'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Kw1jc'><tfoot id='Kw1jc'></tfoot><dl id='Kw1jc'><fieldset id='Kw1jc'></fieldset></dl></div>
    1. <small id='Kw1jc'></small><noframes id='Kw1jc'>

        <legend id='Kw1jc'><style id='Kw1jc'><dir id='Kw1jc'><q id='Kw1jc'></q></dir></style></legend>

      1. <tfoot id='Kw1jc'></tfoot>
        • <bdo id='Kw1jc'></bdo><ul id='Kw1jc'></ul>

        本地化 javascript 消息和驗證文本

        Localize javascript messages and validation text(本地化 javascript 消息和驗證文本)
      2. <tfoot id='Qt8tK'></tfoot>
      3. <small id='Qt8tK'></small><noframes id='Qt8tK'>

        • <legend id='Qt8tK'><style id='Qt8tK'><dir id='Qt8tK'><q id='Qt8tK'></q></dir></style></legend>

              <tbody id='Qt8tK'></tbody>

                <bdo id='Qt8tK'></bdo><ul id='Qt8tK'></ul>
                  <i id='Qt8tK'><tr id='Qt8tK'><dt id='Qt8tK'><q id='Qt8tK'><span id='Qt8tK'><b id='Qt8tK'><form id='Qt8tK'><ins id='Qt8tK'></ins><ul id='Qt8tK'></ul><sub id='Qt8tK'></sub></form><legend id='Qt8tK'></legend><bdo id='Qt8tK'><pre id='Qt8tK'><center id='Qt8tK'></center></pre></bdo></b><th id='Qt8tK'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Qt8tK'><tfoot id='Qt8tK'></tfoot><dl id='Qt8tK'><fieldset id='Qt8tK'></fieldset></dl></div>
                  本文介紹了本地化 javascript 消息和驗證文本的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在開發一個多語言的網絡項目.例如,該項目的一部分涉及一些自定義的谷歌地圖,該地圖利用客戶端接口使用 jquery/.net 將點添加到地圖并將它們保存到數據庫中.

                  I'm working on a web project that is multilingual. For example, one portion of the project involves some custom google mapping that utilizes a client-side interace using jquery/.net to add points to a map and save them to the database.

                  會有一些驗證和其他信息性消息(例如請在地圖上至少添加一個點")必須本地化.

                  There will be some validation and other informational messaging (ex. 'Please add at least one point to the map') that will have to be localized.

                  我現在能想到的唯一選擇是:

                  The only options I can think of right now are:

                  1. 在 javascript 中使用代碼渲染塊從資源文件中提取本地化消息

                  1. Use a code render block in the javascript to pull in the localized message from a resource file

                  使用帶有 meta:resourcekey 的隱藏字段,以使用當前文化自動從資源文件中獲取正確的本地化消息,并在必要時在 jquery 中獲取 .val().

                  Use hidden fields with meta:resourcekey to automatically grab the proper localized message from the resource file using the current culture, and get the .val() in jquery when necessary.

                  每次需要消息時,調用網絡服務以按鍵/語言獲取正確的消息.

                  Make a webservice call to get the correct message by key/language each time a message is required.

                  有什么想法、經驗嗎?

                  我更喜歡使用 .net 資源文件來與應用程序的其余部分保持一致.

                  I'd prefer to use the .net resource files to keep things consistent with the rest of the application.

                  推薦答案

                  好的,我構建了一個通用的 Web 服務來允許我獲取資源并將它們返回到字典中(可能是轉換為字典的更好方法)...

                  Ok, I built a generic web service to allow me to grab resources and return them in a dictionary (probably a better way to convert to the dictionary)...

                  <WebMethod()> _    
                  <ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=False, XmlSerializeString:=True)> _
                      Public Function GetResources(ByVal resourceFileName As String, ByVal culture As String) As Dictionary(Of String, String)
                  
                          Dim reader As New System.Resources.ResXResourceReader(String.Format(Server.MapPath("/App_GlobalResources/{0}.{1}.resx"), resourceFileName, culture))
                          If reader IsNot Nothing Then
                              Dim d As New Dictionary(Of String, String)
                              Dim enumerator As System.Collections.IDictionaryEnumerator = reader.GetEnumerator()
                              While enumerator.MoveNext
                                  d.Add(enumerator.Key, enumerator.Value)
                              End While
                              Return d
                          End If
                  
                          Return Nothing
                  
                      End Function
                  

                  然后,我可以獲取這個 json 結果并將其分配給一個局部變量:

                  Then, I can grab this json result and assign it to a local variable:

                  // load resources
                  $.ajax({
                      type: "POST",
                      url: "mapping.asmx/GetResources",
                      contentType: "application/json; charset=utf-8",
                      dataType: "json",
                      data: '{"resourceFileName":"common","culture":"en-CA"}',
                      cache: true,
                      async: false, 
                      success: function(data) {
                          localizations = data.d;                
                      }
                  });
                  

                  然后,您可以像這樣從局部變量中獲取您的值:

                  Then, you can grab your value from the local variable like so:

                  localizations.Key1

                  localizations.Key1

                  這里唯一的問題是,如果要將本地化分配給全局變量,則必須運行它 async=false,否則在需要時將無法獲得翻譯.我正在嘗試使用獲取",以便可以緩存響應,但它對我不起作用.看到這個問題:

                  The only catch here is that if you want to assign the localizations to a global variable you have to run it async=false, otherwise you won't have the translations available when you need them. I'm trying to use 'get' so I can cache the response, but it's not working for me. See this question:

                  不能通過 GET ajax Web 請求返回 Dictionary(Of String, String),適用于 POST

                  這篇關于本地化 javascript 消息和驗證文本的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  GoogleWebAuthorizationBroker in MVC For Google Drive Access(MVC 中的 GoogleWebAuthorizationBroker 用于 Google Drive 訪問)
                  Why do I get System.UnauthorizedAccessException Access to the path #39;Google.Apis.Auth#39; is denied(為什么我得到 System.UnauthorizedAccessException 對路徑“Google.Apis.Auth的訪問被拒絕) - IT屋-程序員軟件開發技術分享
                  Dynamically built SiteMapPath in asp.net(在 asp.net 中動態構建的 SiteMapPath)
                  ASP.NET Exception: The remote name could not be resolved: #39;apiconnector.com#39;(ASP.NET 異常:無法解析遠程名稱:“apiconnector.com)
                  Does a MasterPage know what page is being displayed?(MasterPage 是否知道正在顯示的頁面?)
                  ASP.net MVC - Navigation and highlighting the quot;currentquot; link(ASP.net MVC - 導航和突出顯示“當前;關聯)

                    <legend id='D3QdT'><style id='D3QdT'><dir id='D3QdT'><q id='D3QdT'></q></dir></style></legend>
                      <bdo id='D3QdT'></bdo><ul id='D3QdT'></ul>
                      <tfoot id='D3QdT'></tfoot>

                      <small id='D3QdT'></small><noframes id='D3QdT'>

                          <i id='D3QdT'><tr id='D3QdT'><dt id='D3QdT'><q id='D3QdT'><span id='D3QdT'><b id='D3QdT'><form id='D3QdT'><ins id='D3QdT'></ins><ul id='D3QdT'></ul><sub id='D3QdT'></sub></form><legend id='D3QdT'></legend><bdo id='D3QdT'><pre id='D3QdT'><center id='D3QdT'></center></pre></bdo></b><th id='D3QdT'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='D3QdT'><tfoot id='D3QdT'></tfoot><dl id='D3QdT'><fieldset id='D3QdT'></fieldset></dl></div>
                              <tbody id='D3QdT'></tbody>
                            主站蜘蛛池模板: 麻豆精品久久久 | 亚洲欧美视频在线观看 | 一区二区三区精品视频 | 国产精品色一区二区三区 | 日本精品视频在线观看 | 亚洲精品一区二区三区免 | 视频一区二区在线观看 | 欧美精品一区二区在线观看 | 欧美日本在线观看 | 国产东北一级毛片 | 亚洲欧美日韩电影 | 国产福利在线 | 欧美亚洲日本 | 亚洲精品2区 | 欧美性久久久 | 中文字幕一区二区三区在线视频 | 亚洲成人在线网 | 91亚洲精华国产 | 亚洲精品二三区 | 亚洲第一福利网 | 国产精品国产馆在线真实露脸 | www.天堂av.com | 国产午夜视频 | 国产在线播放一区二区三区 | 久久久久久久久精 | 欧美国产亚洲一区二区 | 国产精品久久久久久久模特 | 日韩综合在线 | 日韩在线一区二区 | 天天玩夜夜操 | 久久99精品久久久久久噜噜 | 午夜在线电影网 | av天天干 | 欧美成人一区二区 | 欧美a级成人淫片免费看 | 亚洲免费一区二区 | 日韩手机视频 | 91精品国产色综合久久 | 亚洲精品在线视频 | 亚洲精品国产综合区久久久久久久 | 日本爱爱视频 |