Single-assembly multi-language Windows Forms deployment (ILMerge and satellite assemblies / localization) - possible?
The only way I can see this working is by creating a class that derives from ResourceManager
and then overriding the InternalGetResourceSet
and GetResourceFileName
methods. From there, you should be able to override where resources are obtained, given a CultureInfo
instance.
ILMerge + localized resource assemblies
While I don't know the details on the reason why ILMerge integrates the assemblies correctly in 2 steps, this seems to be the only solution at the moment. Check my last edit in the question to see how I did this.
I'm still curious though why it fails to do so in 1 step...
C# Single-Assembly Multilanguage App - Resources not being loaded properly
As it turns out, I was eventually able to make it work, modifying slightly the CurrentUIculture line. It would seem the code does not try parental cultures (properly) because if I set it to the generic culture (that is, "de" instead of "de-DE") it works perfectly.
Thread.CurrentThread.CurrentUICulture = new CultureInfo(CultureInfo.InstalledUICulture.TwoLetterISOLanguageName);
I discovered this since it was the only evident difference between the ApplyResources calls from InitializeComponent() and ChangeLanguage().
Now, I do not why this is and there certainly may be a better solution out there, but it´s the only fix I found so far.
The strings part still doesnt work though :/
Localization using satellite assembly returns default language
I eventually found out what the problem was,
The problem was that the generated code for initializing the resourcemanager was looking like:
ResourceManager rm = new ResourceManager("LocalizationLab.Global", typeof(Global).Assembly);
After some puzzling i found out that it should be this:
ResourceManager rm = new ResourceManager("Global", typeof(Global).Assembly);
which worked!
Deploying .NET satellite assemblies in specific folder
By default the satellite assemblies are placed in the sub-directories directly below the executable file. If you want to move all the fr-FR
, ja-JP
and remaining folders for other cultures into the same folder Languages
you can do it by adding the following entry into the application configuration file:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="Languages"/>
</assemblyBinding>
</runtime>
</configuration>
This will indicate that when searching for assemblies the CLR should search in the default locations and also in the directory or directories specified by the privatePath
attribute of the probing
element. You can specify any directories that exists below the application executable file. When specifying more than one sub-directory you need to delimit each one with a semicolon.
Related Topics
Linq to SQL: Multiple Joins on Multiple Columns. Is This Possible
.Net Core 2.1 Identity Get All Users with Their Associated Roles
Dynamically Setting CSS Values Using ASP.NET
Arkit Body Tracking Using Xamarin and C# Inaccurate
C# Equivalent to Java's Charat()
How to Create a Task (Tpl) Running a Sta Thread
How to Implement Url Rewriting Similar to So
Many-To-Many with Extra Columns Nhibernate
Image Sequence to Video Stream
Clearing Page Cache in ASP.NET
Set Gridview Backcolor to Color from Datatable
How to Call Code Behind Server Method from a Client Side JavaScript Function
Does Java Have Something Similar to C# Properties
Using Image Control in Wpf to Display System.Drawing.Bitmap
Passing an Empty Array as Default Value of an Optional Parameter