c# - 使用输出消息参数进行本地化 C#

标签 c# .net localization

在我的应用程序中,我打印消息,有些是调试消息,有些需要作为弹出窗口启动。
我必须使用本地化,如下所述:How to use localization in C#
我的问题是,如果我的输出基于数据成员,我如何将其发送到 Value 并在 resx 文件中使用它?
我的输出日志是:

string.Format("Operation Id = {0} has failed", opId);

但是当我希望将其添加为本地化时,我无法将数据成员 opId 放入值(在我的 output_messages.resx 中)。

最佳答案

您存储格式字符串,即 resx 可能包含:

Operation Id = {0} has failed

(against some key)

Then you can use:

string.Format(yourResources.WhateverNameYouUsed, opId);

关于c# - 使用输出消息参数进行本地化 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16893952/

相关文章:

c# - 如何更改 ToolTip 在 TreeView 上的位置?

c# - 从 OutOfMemoryException 中恢复

javascript - clndr.js 月份的本地化

iphone - UIBarButton 本地化问题

c# - NAudio:正确使用 MixingSampleProvider 和 VolumeSampleProvider

c# - 将复杂参数传递到 GET 请求中

c# - 如果 TextBox 为特定值,则将 dateTimePicker 设置为 Null

c# - 使用 TCP 发送多个字符串太快了我该如何等待?

.net - EF 5 Code first Entities FirstOrDefault 方法返回 null

ios - 禁止 ios 通过本地化更改 GUI Controller 位置