简体   繁体   English

如何使用强型卫星组件?

[英]How to use strongly-typed satellite assembly?

In my particular scenario, different users have different requirements of what the text of messages, labels, etc are, even though there's no language change. 在我的特定情况下,即使没有语言更改,不同的用户对消息,标签等的文本也有不同的要求。 ie: the language always remains en-US. 即:该语言始终保留为美国语。

Currently, I have all my string resources in an internal resources file and I use strongly-typed in my code. 当前,我所有的字符串资源都存储在内部资源文件中,并且在代码中使用了强类型。

To move the string resources to a satellite assembly I'm following the following MSDN article . 要将字符串资源移至附属程序集,请关注以下MSDN文章 So far I've managed to create a .resources file and the corresponding satellite assembly. 到目前为止,我已经成功创建了.resources文件和相应的附属程序集。 In this article, the example to get a string resources uses GetString() instead of strongly-typed. 在本文中,获取字符串资源的示例使用GetString()而不是强类型。

So how do I tell the app do use a different satellite assembly without losing the ability to use strongly-typed access? 那么,如何告诉应用程序使用其他卫星程序集却又不会失去使用强类型访问的能力?

It may not be the ideal solution, but our approach to this problem was simply to have the resource keys as public static strings, and this list is the canonical source for key value names. 这可能不是理想的解决方案,但是我们解决此问题的方法只是将资源键作为公共静态字符串,而此列表是键值名称的规范来源。

So while they are just string values, it's easy to verify in code review that names aren't being simply free-formed in, and an acceptance test can verify that all of the keys which should be present in the source file do exist. 因此,尽管它们只是字符串值,但很容易在代码审查中验证名称不是简单地自由格式,并且验收测试可以验证源文件中应存在的所有键是否确实存在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM