473,672 Members | 2,970 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 10526
"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
14843
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
1928
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
1143
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
2385
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
2188
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
1983
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
2565
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
2646
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
2240
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
8508
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8428
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8953
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...
1
8652
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6264
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
5727
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();...
1
2849
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
2104
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1851
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.