WPF中的多语言 [英] Multilanguage in WPF

查看:267
本文介绍了WPF中的多语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您能推荐一种为WPF应用程序实现多语言系统的好方法吗?我现在使用的方法涉及XML,类和xaml扩展.在大多数情况下,它都可以正常工作,但是当我不得不处理动态标签或动态文本时,通常需要付出额外的努力.我想让程序员仅在主要问题上工作,而忘记了lang问题.

Can you recommend a good way to implement a Multilanguage system for a WPF app? The method I'm using right now involves XML, classes and a xaml extension. It Works fine in most of cases, but when I have to deal with dynamic labels or dynamic text in general it require some extra effort. I would like to let the programmer working only in the main problem and forgot the lang issues.

推荐答案

我正在使用 WPF本地化扩展.这是在DependencyObject上本地化任何类型的DependencyProperty的简单方法.

I am using the WPF Localization Extension. It is a really easy way to localize any type of DependencyProperty on DependencyObjects.

  • 处于真正的稳定状态
  • 支持类似Text = {LocText ResAssembly:ResFile:ResKey}
  • 的类似绑定的书写样式
  • 使用.resx-fallback机制(例如en-us-> en->独立文化)
  • 支持文化强迫(例如这必须一直是英语")
  • 使用普通的依赖项属性
  • 使用控制模板
  • 可以在XAML中使用(确实是:P),而无需任何其他名称空间
  • 可以在后面的代码中用于将本地化值绑定到动态生成的控件上
  • 实施INotifyPropertyChanged以供高级使用
  • 支持字符串格式,例如"this is the '{0}' value"
  • 支持前缀和后缀值(当前带有LocText扩展名)
  • 用于生产系统(例如我的公共关系产品)中
  • 将语言切换为运行时会影响时间片
  • 可以与所有程序集中的任何资源文件(.resx)一起使用(也可以在运行时动态加载的文件)
  • 不需要任何初始化过程(例如调用xyz来注册特殊的本地化字典")
  • 在设计时可用(MS Expression Blend,MS Visual Studio 2008(普通版和SP1)
  • 在设计时可以更改所选语言
  • 可以本地化任何类型的数据类型,只要它存在一个转换器(TypeConverter)(扩展LocalizeExtension)
  • 已内置支持Text,上层Text,下层TextImage s,Brush es,DoubleThickness
  • 不会影响任何内存泄漏
  • 保留UID属性不变
  • 提供SpecificCulture用作IFormatProvider(例如(123.20).ToString(LocalizeDictionary.SpecificCulture) = "123.20""123,20")
  • 提供一些功能,以检查并获取背后代码中的资源值
  • 不会更改Thread.CurrentCultureThread.CurrentUICulture上的文化(可以轻松更改)
  • is in a real stable state
  • supports binding-like writing style like Text = {LocText ResAssembly:ResFile:ResKey}
  • works with the .resx-fallback mechanism (e.g. en-us -> en -> independent culture)
  • supports culture forcing (e.g. "this has to be English all the time")
  • works with normal dependency properties
  • works with control templates
  • can be used in XAML (really :P) without any additional namespaces
  • can be used in code behind to bind localized values to dynamic generated controls
  • implements INotifyPropertyChanged for advanced use
  • supports string formatting e.g. "this is the '{0}' value"
  • supports prefix and suffix values (currently with LocText extension)
  • is in use in productive systems (like my public relation product)
  • switching of the language to runtime affects NO timeslice
  • can be used with any resource file (.resx) across all assemblies (also the dynamic loaded one at runtime)
  • doesn't need any initializing process (like "call xyz to register a special localize dictionary")
  • is available at design-time (MS Expression Blend, MS Visual Studio 2008 (Normal and SP1)
  • change of the chosen language is possible at design-time
  • can localize any type of data type, as long as a converter (TypeConverter) for it exists (extends LocalizeExtension)
  • has built in support for Text, upper Text, lower Text, Images, Brushes, Double and Thickness
  • doesn't affects any memory leaks
  • leaves the UID property untouched
  • offers a SpecificCulture to use as IFormatProvider (e.g. (123.20).ToString(LocalizeDictionary.SpecificCulture) = "123.20" or "123,20")
  • offers some functionality to check and get resource values in code behind
  • doesn't alter the culture on Thread.CurrentCulture or Thread.CurrentUICulture (can be changed easily)

这篇关于WPF中的多语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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