Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Web applications use multiple threads to service a large number of requests. Setting the culture in one thread doesn't mean it will be available in others. </p> <p>Furthermore, the culture used for each request depends on globalization settings in web.config, page-level settings and the end user's language preferences. Even if you set the culture for one request, it will be reset when the thread is reused to service another request.</p> <p>Actually, there is no reason to change the current thread's culture if you want to format for a specific culture. The following code will work without problem:</p> <pre><code>var culture = new CultureInfo("zh-hk"); Console.WriteLine(DateTime.Now.ToString("dd/MMMM", culture)); </code></pre> <p>This returns <code>11/十二月</code> (.NET Fiddle <a href="http://dotnetfiddle.net/1L43QO" rel="nofollow">here</a>).</p> <p>Check <a href="http://msdn.microsoft.com/en-us/library/bz9tc508.aspx" rel="nofollow">How to: Set the Culture and UI Culture for ASP.NET Web Page Globalization</a> for the settings you need to set to ensure a specific culture is used for globalization. </p> <p>First, if you want to use "zh-hk" for all pages, you can add the following setting in web.config:</p> <pre><code>&lt;system.web&gt; &lt;globalization uiCulture="zh" culture="zh-HK" /&gt; &lt;/system.web&gt; </code></pre> <p>Second, if you want to set the culture programmatically on a page, depending on some criteria (eg a query parameter or user profile setting), you can override <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.page.initializeculture.aspx" rel="nofollow">InitializeCulture</a> and set the culture you want in the UICulture and Culture properties.</p> <p>Finally, if you want to create language-specific pages, you can set the culture on each page's Page directive:</p> <pre><code>&lt;%@ Page UICulture="zh" Culture="zh-HK" %&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload