设置我所有表单的可本地化属性
有没有办法自动设置此属性?我们有数百种表单需要本地化,将所有这些表单设置为 true 将是一场噩梦。
有没有办法让 Visual Studio 将解决方案/项目中的所有表单设置为 Localized = true ?
Is there a way to automate the set of this property ? we have hundreds of forms that needs to be localized and it will be a nightmare going through all of them setting this property to true.
is there a way to make visual studio set all forms in the solution / project to Localizable = true some how ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您创建一个新的Windows窗体时,它没有*.resx文件以及designer.cs文件中的相关代码。当您将Form的Localized属性设置为True时,VS会将以下代码添加到designer.cs中,但它也会生成并添加*.resx文件。
由于 VS 添加了 *.resx 文件,因此无法仅查找和替换或剪切和粘贴代码。
我尝试记录一个 VS 宏来自动执行它,但是,它不会记录将可本地化属性更改为 True(不知道为什么)
这个临时宏可能是您的开始。您可以编写获取表单文件名列表并使用下面的宏代码循环遍历它们。
When you create a new Windows Form, it does not have have *.resx file and the related code in the designer.cs file. When you set the Form's Localizable property to True, VS adds the following code to the designer.cs but it also then generates and adds the *.resx file.
Since VS adds the *.resx file, there is no way to find and replace or cut and paste only code.
I tried to record a VS Macro to automate it however, it would not record changing the Localizable property to True (not sure why)
This temp macro maybe a start for you. You could write get the list of your form filenames and loop through them with the macro code below.
它由表单的 .resx 文件中的如下条目表示(针对 .NET Framework 版本进行调整):
自动将所有值切换为 true 的最简单方法可能是运行表单子类文件,加载其 .resx 文件作为 XML 来测试该元素是否存在,如果不存在则添加它。或者,您可以使用 ResXResourceReader 和 ResXResourceWriter 来读取和写入文件内容。
It's represented by an entry like the following (adjusted for .NET Framework version) in the form's .resx file:
The easiest way to automate toggling all the values to true would probably be to run through the Form subclass files, loading their .resx files as XML to test for the presence of the element, and add it if it isn't. Alternately, you could use a ResXResourceReader and ResXResourceWriter to read and write the file contents.