473,396 Members | 1,879 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,396 software developers and data experts.

satellite assemblies and localization

Dan
I am creating a c# class library project to be used by some exe clients.
This library needs to be localized for its text messages using satellite
resource-only assemblies; I have created the library with an embedded
resource for the default language and a sample satellite assembly with
strings for another language, plus a dummy test client application, but the
library always falls back to the default resources. Here's what I do: could
anyone tell me what's wrong?

1) I create a new c# class library project, named e.g. Localizable;
2) I add a resource (Strings.resx) file to this project and insert some
string resources in the default language (english): e.g. HELLO = "Hello";
3) outside this project, I 'manually' create another resx file e.g. for
italian named Strings.it.resx (with HELLO = "Ciao");
4) I run RESGEN Strings.it.resx to create Strings.it.resources;
5) I create a satellite assembly with AL:

al /t:lib /culture:it
/embed:Strings.it.resources,Localizable.Strings.it. resources
/out:Strings.resources.dll

6) I create a dummy test console application which uses a resource manager
to get the HELLO string first with the default culture then with the "it"
culture. Assuming that it's named Test.exe, in its directory I place the
Localizable dll and a subfolder (it) with the satellite assembly:
|- Test.exe
|- Localizable.dll
|- it\Strings.resources.dll

When I run Test, the strings always come in english. Could anyone give a
hint?
Here are the MANIFEST for the satellite assembly and the Localizable dll:

==== satellite assembly manifest ====
..assembly Strings.resources
{
.hash algorithm 0x00008004
.ver 0:0:0:0
.locale = (69 00 74 00 00 00 ) // i.t...
}
..mresource public Localizable.Strings.it.resources
{
}
..module Strings.resources.dll
// MVID: {CEB4DAA0-09ED-44AA-88D8-C53C495BD45F}
..imagebase 0x00400000
..subsystem 0x00000003
..file alignment 512
..corflags 0x00000001
// Image base: 0x06e60000

==== library assembly manifest ====
..assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) //
..z\V.4..
.ver 1:0:5000:0
}
..assembly Localizable
{
.... (snip) ...
}
..mresource public Localizable.Strings.resources
{
}
..module Localizable.dll
// MVID: {762391D6-143E-4337-9977-283F628D4491}
..imagebase 0x11000000
..subsystem 0x00000003
..file alignment 4096
..corflags 0x00000001
// Image base: 0x06e60000
Nov 15 '05 #1
2 14809
Does the class in test.exe live in a namespace? If so, then your resources
file must have the namespace in it and when you retrieve it, you also
retrieve it by the namespace. Example:

resgen strings.it.resx yournamespace.yourclass.it.resources
al /t:lib /embed:yournamespace.yourclass.it.resources /culture:it
/out:test.resources.dll

test -

CultureInfo it = new CultureInfo("it");
ResourceManager res = new ResourceManager("yournamespace.yourclass",
this.GetType().Assembly );
Console.WriteLine( res.GetString("HELLO", it));

rajasi

"Dan" <fu***@iol.it> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I am creating a c# class library project to be used by some exe clients.
This library needs to be localized for its text messages using satellite
resource-only assemblies; I have created the library with an embedded
resource for the default language and a sample satellite assembly with
strings for another language, plus a dummy test client application, but the library always falls back to the default resources. Here's what I do: could anyone tell me what's wrong?

1) I create a new c# class library project, named e.g. Localizable;
2) I add a resource (Strings.resx) file to this project and insert some
string resources in the default language (english): e.g. HELLO = "Hello";
3) outside this project, I 'manually' create another resx file e.g. for
italian named Strings.it.resx (with HELLO = "Ciao");
4) I run RESGEN Strings.it.resx to create Strings.it.resources;
5) I create a satellite assembly with AL:

al /t:lib /culture:it
/embed:Strings.it.resources,Localizable.Strings.it. resources
/out:Strings.resources.dll

6) I create a dummy test console application which uses a resource manager to get the HELLO string first with the default culture then with the "it"
culture. Assuming that it's named Test.exe, in its directory I place the
Localizable dll and a subfolder (it) with the satellite assembly:
|- Test.exe
|- Localizable.dll
|- it\Strings.resources.dll

When I run Test, the strings always come in english. Could anyone give a
hint?
Here are the MANIFEST for the satellite assembly and the Localizable dll:

==== satellite assembly manifest ====
.assembly Strings.resources
{
.hash algorithm 0x00008004
.ver 0:0:0:0
.locale = (69 00 74 00 00 00 ) // i.t...
}
.mresource public Localizable.Strings.it.resources
{
}
.module Strings.resources.dll
// MVID: {CEB4DAA0-09ED-44AA-88D8-C53C495BD45F}
.imagebase 0x00400000
.subsystem 0x00000003
.file alignment 512
.corflags 0x00000001
// Image base: 0x06e60000

==== library assembly manifest ====
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) //
.z\V.4..
.ver 1:0:5000:0
}
.assembly Localizable
{
... (snip) ...
}
.mresource public Localizable.Strings.resources
{
}
.module Localizable.dll
// MVID: {762391D6-143E-4337-9977-283F628D4491}
.imagebase 0x11000000
.subsystem 0x00000003
.file alignment 4096
.corflags 0x00000001
// Image base: 0x06e60000

Nov 15 '05 #2
Dan
Thank U very much for your reply! anyway, I'm not sure I understand what you
mean, that is, I have 2 layers:

1) the DLL with my library which has 1 embedded resource and eventually
satellite assemblies for other languages;
2) any number of independent client apps using this DLL and belonging
toother projects, namespaces, etc.

Now, the test code which uses a ResourceManager to retrieve a string
resource is placed in the DLL itself (1), not in the EXE client application;
they are 2 different projects, and it is the DLL which needs some satellite
assemblies for localization. The EXE will simply call a function of the DLL
library, which in turn will eventually need to retrieve some string
resources to format response messages, e.g.:

--in the EXE (let's say the DLL lib is in the Localizable namespace and has
a Dummy class, and that the resource file is named Strings):
Localizable.Dummy dummy = new Localizable.Dummy();
Console.WriteLine(dummy.DoSomething());

-- in the DLL:
public class Dummy { ...
public string DoSomething()
{
CultureInfo it = new CultureInfo("it");
ResourceManager res = new ResourceManager("Localizable.Strings",
this.GetType().Assembly );
return res.GetString("HELLO", it);
} }

In this case, I should create the default resource name from the DLL
namespace (Localizable) + the resource filename (Strings):
Localizable.Strings(.resources), and add the LCID to the localized resource
name (Localizable.Strings.it(.resources)? Or this is not true? I have also
looked for a working sample, but I have found nothing with a localized DLL +
an independent EXE client... (it is always the case of a localized EXE, i.e.
just one "layer").
Thank you again...

"Rajasi Saha" <ra*****@online.microsoft.com> wrote in message
news:eZ**************@tk2msftngp13.phx.gbl...
Does the class in test.exe live in a namespace? If so, then your resources
file must have the namespace in it and when you retrieve it, you also
retrieve it by the namespace. Example:

resgen strings.it.resx yournamespace.yourclass.it.resources
al /t:lib /embed:yournamespace.yourclass.it.resources /culture:it
/out:test.resources.dll

test -

CultureInfo it = new CultureInfo("it");
ResourceManager res = new ResourceManager("yournamespace.yourclass",
this.GetType().Assembly );
Console.WriteLine( res.GetString("HELLO", it));

rajasi

Nov 15 '05 #3

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

Similar topics

0
by: Ben Jones | last post by:
Hi there, I am looking into the ease of implementing the localization/globalization features of .NET using C#. I have a test app which creates a ResourceManager and attempts to load a resource...
1
by: Afaq | last post by:
Hi, After adding large number of empty resource files (which will be updated later), we are not able to compile the project. the following is the output of the build process. It fails while...
0
by: BillKi | last post by:
I am working on localizing my webservice to return localized error messages to our client app. I have created 3 resx files, 1 for english (default), 1 for spanish, and 1 for italian. When I...
6
by: James | last post by:
I have two question regarding the version resource that is generated for a satellite assembly. 1) I have a file in my C# console app project called StringResources.en-US.resx. When I build the...
0
by: thbst16 | last post by:
After a number of weeks of fruitless research and experimentation, I decided to turn to the group with this issue and see if anyone had any experiences or insights that might help me out. Here's...
1
by: Martin Platt | last post by:
Guys! I've been playing about with some code trying to get the satellite assembly resource files to work. From what I understand you must have a fallback for a particular language, as well as...
3
by: BBC1009 | last post by:
Don't know why when rebuild VB.Net project (vb.net 2002 framework 1.0), this error comes out suddenly. Anyone can help. Thanks!!!!
0
by: Faris Ahmed | last post by:
Dear ASP newsgroup, I have the following environment: 1) VS2005 ASP.NET 2.0 WebApplication called MyApp. 2) MyApp contains Strings.resx, Strings.en.resx and Strings.de.resx in...
0
by: baretta | last post by:
Hi, When an assembly needs localization the recommended approach is creating a resource assembly that has the same name as the consuming assembly + ".resources" added to it, for instance...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.