[英]Handling multiple languages across multiple applications and shared libraries (.net)
We are developing products that will be used in the following way: 我们正在开发将以以下方式使用的产品:
I am already aware of products like RCWinTrans and handling multiple languages in VC++/MFC applications. 我已经知道诸如RCWinTrans之类的产品,并且可以在VC ++ / MFC应用程序中处理多种语言。 However, the requirements we are faced with here are more extensive and thus require us to make a few up front decisions that could be difficult to change long term, so ideally we want to make the best choice now. 但是,我们在这里面临的要求更加广泛,因此要求我们做出一些长期的决定,这些决定可能很难长期改变,因此理想情况下,我们希望现在做出最佳选择。
Based on my own knowledge, I have a few questions although I may be missing some tricks with .net that will be happily received. 根据我自己的知识,我有几个问题,尽管我可能会缺少一些将很高兴获得的.net技巧。 Here are my questions: 这是我的问题:
Thanks in Advance, 提前致谢,
Roger 罗杰
Have you considered using an Inversion of Control container like StructureMap or Unity ? 您是否考虑过使用Inversion of Control容器(例如StructureMap或Unity) ? That may allow you to keep the default resources together with the project (which IMHO makes most sense), while still allowing a customer to locally override resources as necessary. 这可能使您可以将默认资源与项目(IMHO最有意义)保持在一起,同时仍允许客户根据需要在本地覆盖资源。
As an example, assume you have the following interface: 例如,假设您具有以下界面:
public interface IResourceSupplier
{
// Returns the localized text for a given identifier.
string Localized(string identifier);
// Returns the invariant (English) text for a given identifier.
string Invariant(string identifier);
}
Using IOC, you could create a centralized resource supplier for the solution which would check for user-supplied overrides. 使用IOC,您可以为解决方案创建集中式资源供应商,该供应商将检查用户提供的替代。 If no user override is provided, then you could query each of the project-specific resource suppliers (detected at application startup) until you locate one which returns the desired resource. 如果没有提供用户替代,则可以查询每个特定于项目的资源供应商(在应用程序启动时检测到),直到找到一个返回所需资源的供应商为止。
Obviously, depending on your needs you may need to tweak for performance, for example by caching frequently used resources. 显然,根据您的需求,您可能需要调整性能,例如,通过缓存常用资源。 Using IOC does give the advantage that as long as the interface does not change, plugging in an alternate implementation can be a relatively trivial task. 使用IOC的确具有以下优点:只要接口不变,插入替代实现可能是相对琐碎的任务。
Does this help? 这有帮助吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.