473,385 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Explicit Localization Syntax - One Works, Other Does Not

We have created two (2) global resource files in App_GlobalResouces:
Global.resx
Global.es-MX.resx

In an ASP.NET page, we use two different syntaxes to set text on the page,
depending upon the context.
Syntax 1: <% =Resources.Global.QuickSearch%>
Syntax 2: <%$Resources:Global, QuickSearch%>

When we set our Thread.CurrentThread.CurrentUICulture and
Thread.CurrentThread.CurrentCulture = new CultureInfo("es-MX"), those
controls using syntax 1 display Spanish, but those displaying syntax 2 still
display English.

To create the Global.es-MX.resx file, we copied the Global.resx and modified
the text. All of the keys are present. Also because of this, we thought if
it were a key issue, then how is the English text being found?

Any ideas on what we're doing wrong?
Jul 19 '07 #1
2 2567
Hi Chris,

From your description, when you use the following two ways to display
localized Text in ASP.NET 2.0 web page(load from global resource), only the
<%= ...%appraoch will work, correct?

Syntax 1: <% =Resources.Global.QuickSearch%>
Syntax 2: <%$Resources:Global, QuickSearch%>

As for this problem,I've performed some research and found the cause of the
problem. For the two kind of statements below:

Syntax 1: <% =Resources.Global.QuickSearch%>
====================
This is simple embeded inline code statement which is executeing at the end
of the page's lifecycle(rendering stage). So this code is the same as you
put some code in codebehind page event.

Syntax 2: <%$Resources:Global, QuickSearch%>
====================
This is a built-in ASP.NET 2.0 expression and this expression is determined
at earlier time, when the page is dynamically compiled and initialized.
Therefore, if you set the Thread.CurrentUICulture in page's codebehind
event, that's too late for this localization expression. If you want to
programmatically set the Thread's CultureInfo and want to make the
<%$Resources %expression be wared of it, you need to put the code in an
earlier time during the page request's server-side processing. One good
place is the "BeginRequest" event of ASP.NET server-side pipeline, you can
use Global.asax to register this event's handler. e.g.
>>>>>in global.asax>>>>>>>>>
<script runat="server">

void Application_Start(object sender, EventArgs e)
{
................
}

void Application_BeginRequest(object sender, EventArgs e)
{
CultureInfo ci = new CultureInfo("zh-CN");

Thread.CurrentThread.CurrentCulture = ci;
Thread.CurrentThread.CurrentUICulture = ci;

Context.Response.Write("<br/>Application_BeginRequest.......");
}
...................

<<<<<<<<<<<<<<

Thus, the <%$ REsources %expression in Page can get awared of the
CultureInfo changing.

Hope this helps.
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 20 '07 #2
Thanks for the information. I never ran across that in my searches and in
it seems that the far majority of the examples I found on this topic
reference Syntax #2, but don't mention the limitations below.

Thanks,
Chris

"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:c%****************@TK2MSFTNGHUB02.phx.gbl...
Hi Chris,

From your description, when you use the following two ways to display
localized Text in ASP.NET 2.0 web page(load from global resource), only
the
<%= ...%appraoch will work, correct?

Syntax 1: <% =Resources.Global.QuickSearch%>
Syntax 2: <%$Resources:Global, QuickSearch%>

As for this problem,I've performed some research and found the cause of
the
problem. For the two kind of statements below:

Syntax 1: <% =Resources.Global.QuickSearch%>
====================
This is simple embeded inline code statement which is executeing at the
end
of the page's lifecycle(rendering stage). So this code is the same as you
put some code in codebehind page event.

Syntax 2: <%$Resources:Global, QuickSearch%>
====================
This is a built-in ASP.NET 2.0 expression and this expression is
determined
at earlier time, when the page is dynamically compiled and initialized.
Therefore, if you set the Thread.CurrentUICulture in page's codebehind
event, that's too late for this localization expression. If you want to
programmatically set the Thread's CultureInfo and want to make the
<%$Resources %expression be wared of it, you need to put the code in an
earlier time during the page request's server-side processing. One good
place is the "BeginRequest" event of ASP.NET server-side pipeline, you can
use Global.asax to register this event's handler. e.g.
>>>>>>in global.asax>>>>>>>>>

<script runat="server">

void Application_Start(object sender, EventArgs e)
{
...............
}

void Application_BeginRequest(object sender, EventArgs e)
{
CultureInfo ci = new CultureInfo("zh-CN");

Thread.CurrentThread.CurrentCulture = ci;
Thread.CurrentThread.CurrentUICulture = ci;

Context.Response.Write("<br/>Application_BeginRequest.......");
}
..................

<<<<<<<<<<<<<<

Thus, the <%$ REsources %expression in Page can get awared of the
CultureInfo changing.

Hope this helps.
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.

Jul 20 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Steve W. | last post by:
I just read the section (and did the exercise) in the C# Step by Step book that covers Explict Interface Implementation (where you specify in the method implementation the specific interface that...
31
by: Michael C | last post by:
If a class inherits from another class, say Form inherits from control, then I can assign the Form to a variable of type Control without needing an explicit conversion, eg Form1 f = new Form1();...
3
by: Eric | last post by:
Hi, I'm just looking into the samples that are delivered withthe Enterprise Localization Framework/Toolkit. I have set it up and it all works fine. But.. now i have a question. I read a...
6
by: Rental | last post by:
I'm having the sam problem as described below with the Localization toolkit. Does anyone know if there is a solution to this problem. --->When attempting to generate resource dlls with...
1
by: Olivier Matrot | last post by:
Hello, I'm trying to use explicit localization expression to access global resources from an .inc file that's included into several ASPX pages. I may be wrong in my expression, bu accessing...
1
by: kelmen | last post by:
Greeting, I'm working on the resources stuff, using the explicit localization. And to test it is as : http://www.asp.net/QuickStart/aspnet/doc/localization/culture.aspx#ielanguage add in the...
0
by: Rusty Hill | last post by:
I am trying to concatenate two localization expressions AT DESIGN TIME and am not sure how to do it. For example I would like to concatenate two pieces of information from resource files and have...
1
by: =?Utf-8?B?Q2hyaXMgVw==?= | last post by:
We have created two (2) global resource files in App_GlobalResouces: Global.resx Global.es-MX.resx In an ASP.NET page, we use two different syntaxes to set text on the page, depending upon the...
12
by: Rahul | last post by:
Hi Everyone, I have the following code and i'm able to invoke the destructor explicitly but not the constructor. and i get a compile time error when i invoke the constructor, why is this so? ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.