Silverlight本地化 [英] Silverlight localization

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

问题描述

翻译Silverlight 5应用程序(Prism + MEF)有哪些可用的选项?如果可能的话,我想:

  • 没有resx文件(我不喜欢它们的管理方式)
  • 宁可提取xaml字符串然后进行翻译(我认为有Microsoft提供的工具,该工具使用自定义属性标记了所有XAML节点并提取了字符串)
  • 在外部程序集中具有翻译(在Prism中它们可以是模块)并在需要时加载它们
  • 在运行时更改语言

我愿意就此主题提出建议和最佳做法.

LocBaml是我上面所说的,但似乎不适用于Silverlight

解决方案

我知道这将获得许多传统答案,但我也想提出一些我们尝试(并成功地)做过的完全原始的事情,以提高效率Silverlight的本地化:

完成后Silverlight项目的本地化

它基本上使用附加属性在XAML中提供钩子,用于动态更改本地化字符串.首次解析它们时,您的代码将有机会更改相关元素,而语言交换仅意味着重新加载当前页面.

使用简单的RIA服务调用从服务器数据库中获取本地化字符串.返回的条目是所选语言的简单键/值对.

此方法也没有传统绑定方法的开销(很大),您会发现很多.应用启动时,我们仅下载 所选语言字符串.它还可能允许将编辑/更正发送回服务器(如果您可以承担应用程序中编辑器的开销……我们已经做到了,但这是很多工作)./p>

P.S.我们使用的是PRISM,但是它在任何Silverlight应用程序中都可以正常运行,因为它没有依赖关系(例如,在Unity等上).

PPS.今晚回家时,我将为该系统发布一些代码片段.

(Resx真是上个世纪")

What are the avaliable options for translating a silverlight 5 application (Prism + MEF)? If possible I would like to:

  • not have resx files (I don't like the way they are managed)
  • rather have xaml string extracted and then translated (I think there was a tool from Microsoft, that marked all XAML nodes with custom attribute and extracted the strings)
  • have translations in external assemblies (in Prism they could be modules) and load them when needed
  • change language at runtime

I'm open to suggestions and best practices on this topic.

edit: LocBaml is what I was talking about above, but looks like it's not avaliable for Silverlight

解决方案

I know this will get a number of traditional answers, but I would also like to put forward something completely original we tried (and succeeded) doing ourselves for more efficient localisation of Silverlight:

Localisation of Silverlight projects after completion

It basically uses attached properties to provide hooks, in the XAML, for dynamic changing of localisation strings. When they are first parsed your code gets a chance to make changes to the related elements, and a language swap just means reloading the current page.

The localisation strings come down from a server database using a simple RIA services call. The entries returned are simple key/value pairs for the chosen language.

This method also does not have the (quite large) overhead of the traditional binding methods you will see a lot of. We download only the chosen language strings when the app starts up. It also potentially allows edits/corrections to be sent back to the server (if you can bear the overhead of an editor in the app... we did this but it was a lot of work).

P.S. We were using PRISM, but it works as well in any Silverlight app as there are no dependencies (e.g. on Unity etc).

PPS. I will post some code snippets for this system when I get home tonight.

(Resx is so "last century")

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

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