简体   繁体   English

是否有Visual Studio加载项用于从代码文件中的字符串填充资源文件?

[英]Is there a Visual Studio add-in for populating resource files from strings in a code file?

I'm maintaining a WinForms application which was not written using any development patters conducive to localizing the classes in the project which were not directly associated with forms, or the code-behind partials of the forms. 我正在维护一个WinForms应用程序,该应用程序不是使用任何有助于本地化项目中与表单没有直接关联的类或表单的代码隐藏部分的开发模式编写的。

Thus, there is MessageBox() code with English text in it in almost every code file. 因此,几乎每个代码文件中都有MessageBox()代码,其中包含英文文本。 I'd like to find a tool which will "scrape" those strings from the code, insert the strings in a resource file, and substitute a call to the resource with the substituted string in a comment. 我想找到一个工具,它将从代码中“刮掉”这些字符串,将字符串插入资源文件中,并用注释中的替换字符串替换调用资源。

Does such a tool exist? 这样的工具存在吗?

See ReSharper 5 Internationalization Features 请参阅ReSharper 5国际化功能

When ReSharper finds a localizable string, it helps you move it to a resource file with only a couple of clicks. 当ReSharper找到可本地化的字符串时,它可以帮助您将其移动到资源文件,只需点击几下。 You can optionally search for identical strings and refactor them to use the new resource item. 您可以选择搜索相同的字符串并重构它们以使用新的资源项。

Hope it helps. 希望能帮助到你。

Visual Localizer项目专注于这个问题,并且是免费的。

Resharper can do it. Resharper可以做到。 There is a Resharper plugin called RGreatEx that has a lot of localization refactorings for strings. 有一个名为RGreatEx的Resharper插件, 它对字符串有很多本地化重构。 I'm guessing you are looking for something free though, and both of these cost money. 我猜你正在寻找免费的东西,而且这两个都要花钱。 RGreatEx also hasn't seen updates in more than two years. RGreatEx在两年多的时间里也没有见过更新。

EDIT: Did some more searching, and found this tool on CodePlex. 编辑:做了一些搜索,并在CodePlex上找到了这个工具 It doesn't supporting pulling strings into resources, but it does have side-by-side editing of multiple resource files to ease writing string translations. 它不支持将字符串拉入资源,但它确实有多个资源文件的并排编辑,以便于编写字符串翻译。

ReSharper is of course the best in this field, as it can scan all strings in your code base and let you know which can be placed into resources. ReSharper当然是这个领域中最好的,因为它可以扫描代码库中的所有字符串,并让您知道可以将哪些字符串放入资源中。

But if you intend to use a free tool, Microsoft does have an open source one here, 但是如果你打算使用免费工具,那么微软确实有一个开源工具,

http://resourcerefactoring.codeplex.com/ http://resourcerefactoring.codeplex.com/

You have to manually scan all files using this tool as it is not as smart as ReSharper. 您必须使用此工具手动扫描所有文件,因为它不像ReSharper那样智能。

You can also use T4 templates to do this kind of thing. 您也可以使用T4模板来执行此类操作。 They're built into Vis Studio as of 2005 I think. 我认为它们已于2005年内置于Vis Studio中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM