yck1509 / ConfuserEx

An open-source, free protector for .NET applications
http://yck1509.github.io/ConfuserEx/
Other
3.55k stars 1.62k forks source link

Winforms localization after protection #471

Open Pmaslo opened 8 years ago

Pmaslo commented 8 years ago

Does ConfuserEx support localization in Windows Forms Applications? Do I need to enable anything specific in order for the localization to work?

It seems, that after the obfuscation the buttons, menus are always displayed in the Default language.

I have an application that supports a few languages. The Default language works ok, but the rest only work in part.

The part that works ok (for the non-Default languages) is the strings which are being pulled using My.Resources.MyResourceName.MeExampleString

Of course, the same application works properly, before obfuscation.

FWIW, my application changes Culture in the New() constructor of the main class, based on user settings, like this:

        If My.Settings.LocalizationLang = "Deutsch" Then
            My.Application.ChangeCulture("de")
            My.Application.ChangeUICulture("de")
            Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("de")
        Else
            My.Application.ChangeCulture("en")
            My.Application.ChangeUICulture("en")
            Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en")
        End If
AndresRohr commented 5 years ago

I have exactly the same issue. I'm using the latest version in GitHub. Did somebody find out whether it is possible to confuse a localized solution in the meantime? A localized project like the one above has an additional subfolder 'de' with the file '(AppName).resources.dll' inside. When you analyze the 'Main.Designer.cs' you see that these resources will be loaded at runtime by a call System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main));. The resource manager will then look at Thread.CurrentThread.CurrentUICulture to pick the '(AppName).resources.dll' in the corresponding subdirectory. But how does ConfuserEx handle this?

AndresRohr commented 5 years ago

Ok, I could solve that now by looking into the source of ConfuserEx. For those who are interested:

If you do all this you will get a confused localized app.