質問

In our WPF plugin project we use LocBaml tool to localize UI. But now it is needed to localize a string inside a cs file:

ToolInfo.MenuCaption = "&Toggle console";

I've found some localization topics:

WPF Localization - On-the-fly Language Selection

WPF Application Framework (WAF)

WPF Localization Extension

It seems that for using these 3rd party tools it is needed to remove LocBalm implementation and write a new one.

Is it possible to stay with LocBaml tool and add a translation just for this string in cs file?

役に立ちましたか?

解決

If the custom localization is taking place only in codebehind (cs file(s)), there's no reason that I can see for it to not work with LocBaml.

You could always use a hack to use LocBaml for this localized string as well, something like this :

<TextBlock x:Uid="HiddenText" Name="HiddenText" Text="&Toggle console" Visibility="Collapsed" />

And in codebehind :

ToolInfo.MenuCaption = HiddenText.Text;

This is kind of mildly awful, but you should be able to still localize the string with LocBaml this way.

Otherwise, you'll have to string together a separate system yourself - something with resource strings and a resource manager, most likely - or try to get one of the localization platforms to play nice with LocBaml.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top