C# 字符串翻译

标签 c# string internationalization translation

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/

相关文章:

c# - 如何知道线程是否被垃圾收集阻塞

c# - 将二进制格式化程序与异步套接字一起使用

c - strcpy 运行时错误/非空目标

Django i18n : Specifying context. (msgctxt)

spring - 消息包键中的空格

node.js - 如何在不重新启动 Node 服务器的情况下反射(reflect)语言环境更改 - i18n?

c# - 将字符串转换为字符串[],然后将字符串[]转换为字节[]

c# - 正则表达式性能优化

java - (Java String.format) 无法将此列设置为固定宽度

c# - 覆盖文本文件的第一行(c#)