WPF:本地化 - 视觉工作室设计师无法工作 [英] WPF: Localization - visual studio designer not working

查看:119
本文介绍了WPF:本地化 - 视觉工作室设计师无法工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的项目进行本地化。



经过一些研究后我很快找到了这个链接:

http://www.codeproject .com / KB / WPF / WPFUsingLocbaml.aspx



第三种选择是最理想的,所以这就是我想要的(摘自http://www.codeproject.com) /KB/WPF/WPFUsingLocbaml.aspx):


I am trying to do localization for my project.

After some research I quickly found this link:
http://www.codeproject.com/KB/WPF/WPFUsingLocbaml.aspx

The 3rd option is the most ideal, so this is what I wanted(taken from http://www.codeproject.com/KB/WPF/WPFUsingLocbaml.aspx):


"第三种方法既使用.Resx文件作为字符串,又使用LocBaml作为
本地化UI并使用.NET链接器将资源
链接在一起。这是迄今为止最困难的方法,因为它需要
对资源的命名和使用方式有所了解。它的优点
是Visual Studio设计器的工作原理,你根本不需要
来改变你的XAML文件。使用这种方法的另一个好处是
,你可以先完成你的应用程序,然后在UI中进行
的本地化[你还需要在代码中隔离给
用户的所有字符串 - 后面的文件]缺点包括必须在整个UI中翻译
,因为我们使用的是LocBaml。使用这种方法也无法实现
切换语言。"
"The third approach uses both a .Resx file for strings, and LocBaml for localizing the UI and uses the .NET linker to link the resources together. This is by far the most difficult approach, as it requires some understanding on how resources are named and used. Its advantages are that the Visual Studio designer works, and that you don't need to change your XAML file at all. Another advantage of using this method is that you can first finish your application, and do the localization of the UI afterwards [You still need to isolate all strings given to the user in code-behind files] Disadvantages include having to translate the entire UI because we are using LocBaml. Its also not possible to switch languages on the fly with this approach."




因此,每种语言都保留resx文件中的所有字符串(所以Resources.fr-FR.resx fe)。然后使用LocBaml生成正确的卫星dll,这样我以后可以添加语言而无需进行新的构建。



我遇到的问题是视觉问题studio 2008设计师不工作。



默认情况下,我希望将英语(en-US)作为语言,因此我将该语言放在Resources.resx中,其他语言也在例如Resources.fr-FR.resx < br>


我编辑了项目文件以包含"< UICulture> en-US< / UICulture>"并取消注释"assembly:NeutralResourcesLanguage(" en-US",UltimateResourceFallbackLocation.Satellite)]"在AssemblyInfo.cs中。



这是我的xaml文件:



So keeping all the strings in resx files per language(so Resources.fr-FR.resx f.e). then using LocBaml to generate the correct satellite dll's, that way I can add languages later without having to make a new build.

The problem I'm running into is that the visual studio 2008 designer isn't working.

By default I want english(en-US) as language, so I put that language in Resources.resx and the others in for example Resources.fr-FR.resx

I edited the project file to contain the "<UICulture>en-US</UICulture>" and uncommented the "assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]" in AssemblyInfo.cs.

this is my xaml file:

< 窗口x: = " LocalizationTest.Window1"
xmlns = " http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns: x = " http://schemas.microsoft.com/winfx/2006/xaml"
xmlns: properties = " clr-namespace:LocalizationTest.Properties"
标题 = " Window1" 高度 = " 300" 宽度 = " 300" >
< 网格 >
< 标签 高度 = " 28" 保证金 = " 12,12,136,0" 名称 = " label1" VerticalAlignment = " Top" >电流I ocalization: < / 标签 >
< 标签 高度 = " 28" Horizo​​ntalAlignment = " Right" 保证金 = < font style ="color:blue">" 0,12,12,0" 名称 = " lblCurrentCulture" VerticalAlignment = " Top" < font style ="font-size:11px"> 宽度 = " 118" > < / 标签 >
< 按钮 高度 = " 23" 保证金 = " 12,46,12,0" 名称 < font style ="font-size:11px"> = " button1" VerticalAlignment = " Top" x: Uid = " btnTest" 内容 = " {x:静态属性:Resources.btnTest}" > < / 按钮 >
< / 网格 >
< / Window >
<Window x:Class="LocalizationTest.Window1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:properties="clr-namespace:LocalizationTest.Properties" 
    Title="Window1" Height="300" Width="300"
    <Grid> 
        <Label Height="28" Margin="12,12,136,0" Name="label1" VerticalAlignment="Top">Current Localization:</Label> 
        <Label Height="28" HorizontalAlignment="Right" Margin="0,12,12,0" Name="lblCurrentCulture" VerticalAlignment="Top" Width="118"></Label> 
        <Button Height="23" Margin="12,46,12,0" Name="button1" VerticalAlignment="Top" x:Uid="btnTest" Content="{x:Static properties:Resources.btnTest}"></Button> 
    </Grid> 
</Window> 

推荐答案

您好,

请查看我的文章,我使用了本地化,并且我已经解释了如何使用resx文件。

http://www.codeproject.com/kb/wpf/witiymiwyg.aspx

我希望这会对你有所帮助:)
Hi,

please check my article, i have used Localization and also i have explained how to use resx files.

http://www.codeproject.com/kb/wpf/witiymiwyg.aspx

I hope this will help you :)


这篇关于WPF:本地化 - 视觉工作室设计师无法工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆