C#
是否提供一种即时翻译字符串的方法或类似的方法?
我现在正在处理一些遗留代码,其中有一些部分是这样的:
section.AddParagraph(String.Format("Premise: {0}", currentReport.Tenant.Code));
section.AddParagraph(String.Format("Description: {0}", currentReport.Tenant.Name));
section.AddParagraph();
section.AddParagraph(String.Format("Issued: #{0:D5}", currentReport.Id));
section.AddParagraph(String.Format("Date: {0}", currentReport.Timestamp.ToString(
"dd MMM yyyy", CultureInfo.InvariantCulture)));
section.AddParagraph(String.Format("Time: {0:HH:mm}", currentReport.Timestamp));
因此,我想根据一些替换表 即时实现这些字符串的翻译(例如,Qt
所做的)。
- 这可能吗(可能,使用
C#
已有的东西或使用一些后处理 - 使用PostSharp
可能有可能)? - 是否存在用于使用
C#
(从头开始) 构建的应用程序的一些通用内部化方法?
最佳答案
Does some generic internalization approach for applications built with C# (from scratch) exist?
是的,使用 resource files .这是another article在 MSDN 上。
关于C# 字符串翻译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6602860/