This project is read-only.

Globalization and Localization in Modern UI

May 1, 2013 at 2:28 PM
Edited May 1, 2013 at 2:29 PM
As I can see, mui(Modern UI) uses a static Resource in Project Property Page. So the problem is raised when I use ModernDialog.ShowDialog() Function in a nonenglish UI Environment, for example Japanese and also Chinese.
By reading the source code, I found that ModernDialog Buttons' creation routine uses hard-coding string resource. As following:
    /// <summary>
    /// Gets the Ok button.
    /// </summary>
    public Button OkButton
    {
        get
        {
            if (this.okButton == null) {
                this.okButton = CreateDialogButton(FirstFloor.ModernUI.Resources.Ok, true, false, this.closeTrueCommand);
            }
            return this.okButton;
        }
    }
FirstFloor.ModernUI.Resources.Ok equls "OK". In nonEnglish Environment, We wound not like to see "OK".

Here is My question: Is there a easily way to do Localization job in Modern UI(imported as DLL)?

ps. I would prefer to use Modern UI DLL commonly, so I don't wanna modify the source code and recompile it.
May 1, 2013 at 6:14 PM
You need to create a satellite assembly for mui. MUI itself is en-us only.

Introduction to Satellite Assemblies
May 2, 2013 at 12:16 PM
Edited May 2, 2013 at 12:19 PM
kozw wrote:
You need to create a satellite assembly for mui. MUI itself is en-us only.

Introduction to Satellite Assemblies
I tried to create a satellite assembly for mui, but it failed! Help!
I made a txt file named "FirstFloor.ModernUI.Resources.zh-Hans.txt", which contained(as it was defined in mui projects' Resources.recx):
Cancel=取消
Close=关闭
NavigationFailed=导航失败
NavigationFailedFrameNotFound=不能导航到 {0},找不到任何 ModernFrame 目标 '{1}'
NavigationFailedSourceNotSpecified=不能导航到 {0},未指定源
No=否
Ok=确定
UIThreadRequired=操作需要UI线程
UnexpectedToken=意外的令牌
UnknownTokenType=未知令牌类型
Yes=是
As you can see, I translated these English into Simplified Chinese ones. The "zh-Hans" stands for Simplified Chinese.
Then I used "resgen FirstFloor.ModernUI.Resources.zh-Hans.txt" command to compile .txt file into .resources one.
After that, the followint command was executed:
al /t:lib /embed:FirstFloor.ModernUI.Resources.zh-Hans.resources /culture:zh-Hans /out:FirstFloor.ModernUI.resources.dll /template:FirstFloor.ModernUI.dll
And I got FirstFloor.ModernUI.resources.dll.
Finally, having copied FirstFloor.ModernUI.resources.dll to zh-Hans folder together with .resources file, I ran the demo, ModernDialog's buttons were still in English.
May 2, 2013 at 1:55 PM
Edited May 2, 2013 at 1:55 PM
That may be because the NeutralResourcesLanguageAttribute was missing from the mui binary. I've just checked in an update. You'll need to compile the latest source code for this.
May 3, 2013 at 2:17 AM
kozw wrote:
That may be because the NeutralResourcesLanguageAttribute was missing from the mui binary. I've just checked in an update. You'll need to compile the latest source code for this.
It works well, Thanks!
Sep 10, 2013 at 3:02 PM
Edited Sep 10, 2013 at 4:02 PM
Hi. Can't put the resource language to work. Successfully created UTF8 textfile FirstFloor.ModernUI.Resources.pt.txt with the content:
NavigationFailedFrameNotFound=Não foi possível navegar para {0}, não foi encontrado o destino '{1}'
Cancel=cancelar
Close=fechar
Maximize=maximizar
Minimize=minimizar
NavigationFailed=Navegação falhada
NavigationFailedSourceNotSpecified=Não foi possível navegar para {0}, origem não especificada
No=não
Ok=ok
Restore=repor
UIThreadRequired=Operation requires the UI thread
UnexpectedToken=Unexpected token
UnknownTokenType=Unknown token type
Yes=sim
Then did:
resgen FirstFloor.ModernUI.Resources.pt.txt pt\FirstFloor.ModernUI.Resources.pt.resources
followed by
al /t:lib /embed:pt\FirstFloor.ModernUI.Resources.pt.resources /culture:pt /out:pt\FirstFloor.ModernUI.resources.dll /template:FirstFloor.ModernUI.dll 
All went ok and the pt\FirstFloor.ModernUI.resources.dll was generated and copied to the bin\Debug\pt\FirstFloor.ModernUI.resources.dll

Unfortunately my messages still wont appear in pt even after copying all the files (.txt, .resources) into there. I've checked with procmon.exe and the dll is being loaded.

Also checked with ILSpy and everything seems ok with the localized version, and, for the sake of debugging I pulled the source code and added a new resource file Resources.pt.resx with the content above, recompiled, referenced the compiled assemblies and all went ok. So this can be a workaround but that means that I'll loose all updates and nuget package managment.

Any help?

Thx
Sep 10, 2013 at 9:29 PM
Is the locale of your app correctly set to PT (Thread.CurrentThread.CurrentCulture)?
Sep 11, 2013 at 10:16 AM
Hi. Yes it is, both CurrentCulture and CurrentUICulture are properly set. All other application resources are correctly being localized just the ones from the mui are missing. My guess is that the generated pt\FirstFloor.ModernUI.resources.dll is not signed as the main dll FirstFloor.ModernUI.resources.dll and thus the compiler will not load the resources.

From ILSpy
// FirstFloor.ModernUI.dll
// FirstFloor.ModernUI, Version=1.0.5.0, Culture=neutral, PublicKeyToken=2d21ec3cd074c59a
// pt\FirstFloor.ModernUI.resources.dll
// FirstFloor.ModernUI.resources, Version=1.0.5.0, Culture=pt, PublicKeyToken=null
But since the key is private can sign it with al /key

Thx
Sep 14, 2013 at 3:48 AM
Edited Sep 14, 2013 at 3:49 AM
saamorim wrote:
Hi. Yes it is, both CurrentCulture and CurrentUICulture are properly set. All other application resources are correctly being localized just the ones from the mui are missing. My guess is that the generated pt\FirstFloor.ModernUI.resources.dll is not signed as the main dll FirstFloor.ModernUI.resources.dll and thus the compiler will not load the resources.

From ILSpy
// FirstFloor.ModernUI.dll
// FirstFloor.ModernUI, Version=1.0.5.0, Culture=neutral, PublicKeyToken=2d21ec3cd074c59a
// pt\FirstFloor.ModernUI.resources.dll
// FirstFloor.ModernUI.resources, Version=1.0.5.0, Culture=pt, PublicKeyToken=null
But since the key is private can sign it with al /key

Thx
Try to use the most recently released mui.
Sep 14, 2013 at 10:13 AM
Hi. I'm already using it, as you can see I'm using the 1.0.5
// FirstFloor.ModernUI, Version=1.0.5.0, Culture=neutral, PublicKeyToken=2d21ec3cd074c59a
Sep 30, 2013 at 12:13 PM
I had the same problem as suwayking (the satellite Dlls could not be signed since we do not have the key) and I end up checking out the source code and recompiling the FirstFloor.ModernUI dll with my own key and it works...
Sep 30, 2013 at 12:16 PM
Hi. In the end that's what I did.
Oct 1, 2013 at 11:37 AM
I had the same problem.
Is there any other way to solve this without recompiling the source code?
Oct 1, 2013 at 1:05 PM
Since the key is private to kozw, there is no other way, not that I know of.

Probably a way to go is to propose that the current resources, through ResourceManager, be moved to a resourcedictionary so that they can be easily overridden.

I'll see if I can arrange some time to create and propose a patch to it.

Regards
Oct 1, 2013 at 1:09 PM
Wait, probably is not needed. I've come across this thread:
http://www.sdl.com/community/blog/details/8612/net-localization-localizing-and-testing-signed-assemblies

Which explains the signed process and more specifically, the delay-signed process.

I'm going to investigate this, and let you know.

Regards,
Sérgio Amorim