473,797 Members | 3,152 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Localization - Real examples using satellite DLLs and C#.

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 specific regional
variations of that language in the satellite dll. That,
I can get to work.

The code I was using could load the currently executing
assembly, and pick out resources embedded in that without
any troubles.

Also, if I load a different satellite assembly, and use
the resourcemanager object on that, I can also make that
work. What I don't understand is, how is this useful? I
mean, if you must load the satellite assembly before
accessing the resource, it has to be hard coded in the
project (or you write something to trawl through a
particular location, loading all assemblies there?)

Here's a little snippet of what I'm trying to make use
of, but presently is of little use at all....

System.Reflecti on.Assembly myAssembly = this.GetType
().Assembly;
System.Reflecti on.Assembly myOtherAssembly ;
myOtherAssembly = System.Reflecti on.Assembly.Loa d
("SatelliteReso urce");
System.Resource s.ResourceManag er rm = new
System.Resource s.ResourceManag er
("SatelliteReso urce.resource", myOtherAssembly );

System.Globaliz ation.CultureIn fo thisCulture =
System.Threadin g.Thread.Curren tThread.Current Culture;
string retVal = rm.GetString
("System.NullRe ferenceExceptio n", thisCulture);

MessageBox.Show (retVal);

I'd like this to be useful in that I can also have other
satellite resources, and add them into the application at
a later date without the need to recode.

Is trawling through and loading all dlls the smartest way
to do it??

Any suggestions would be highly appreciated...

Cheers.
Nov 15 '05 #1
1 10534
"Martin Platt" <ma**********@h cn.com.au> wrote in message
news:08******** *************** *****@phx.gbl.. .
From what I understand you must have a fallback for a
particular language, as well as specific regional
variations of that language in the satellite dll. That,
I can get to work.

The code I was using could load the currently executing
assembly, and pick out resources embedded in that without
any troubles.

Also, if I load a different satellite assembly, and use
the resourcemanager object on that, I can also make that
work. What I don't understand is, how is this useful? I
mean, if you must load the satellite assembly before
accessing the resource, it has to be hard coded in the
project (or you write something to trawl through a
particular location, loading all assemblies there?)


Here's how we do it. In our case, we don't build the fallback resources
into the main application, to save space. We don't have to load the
resource dll - it happens for us. This snippet is from a function that
takes a constant string (constantName) that identifies the resource string
we want to load.
ResourceManager resourceManager = null;

string resourceString = "";

try
{
resourceManager = new ResourceManager ("LR",
Assembly.GetExe cutingAssembly( ));
}
catch (Exception resourceEx)
{
Console.WriteLi ne("Could not create resource manager. Error: " +
resourceEx.Mess age);
}

try
{
resourceString = resourceManager .GetString(cons tantName);
}
catch (MissingManifes tResourceExcept ion)
{
// we couldn't find the right resource. We're probably running in
// a locale that we do not have a language DLL for. We should try to
// fall back to US English

try
{
CultureInfo culture = new CultureInfo("en-US");
resourceString = resourceManager .GetString(cons tantName, culture);
}
catch (Exception cultureEx)
{
// last chance - no idea what went wrong
resourceString = "Could not get string from resource manager";
}
}
catch (Exception ex)
{
// no idea what went wrong
resourceString = "Could not get string from resource manager.";
}

return resourceString;
Nov 15 '05 #2

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

Similar topics

2
14853
by: Dan | last post by:
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...
2
1940
by: Kallis | last post by:
Hello, I have the following situation when trying to localize my software: I have BIG solution with about 80 projects. In one of the projects I have a number of dialogs (the dialog project :-) ). I have decided that I do not want to use the "form"-mechanism (using the property "localized=true") for localization since the strings I show are not that "constant" during the life time of the dialog. Thus, I have to put the resources in...
3
1149
by: Ian | last post by:
Hi there, I am trying to follow this guide (http://www.c-sharpcorner.com/Code/2004/March/MultilingualAppsInNet.asp) with regards to creating a multi language application. I want to offer 2 languages at the beginning - English and Spanish. My question is, do I need to embed the resource file for each language inside my main app?
1
2394
by: MarkMurphy | last post by:
We had downloaded the Enterprise Localization Framework a few months ago for evaluation and were using it under .NET Framework 1.0. We've just now upgraded to .NET Framework 1.1 and have started having problems. When attempting to generate resource dlls with LocalizationManagement.exe, I get an exception: Unable to generate loose file resources: The type initializer for "Microsoft.Toolkits.EnterpriseLocalization.ElementResourceSet"...
5
2194
by: Hannes Schmiderer | last post by:
We have to support different languages in our application. We do not want to compile the whole application if anything changes in the text of the pages. With satellite assemblies this is possible easily. We change the .resx XML-resource-file, run resgen.exe and al.exe and we have a new dll. But how is this possible with the neutral/default/fallback language resource which is integrated in the main assembly?
6
1991
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 --->LocalizationManagement.exe, I get an exception: --->Unable to generate loose file resources
1
2572
by: Nathan | last post by:
We have a project that contains a number of DLLs. One DLL is a library containing User Interface utilities that are used in most of our forms. As we plan to localize all our strings, we've added a project that contains only string resources. The structure in solution explorer looks like: Utilities (Project) -- UtilityA.cs -- UtilityB.cs Utilities_en (Project) -- ResourceA.en.resx
5
2653
by: CMM | last post by:
I don't seem to "get" ASP.NET 2.0's Localization features. I've read up on everything... and of course, everything is explained in cursory softball terms- not any "real-world" usage way. I hope someone can give me a clue... Questions: 1) Do my eyes deceive me or is it true that localization is still totally utterly disengaged from the Designer and Property Editor... either in source
0
2243
by: thayes | last post by:
I'm developing an app using WPF, and have just started looking into localization. I have gotten the BAML localization solution working (with LocBaml and CSV files), but I'm a bit perplexed when it comes to translation of strings at runtime. For example, I am building a search window, and when a search is performed, I update a header to tell the user how many results were found. I can understand how the satellite assemblies are used to fill in...
0
10469
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10246
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9066
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7560
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6803
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5459
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4135
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3750
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2934
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.