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

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

  • <tfoot id='5SVtQ'></tfoot>

          <bdo id='5SVtQ'></bdo><ul id='5SVtQ'></ul>
        <legend id='5SVtQ'><style id='5SVtQ'><dir id='5SVtQ'><q id='5SVtQ'></q></dir></style></legend>

        CurrentThread.CurrentUICulture 設(shè)置正確,但似乎被 as

        CurrentThread.CurrentUICulture is set correctly but seems to be ignored by asp.net(CurrentThread.CurrentUICulture 設(shè)置正確,但似乎被 asp.net 忽略)

          <legend id='zqYCx'><style id='zqYCx'><dir id='zqYCx'><q id='zqYCx'></q></dir></style></legend>
        1. <tfoot id='zqYCx'></tfoot>

                <i id='zqYCx'><tr id='zqYCx'><dt id='zqYCx'><q id='zqYCx'><span id='zqYCx'><b id='zqYCx'><form id='zqYCx'><ins id='zqYCx'></ins><ul id='zqYCx'></ul><sub id='zqYCx'></sub></form><legend id='zqYCx'></legend><bdo id='zqYCx'><pre id='zqYCx'><center id='zqYCx'></center></pre></bdo></b><th id='zqYCx'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='zqYCx'><tfoot id='zqYCx'></tfoot><dl id='zqYCx'><fieldset id='zqYCx'></fieldset></dl></div>
                  <tbody id='zqYCx'></tbody>

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

                  <bdo id='zqYCx'></bdo><ul id='zqYCx'></ul>
                • 本文介紹了CurrentThread.CurrentUICulture 設(shè)置正確,但似乎被 asp.net 忽略的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  在切換語(yǔ)言時(shí),我正在努力從我的 in 文件夾中的資源文件中的正確 strings.txt 中獲取值.

                  我有一個(gè) domain.com(英語(yǔ))和一個(gè) domain.nl(荷蘭語(yǔ)).然而,我使用哪個(gè)域以及如何設(shè)置 currentUICulture 似乎并不重要,向用戶顯示的語(yǔ)言總是相同的!

                  [default.aspx.vb]

                  部分類 _Default繼承 System.Web.UI.Page共享 rm 作為 ResourceManager = HttpContext.Current.Application("RM")Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) 處理 Me.LoadLabel.Text = rm.GetString("homewelcome")結(jié)束子受保護(hù)的覆蓋子 InitializeCulture()SetLanguage(Request.Url.ToString)結(jié)束子公共共享子集語(yǔ)言(ByVal URL 作為字符串)Dim lang As String = ""如果 URL.Contains("www.domain.nl") 那么lang = "nl"ElseIf URL.Contains("www.domain.com") 然后lang = "en"萬一System.Threading.Thread.CurrentThread.CurrentUICulture = 新 System.Globalization.CultureInfo(lang)System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(lang)結(jié)束子結(jié)束類

                  [global.asax]

                  Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)應(yīng)用程序(RM")=新資源管理器(字符串",Assembly.Load(字符串"))結(jié)束子

                  在我的 bin 文件夾中:

                  binstrings.txtbin lstrings.nl.txtbinenstrings.en.txt

                  我像這樣生成 dll:

                  resgen strings.txt strings.resourcesal/embed:strings.resources,strings.resources/out:strings.dllresgen nlstrings.nl.resourcesal/embed:nlstrings.nl.resources,strings.nl.resources/out:nlstrings.resources.dll/c:nlresgen enstrings.en.resourcesal/embed:enstrings.en.resources,strings.en.resources/out:enstrings.resources.dll/c:en

                  現(xiàn)在,所有文件似乎都已正確創(chuàng)建.

                  但是,當(dāng)我訪問 www.domain.com 時(shí),使用的是 binstrings.txt 中的值,而不是(如我所期望的那樣) binenstrings.en.txt 中的值

                  我在帶有 IIS7.5 的 Windows 7 上運(yùn)行當(dāng)我調(diào)試時(shí),我發(fā)現(xiàn)在我的 InitializeCulture 方法中:

                  Protected Overrides Sub InitializeCulture()SetLanguage(Request.Url.ToString)結(jié)束子

                  當(dāng)我檢查當(dāng)前的 System.Threading.Thread.CurrentThread.CurrentUICulture.ToString 時(shí),它等于en",所以似乎文化設(shè)置正確,只是不正確使用了strings.dll.

                  但是發(fā)生了更奇怪的事情:我的 default.aspx <asp:Literal ID="Literal1" runat="server" Text="<%$Resources:lookingfor%>"/>

                  1. 當(dāng)我接近 www.domain.nl(荷蘭域!)時(shí),Literal1 控件顯示來自App_LocalResourcesdefault.aspx.en.resx"的值,而 rm.getstring 顯示來自 bin 的值strings.txt當(dāng)我檢查當(dāng)前 System.Threading.Thread.CurrentThread.CurrentUICulture.ToString 它等于nl"

                  2. 當(dāng)我接近 www.domain.com(英文域!)時(shí),Literal1 控件顯示來自App_LocalResourcesdefault.aspx.en.resx"的值,而 rm.getstring 顯示來自 bin 的值strings.txt當(dāng)我檢查當(dāng)前 System.Threading.Thread.CurrentThread.CurrentUICulture.ToString 它等于en"

                  這是怎么回事?

                  所以在使用 www.domain.nl 時(shí),使用了錯(cuò)誤的 strings.dll,但使用了正確的 .resx

                  解決方案

                  您可以使用 ResourceManager 的 GetString(string, CultureInfo) 重載來獲取正確語(yǔ)言的字符串.

                  順便說一句.global.asax 可能是設(shè)置 CurrentCulture 和 CurrentUICulture 的更好位置.

                  編輯根據(jù)彼得的要求提供代碼示例

                  全球.asax

                  首先,我會(huì)檢測(cè)和存儲(chǔ)文化:

                  Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)'在每個(gè)請(qǐng)求開始時(shí)觸發(fā)'作為 CultureInfo 的暗淡文化Dim uri As Uri = Request.Url如果 uri.ToString().Contains("nederlands") 那么文化 = 新 CultureInfo("nl-NL")ElseIf uri.ToString().Contains("polski") Then文化 = 新 CultureInfo("pl-PL")別的文化 = 新 CultureInfo("en-US")萬一Thread.CurrentThread.CurrentCulture = 文化Thread.CurrentThread.CurrentUICulture = 文化結(jié)束子

                  根據(jù)您想要做什么,它可能不是重載的最佳功能,在您的情況下,我相信 Session_Start 更好(也就是說,除非您想讓用戶能夠切換語(yǔ)言).
                  另一件事是,我沒有用域名測(cè)試它,我使用了查詢參數(shù)并且沒有正確驗(yàn)證它們,但這只是為了舉例.

                  創(chuàng)建 App_LocalResources

                  我只能建議您使用 App_LocalResources,而不是實(shí)例化 ResourceManager 并手動(dòng)編譯您的資源.您只需在解決方案資源管理器中右鍵單擊您的項(xiàng)目,選擇添加 -> 添加 Asp.Net 文件夾 -> App_LocalResources.

                  創(chuàng)建資源文件

                  創(chuàng)建適當(dāng)命名的資源文件:Default.aspx.resx、Default.aspx.nl.resx 并將您想要本地化的內(nèi)容添加到它們.在我的情況下是:

                  Default.aspx.resx(中性又名后備文化資源文件)

                  label1 一些標(biāo)簽label2 其他一些標(biāo)簽

                  Default.aspx.nl.resx(對(duì)不起我可憐的荷蘭語(yǔ))

                  label1 Dit is een etiketlabel2 Dit is aner etiket

                  默認(rèn).aspx.pl.resx

                  label1 Jaka? tam labelkalabel2 Jaka? inna labelka

                  Default.aspx.vb(隱藏代碼)

                  在后面的代碼中,您可以像這樣以編程方式修改網(wǎng)頁(yè)的內(nèi)容:

                  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) 處理 Me.LoadLabel2.Text = Me.GetLocalResourceObject("label2")結(jié)束子

                  出于許多原因,我不推薦這種方法(尤其是它不應(yīng)該在頁(yè)面加載處理程序中使用),但有時(shí)需要它.

                  默認(rèn).aspx

                  終于到了我們漂亮(而且非常有用)的網(wǎng)頁(yè):

                  <html xmlns="http://www.w3.org/1999/xhtml" ><head runat="服務(wù)器"><標(biāo)題></標(biāo)題></頭><身體><form id="form1" runat="server">

                  <asp:Label ID="Label1" runat="server" Text="<%$ Resources:label1 %>"></asp:Label><br/><asp:Label ID="Label2" runat="server" Text="Label"></asp:Label></div></表格></身體></html>

                  如您所見,您可以使用以下表達(dá)式訪問資源:<%$ Resources:label1 %>.這將為您提供與 label1 資源鍵關(guān)聯(lián)的字符串.需要注意的重要事項(xiàng): runat="server" 不是可選的.

                  HTH.您可能還想閱讀 關(guān)于 Asp.Net 本地化的教程.

                  Im struggling with gettings the values from the correct strings.txt in my resource files in my in folder when switching languages.

                  I have a domain.com (for English) and a domain.nl (for Dutch). It however doesnt seem to matter which domain I use and how I set the currentUICulture, the language shown to the user is always the same!

                  [default.aspx.vb]

                  Partial Class _Default
                      Inherits System.Web.UI.Page
                  
                      Shared rm As ResourceManager = HttpContext.Current.Application("RM")
                  
                      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
                          Label.Text = rm.GetString("homewelcome")
                      End Sub
                  
                      Protected Overrides Sub InitializeCulture()
                          SetLanguage(Request.Url.ToString)
                      End Sub
                  
                      Public Shared Sub SetLanguage(ByVal URL As String)
                          Dim lang As String = ""
                          If URL.Contains("www.domain.nl") Then
                              lang = "nl"
                          ElseIf URL.Contains("www.domain.com") Then
                              lang = "en"
                          End If
                          System.Threading.Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo(lang)
                          System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(lang)
                      End Sub
                  End Class
                  

                  [global.asax]

                  Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
                      Application("RM") = New ResourceManager("strings", Assembly.Load("strings"))
                  End Sub
                  

                  In my bin folder I have:

                  binstrings.txt bin lstrings.nl.txt binenstrings.en.txt

                  I generate the dlls like so:

                  resgen strings.txt strings.resources
                  al /embed:strings.resources,strings.resources /out:strings.dll
                  resgen nlstrings.nl.resources
                  al /embed:nlstrings.nl.resources,strings.nl.resources /out:nlstrings.resources.dll /c:nl
                  resgen enstrings.en.resources
                  al /embed:enstrings.en.resources,strings.en.resources /out:enstrings.resources.dll /c:en
                  

                  Now, all files seem to be created correctly.

                  However, when I go to the www.domain.com, the values from binstrings.txt are used and NOT (like I would expect and desire), the values from binenstrings.en.txt

                  Im running on Windows 7 with IIS7.5 When I debugged I found that in my InitializeCulture method:

                  Protected Overrides Sub InitializeCulture()
                      SetLanguage(Request.Url.ToString)
                  End Sub
                  

                  when I check for the current System.Threading.Thread.CurrentThread.CurrentUICulture.ToString its equal to "en", so it seems that the culture is SET correctly, its only that not the correct strings.dll is used.

                  But there's a more strange things going on: I have this in my default.aspx <asp:Literal ID="Literal1" runat="server" Text="<%$Resources:lookingfor%>" />

                  1. When I aproach www.domain.nl (the Dutch domain!), the Literal1 controls displays the value from "App_LocalResourcesdefault.aspx.en.resx" and the rm.getstring shows me a value from binstrings.txt And when I check the current System.Threading.Thread.CurrentThread.CurrentUICulture.ToString its equal to "nl"

                  2. When I aproach www.domain.com (the English domain!), the Literal1 controls displays the value from "App_LocalResourcesdefault.aspx.en.resx" and the rm.getstring shows me a value from binstrings.txt And when I check the current System.Threading.Thread.CurrentThread.CurrentUICulture.ToString its equal to "en"

                  What is going on here?

                  So when using www.domain.nl, the WRONG strings.dll is used, but the CORRECT .resx

                  解決方案

                  You can use ResourceManager's GetString(string, CultureInfo) overload to get strings in correct language.

                  BTW. global.asax is probably the better place to set CurrentCulture and CurrentUICulture.

                  EDIT Providing code sample per Peter's request

                  Globabal.asax

                  For starters, I would detect and store culture:

                  Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
                      ' Fires at the beginning of each request '
                      Dim culture As CultureInfo
                      Dim uri As Uri = Request.Url
                      If uri.ToString().Contains("nederlands") Then
                          culture = New CultureInfo("nl-NL")
                      ElseIf uri.ToString().Contains("polski") Then
                          culture = New CultureInfo("pl-PL")
                      Else
                          culture = New CultureInfo("en-US")
                      End If
                  
                      Thread.CurrentThread.CurrentCulture = culture
                      Thread.CurrentThread.CurrentUICulture = culture
                  End Sub
                  

                  Depending on what you want to do, it might not be the best Function to overload, in your case I believe Session_Start is better (that is unless you want to give users an ability to switch language).
                  Another thing is, I didn't test it with domain names, I used query parameters and haven't validate them properly but it was just for the purpose of example only.

                  Create App_LocalResources

                  Instead of instantiating ResourceManager and compiling your resources manually, I can only suggest you to use App_LocalResources. You just need to right-click on your project in the Solution Explorer, choose Add -> Add Asp.Net Folder -> App_LocalResources.

                  Create resource files

                  Create appropriately named resource files: Default.aspx.resx, Default.aspx.nl.resx and add the contents you want to localize to them. In my case it was:

                  Default.aspx.resx (neutral aka fall-back culture resource file)

                  label1  Some label
                  label2  Some other label
                  

                  Default.aspx.nl.resx (Sorry for my poor Dutch)

                  label1  Dit is een etiket
                  label2  Dit is ander etiket
                  

                  Default.aspx.pl.resx

                  label1  Jaka? tam labelka
                  label2  Jaka? inna labelka
                  

                  Default.aspx.vb (code behind)

                  In code behind you can programmatically modify contents of your web page like this:

                  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
                      Label2.Text = Me.GetLocalResourceObject("label2")
                  End Sub 
                  

                  For many reasons I would not recommend this method (especially it should not be used in page load handler), however it is sometimes needed.

                  Default.aspx

                  Finally we are at our beautiful (and very useful) web page:

                  <html xmlns="http://www.w3.org/1999/xhtml" >
                  <head runat="server">
                      <title></title>
                  </head>
                  <body>
                  
                      <form id="form1" runat="server">
                      <div>
                        <asp:Label ID="Label1" runat="server" Text="<%$ Resources:label1 %>"></asp:Label>
                        <br />
                        <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>    
                      </div>
                      </form>
                  </body>
                  </html>
                  

                  As you can see, you can access the resources with following expression: <%$ Resources:label1 %>. This will give you the string associated with label1 resource key. Important thing to note: runat="server" is not optional.

                  HTH. You may want to read the tutorial on Asp.Net Localization as well.

                  這篇關(guān)于CurrentThread.CurrentUICulture 設(shè)置正確,但似乎被 asp.net 忽略的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  Ignore whitespace while reading XML(讀取 XML 時(shí)忽略空格)
                  extracting just page text using HTMLAgilityPack(使用 HTMLAgilityPack 僅提取頁(yè)面文本)
                  C# extracting data from XML(C# 從 XML 中提取數(shù)據(jù))
                  Read a XML (from a string) and get some fields - Problems reading XML(讀取 XML(從字符串)并獲取一些字段 - 讀取 XML 時(shí)出現(xiàn)問題)
                  Reading large XML documents in .net(在 .net 中讀取大型 XML 文檔)
                  How to create folder in Google Drive using .NET API?(如何使用 .NET API 在 Google Drive 中創(chuàng)建文件夾?)

                        <i id='7Kuqm'><tr id='7Kuqm'><dt id='7Kuqm'><q id='7Kuqm'><span id='7Kuqm'><b id='7Kuqm'><form id='7Kuqm'><ins id='7Kuqm'></ins><ul id='7Kuqm'></ul><sub id='7Kuqm'></sub></form><legend id='7Kuqm'></legend><bdo id='7Kuqm'><pre id='7Kuqm'><center id='7Kuqm'></center></pre></bdo></b><th id='7Kuqm'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='7Kuqm'><tfoot id='7Kuqm'></tfoot><dl id='7Kuqm'><fieldset id='7Kuqm'></fieldset></dl></div>

                      1. <legend id='7Kuqm'><style id='7Kuqm'><dir id='7Kuqm'><q id='7Kuqm'></q></dir></style></legend>
                          <tbody id='7Kuqm'></tbody>

                        <small id='7Kuqm'></small><noframes id='7Kuqm'>

                      2. <tfoot id='7Kuqm'></tfoot>
                        • <bdo id='7Kuqm'></bdo><ul id='7Kuqm'></ul>
                          • 主站蜘蛛池模板: 北条麻妃av一区二区三区 | 激情毛片| 日本成人在线免费视频 | a级毛片国产 | 久久久久电影 | 国产在线播 | 国产一区二区三区在线 | 国产精品美女久久久久久免费 | 国产精品美女久久久久 | 国产精品久久久久一区二区三区 | 日韩av看片| 国产精品久久99 | 久久机热 | 国产成人精品午夜视频免费 | 亚洲一区二区免费视频 | 日韩欧美在线视频观看 | 欧美一区二区三区久久精品 | 久久精品国产久精国产 | 国产丝袜av | 精品一区二区在线看 | 精品一二区 | av天天看| 久久久久久久久国产成人免费 | 亚洲成网 | 成人av片在线观看 | 国产欧美一区二区三区国产幕精品 | 久久久久精 | 99视频免费播放 | 国产片网站 | 久久久精品综合 | 在线国产精品一区 | 亚洲一区视频在线 | 伊人性伊人情综合网 | www亚洲精品 | 国产精品乱码一区二区三区 | 国产精品久久久久久久久久久久 | 中文字幕视频网 | 日韩欧美一区二区三区四区 | 欧美成人精品在线 | 亚洲美女一区二区三区 | 亚洲欧美视频一区 |