MFC / C#.NET mixed mode localization (multi language / multilingual application) - c#

we have a complex application here which is written in MFC and C# and running in mixed-mode. We're now trying to set up a multi-lingual version of this application. So I created English resource files (in the .NET part) for every existing resource file and translated all necessary strings. E. g.: MyResource.resx and MyResource.en.resx. Original language is German.
Now if I start the solution containing only the .NET-Projects with the Thread.CurrentThread.CurrentUICulture set to 'en-US' all the dialogs and texts appear in English as expected. The MFC part (the compiled code in the .exe file) is translated with a tool called Lingobit which replaces the strings in that .exe file and it works fine. So far, so good.
But when it comes to start the full mixed-mode application all the English resource files of the .NET part are ignored and it falls back to the German ones.
I additionally tried to use Lingobit to translate the .NET-DLLs. Lingobit creates a separate mylib.resource.dll of my original mylib.dll which seems to be ignored, too.
I'm running out of ideas here how to create an English version of this application. Any suggestion how to make my mixed-mode application use the English resource files?
Thanks in advance.

The solution itself was quite simple, but it took me a while to find it. If you compile the .Net project Visual Studio creates a "en"-Folder in your output folder (e. g.: bin/Debug/). This folder is not created with the compilation of the mixed mode version, so just copy it from your .Net output folder to your mixed mode output folder.
In addition I'll create a little script to copy it to the needed location after the build.
Have a good one everybody.

Related

Cultureinfo not applied after build on build server

Ok, this one is really weird.
We have a main project. Lets call it 'MyApplication'.
To make it multilingual, we added a new project in the solution called 'MyApplication.Languages' which contains all the resx files in different languages.
In our Main() we have the following code to switch the CultureInfo:
Thread.CurrentThread.CurrentUICulture = new CultureInfo("nl-NL");
Obviously, we have a resx.nl-NL file and we are referencing this file in our code.
This works perfectly when we execute the code locally, whether it is in Debug or Release mode.
But when the application is build on the build server, the language is never anything other then English. Even when we explicitly set it to "nl-NL" like in the example above.
Does anyone have any idea what could be the issue here?
After much trial and error we found out that the multilingual files where not stored in 1 assembly, but in several (one for each language that is configured).
These assemblies are stored in separate folders. In our case en and nl
During the copy from the artifacts directory, we did not take this into account and therefore, there was no other language then the default English
Hope this helps anyone out there

Use all culture versions of resources files in UWP app

Accoding to Andy Wigley on this video https://www.microsoftvirtualacademy.com/en-US/training-courses/a-developer-s-guide-to-windows-10-12618 (look in additional resources -> Localization), UPW apps download only the culture resources they need.
I'm writing an app that uses resource files not only to translate UI but also generate files for the user. User may want to generate files in different culture than the one the OS uses. How I can assure that e.g. if my system is in en-US I will be able to get resources in french?
I may use own XML files that all will be included in the app. But some of the resource for sure will be needed also in UI, so I don't want to duplicate the resources and have to translate them twice.
Rob's answer would work great for a new app, but it didn't work for me, as I had already shipped a previous version of the app as a bundled package. If you then try to switch to a non-bundled package, the store submission portal gives the error:
A previous submission for this app was released with a Windows 10 appxbundle. Subsequent submissions must continue to contain a Windows 10 appxbundle.
After reverse-engineering far too much of the build system, I found enough clues to discover this well-hidden documentation: https://msdn.microsoft.com/en-us/library/dn482043.aspx
Following the steps there, you'll still create a bundled package, but the toolchain won't use Language as a qualifier on which to separate out different bundles. In other words, the neutral package will have all the languages in it, while still bundling satellite packages for Scale (or whatever you like).
In case the MSDN page vanishes, the punchline is that you can override <AppxBundleAutoResourcePackageQualifiers> in your msbuild file to remove the Langauge qualifier:
<AppxBundleAutoResourcePackageQualifiers>Scale</AppxBundleAutoResourcePackageQualifiers>
If you do not want to separate out resources into separately downloadable bundles then you don't need to. When you build the app package you can choose to never create bundles so all resources are included in the main package.
See step six in Create an app package at https://msdn.microsoft.com/en-us/library/hh454036.aspx , but choose "never" instead of "always".

Visual Studio C# Updating Localized Languages resx

I have multi Language Application, first it was made in English only,
than one time i added support for German and Russian version and send resx files for translation to mates.
But while they do translation, i added few more checkboxes in GUI
and now when i copy their files and load German \ Russian GUI version those not translated checkboxes do not shown in in those languages.
My Question is:
Is there a way to update localized .resx files to version of main, as i can see it:
in Localized files if controls are missing - they will display in default language.
For translation they used: Zeta Resource Editor
Found answer by myself :) Maybe someone need it:
In this free program (Zeta Resource Editor) You can Add group of existing resources from Your VS Project - just select them an add, Zeta Resource Editor will auto show which strings are missing, so you can easily find them.

Confusing C# code with Confuser does not work with language resource files (DLLs)

I have a C# project (WinForms) in Visual Studio 2012, running Windows 7 Professional 64bit.
My WinForms app comes with two languages - English and German.
Thus, in my Visual Studio project, I have two resource files (.resx) lang.resx (containing my default language, German) and lang.en-GB.resx (containing my optional language, English).
When I compile my project for .NET 3.5, VS creates two folders in my app project folder, "de_DE" and "en_GB", and copies DLL files containing the language stuff into those two folders (both files are named "app.resources.dll").
So far, so good. My app works well, when not "confused". When run on an English copy of Windows, it shows English text, when run on a German or any other language copy of Windows, it shows German text... As expected.
Now, I am confusing my code with Confuser (found on CodePlex: https://confuser.codeplex.com/), using Confusor version 1.9 (the latest, pre-compiled, downloadable .exe version).
When I add my "app.exe" and "de-DE\app.resources.dll" and "en-GB\app.resources.dll" to confuser, the confusor will only generate 1 confused app.resources.dll - not 2 (one for each language / resource DLL).
That means, I cannot switch between languages as only ONE app.resources.dll seems to be considered by confuser (not both).
I guess my project setup is nothing special or outstanding (plain olde WinForm app with more than one language).
My question is:
How do I have to configure the confuser so that it confuses my app.exe and the two app.resources.dll files correctly?
Any help (or even hint) is greatly appreciated!
On the confuser patch listings it addresses your exact issue:)
http://confuser.codeplex.com/sourcecontrol/list/patches
Patch ID 14664 is about your issue, and it looks like you need to set the entries in the project file (taking an excerpt of their own site):
An example with language files, showing what the output should be:
Executables\Common.resources.dll -> targetfolder\common.resources.dll
Executables\de\Common.resources.dll -> targetfolder\de\common.resources.dll
Executables\fi\Common.resources.dll -> targetfolder\fi\common.resources.dll
etc.
After patching this can now be achieved with the following kind of project file:
...
<assembly path="..\Executables\Common.resources.dll" />
<assembly path="..\Executables\de\Common.resources.dll" toSubFolder="de" />
<assembly path="..\Executables\fi\Common.resources.dll" toSubFolder="fi" />
Cannot you merely rename DLLs ?
de-DE\app.resources.dll => de-DE_app.resources.dll
en-GB\app.resources.dll => en-GB_app.resources.dll

Tool for creating resource file

In our company we have a software program that operates the machines that we produce. The application (HMI) that is running on a WES7 OS is programmed in C#. Because our machines are shipped all over the world, the language of the HMI can be adjusted by clicking on a language button.
The HMI software is written by a third company but we have it in our own control now. The machine's we deliver might have project specific "fault" messages and must be added to the HMI. This means that these specific "fault messages" must be added to the resources.resx file. But for as far as I know, this can only be done from Visual Studio, do a build and a new file ExternalResources.xap file is created with all translations (Multilanguage).
We don't want a specific application for each customer or do a build on the project for only creating the ExternalResources.xap file. So I'm wondering if there are tools available that run standalone (no Visual Studio needed) and that can create the ExternalResources.xap file.
We don't need to add sources to the resources file, but only change the value of a source on project wish. I hope I made my point clear and someone knows a solution.
Edit:
I need to generatoe the ExternalResources.xap file. When you open this file, all locations available are shown in folders, and within this folders, there are *.recourses.dll files. Those files do I need to generate!
You may use Resgen.exe
Or develop some tool for that, here is a useful sample Extended Strongly Typed Resource Generator
Hope this helps.

Categories

Resources