简体   繁体   中英

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.

Thus, there is MessageBox() code with English text in it in almost every code file. 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

When ReSharper finds a localizable string, it helps you move it to a resource file with only a couple of clicks. 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. There is a Resharper plugin called RGreatEx that has a lot of localization refactorings for strings. 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.

EDIT: Did some more searching, and found this tool on 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.

But if you intend to use a free tool, Microsoft does have an open source one here,

http://resourcerefactoring.codeplex.com/

You have to manually scan all files using this tool as it is not as smart as ReSharper.

You can also use T4 templates to do this kind of thing. They're built into Vis Studio as of 2005 I think.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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