Help with Localization

  • Thread starter Thread starter CGuy
  • Start date Start date
C

CGuy

Hi,

I'm trying to develop an ASPX page that supports multiple languages.
Everything has gone well till now -

1. Created a project in VS.NET 2003
2. Added 2 resource files named Captions.resx and Captions.fr.resx for
English and French cultures respectively
3. Used the following code in the ASPX Code Behind file

resourceManager = new ResourceManager("MyProject.Captions",
Assembly.GetExecutingAssembly());
this.Label.Text = resourceManager.GetString("LABEL_CAPTION");

4. Compiled the project in VS.NET 2003. The page loads fine with the
label's caption set to English or French (depending on the Culture)

Now the problem

Since I plan to support more languages and there are going to be more
resource files (per language, per category etc), I would like to organize
them into several directories. So, I moved both my resource files into a
"Resources" directory and recompiled the project - BOOM - get a runtime
error saying:

"Could not find any resources appropriate for the specified culture (or the
neutral culture) in the given assembly. Make sure
"MyProject.Captions.resources" was correctly embedded or linked into
assembly "MyProject". baseName: MyProject.Captions locationInfo: <null>
resource file name: MyProject.Captions.resources assembly: MyProject,
Version=1.0.1361.33724, Culture=neutral, PublicKeyToken=null "

I guess the problem is due to the fact that VS.NET is unable to locate the
resx files during compilation. How do I fix this problem? Any help in this
matter is greatly appreciated.

CGuy
 
Hi CGuy,

Assuming that you have placed your resource files in the
folder "Resources", ensure that:
1. Italian resources are in a folder "it" under
the "Resources" folder. That is to say that the sub-folder
name should be as per the language.
2. Your resource files should have the
extension "filename.it.resx". That is to say that the file
name should be as per the language.


Resources
|
|---it
| |
| |---filename.it.resx
|
|---en
|
|---filename.en.resx


HTH
Regards
Harsh Thakur
 
Actually I believe the VS project system is including the directory name
into the resource name. So I would change your code correspondingly:
resourceManager = new
ResourceManager("MyProject.Resources.Captions",
Assembly.GetExecutingAssembly());
 
Back
Top