472,129 Members | 1,695 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Localization

I need to localize my ASP.NET app and I just used "Tools" --"generate local
resources" command and everything works fine in my WebForms.
Resource file name is: MyWebForm.aspx.resx under a subDir named:
"App_LocalResources" inside the App directory.

Now I need to localize some messages my VB app sends to the user. What I'm
looking for is a way to read from a .resx file and get the appropriate
values.

I found some examples like this one:

Dim res As System.Resources.ResourceManager
res = New System.Resources.ResourceManager("ResFilename",
System.Reflection.Assembly.GetExecutingAssembly)
Myname = res.GetString("Myname")

But when I try it, I get this error message:

Could not find any resources appropriate for the specified culture or the
neutral culture. Make sure "ResFilename.resources" was correctly embedded or
linked into assembly "App_Web_fq5sjqk2" at compile time, or that all the
satellite assemblies required are loadable and fully signed.

The file is under the same subDir like others and is named:
ResFilename.resources.resx

--
bruno
Jul 30 '06 #1
2 3414
Hello Bruno,

Since you mentioned that you've created local page resources through the
"Tools" --"generate local resources" menu, I think you're developing
ASP.NET 2.0 application in VS 2005. As for ASP.NET 2.0 web application, it
has provided much enhanced localization features that facilitate your work
for page localization. You have the following options to perform page
localization in ASP.NET 2.0:
1. Use local resource( in the App_LocalResources subdir), declaratively or
programmatically. And the resource items for a certain page
must be put in that page's local resource file ----- PageName.aspx.resx

e.g. "Button1.Text" is a resource item's key in the page's local resource
file(in App_LocalResources sub folder)

<asp:Button ID="Button1" runat="server"
Text="<%$ Resources:Button1.Text %>" />

or
==============
protected void Page_Load(object sender, EventArgs e)
{
Button1.Text =
this.GetLocalResourceObject("Button1.Text").ToStri ng();
}
==============
2. Use global resource (in the App_GlobalResources global folder).
"App_GlobalResources" folder is one of the special application level
folders in ASP.NET 2.0 application which is used to store some application
scope resources and we can easily reference it in all the pages within the
same application.

e.g. # Put the message related resources in a "Messages.resx" file in the
App_GlobalResources folder

<asp:Label ID="Label2" runat="server" Text="<%$ Resources:Messages,
Message1 %>"></asp:Label>

or

====================
protected void Page_Load(object sender, EventArgs e)
{
string msg1 = this.GetGlobalResourceObject("Messages",
"Message1").ToString();

Label2.Text = msg1;
}
====================
3. We can use the orginal means to load resource stream and get resource
item from it as we do in ASP.NET 1.0, however, we're recommended to use
the #1 and #2 in ASP.NET 2.0. Because ASP.NET 2.0 Web application project
use dynamic compilation which is not quite easy to use embeded resources.

Therefore, for your scenario, you can consider either store the Message
key/values in a page's localResource file or in a global resource file,
this depend on whether that message values is only used by a specific page
or is reused in the whole web application.

Here are some other MSDN reference articles discussing on how to perform
localization tasks in ASP.NET 2.0 Page. You can also have a look to get
some further ideas:

#ASP.NET Web Page Resources Overview
http://msdn2.microsoft.com/en-us/library/ms227427.aspx

#How to: Retrieve Resource Values Programmatically
http://msdn2.microsoft.com/en-us/library/ms227982.aspx

#Resources and Localization in ASP.NET 2.0
http://msdn.microsoft.com/msdnmag/is...s/default.aspx

If you have anything unclear or any further questions, please feel free to
let me know.

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 31 '06 #2
Many thanks.
--
bruno
"Steven Cheng[MSFT]" wrote:
Hello Bruno,

Since you mentioned that you've created local page resources through the
"Tools" --"generate local resources" menu, I think you're developing
ASP.NET 2.0 application in VS 2005. As for ASP.NET 2.0 web application, it
has provided much enhanced localization features that facilitate your work
for page localization. You have the following options to perform page
localization in ASP.NET 2.0:
1. Use local resource( in the App_LocalResources subdir), declaratively or
programmatically. And the resource items for a certain page
must be put in that page's local resource file ----- PageName.aspx.resx

e.g. "Button1.Text" is a resource item's key in the page's local resource
file(in App_LocalResources sub folder)

<asp:Button ID="Button1" runat="server"
Text="<%$ Resources:Button1.Text %>" />

or
==============
protected void Page_Load(object sender, EventArgs e)
{
Button1.Text =
this.GetLocalResourceObject("Button1.Text").ToStri ng();
}
==============
2. Use global resource (in the App_GlobalResources global folder).
"App_GlobalResources" folder is one of the special application level
folders in ASP.NET 2.0 application which is used to store some application
scope resources and we can easily reference it in all the pages within the
same application.

e.g. # Put the message related resources in a "Messages.resx" file in the
App_GlobalResources folder

<asp:Label ID="Label2" runat="server" Text="<%$ Resources:Messages,
Message1 %>"></asp:Label>

or

====================
protected void Page_Load(object sender, EventArgs e)
{
string msg1 = this.GetGlobalResourceObject("Messages",
"Message1").ToString();

Label2.Text = msg1;
}
====================
3. We can use the orginal means to load resource stream and get resource
item from it as we do in ASP.NET 1.0, however, we're recommended to use
the #1 and #2 in ASP.NET 2.0. Because ASP.NET 2.0 Web application project
use dynamic compilation which is not quite easy to use embeded resources.

Therefore, for your scenario, you can consider either store the Message
key/values in a page's localResource file or in a global resource file,
this depend on whether that message values is only used by a specific page
or is reused in the whole web application.

Here are some other MSDN reference articles discussing on how to perform
localization tasks in ASP.NET 2.0 Page. You can also have a look to get
some further ideas:

#ASP.NET Web Page Resources Overview
http://msdn2.microsoft.com/en-us/library/ms227427.aspx

#How to: Retrieve Resource Values Programmatically
http://msdn2.microsoft.com/en-us/library/ms227982.aspx

#Resources and Localization in ASP.NET 2.0
http://msdn.microsoft.com/msdnmag/is...s/default.aspx

If you have anything unclear or any further questions, please feel free to
let me know.

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 31 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Amin Schoeib | last post: by
6 posts views Thread by Rental | last post: by
8 posts views Thread by Olivier Matrot | last post: by
5 posts views Thread by CMM | last post: by
reply views Thread by shapper | last post: by
3 posts views Thread by Corey B | last post: by
3 posts views Thread by Computer Guru | last post: by

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.