locked
Easy way to find all string litterals in my C++ code? RRS feed

  • Question

  • I have a large C++ project (over 3k files weighing in at just under 40MB) and need to find all the strings in there that need localization (so I can take them out and put them in the strings database). Is there a way (using Visual C++ 2017 or some extension for it or something) to find all the string literals in my code so I can then scan the list to figure out the ones that need to be localized. Google shows up a few regexes but those pick up all the #include lines and comments and other things that have a " character in there which makes finding the actual literals too hard.

    Is there a way to make VS (or some other tool) do what I want and show me just the string literals?

    Saturday, July 27, 2019 1:56 AM

All replies

  • Maybe, run the binary thru strings first.

    Then filter out all junk you don't want to localize.

    Then search remaining strings in source files with something like grep

    -- pa

    Saturday, July 27, 2019 7:46 PM
  • It is very, very time-consuming to internationalize an application that was not designed for it from the beginning.  There's really no way to automate it.  First, you have to figure out how you're going to do the substitution.  Are you going to switch to string resources, so you can just substitute a new resource DLL?  That's the easy way to substitute, but it means you need to convert every translatable string usage to a string resource fetch.  And that means you really do need to look at every file to figure which strings need localizing and which can be left as constants.  You can't really automate that process; grep doesn't know which strings need localizing and which do not.

    I'm afraid you have a lot of rather tedious work ahead of you.


    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    • Proposed as answer by Guido Franzke Wednesday, July 31, 2019 12:20 PM
    Sunday, July 28, 2019 6:26 AM