In the quest for localization I need to find all the string literals littered amongst our source code. I was looking for a way to script this into a post-modification source repository check. (I.E. after some one checks something in have a box setup to check this stat) I'll probably use NAnt and CruiseControl or something to handle the management of the CVS (Well StarTeam in my case :( ) But do you know of any scriptable (or command line) utility to accurately cycle through source code looking for string literals? I realize I could do simple string look up based on regular expressions but want a little more bang for my buck. (Maybe analyze the string or put it into categories) Because a lot of times the string may not necessarily require translation. Any ideas?
A string literal is a programming string in which characters exist as their literal value rather than a variable and appear the same in code and in published material. They are denoted by delimiters. Delimiters are characters, often quotation marks or brackets, that contain a string literal.
A string literal is a sequence of zero or more characters enclosed within single quotation marks. The following are examples of string literals: 'Hello, world!' 'He said, "Take it or leave it."'
A string literal is a sequence of zero or more characters enclosed by single quotes. The null string ( '' ) contains zero characters. A string literal can hold up to 32,767 characters. PL/SQL is case sensitive within string literals.
A string literal is where you specify the contents of a string in a program. >>> a = 'A string' Here 'A string' is a string literal. The variable a is a string variable, or, better put in Python, a variable that points to a string. String literals can use single or double quote delimiters.
Visual Studio 2010 and earlier:
:q
(quoted string)Find Results window will now contain a report of all files, with line numbers and the line itself with the quoted string.
For Visual Studio 2012 and later search for ((\".+?\")|('.+?'))
(reference, hat-tip to @CincauHangus)
It uses the compiled binary instead of source, but Sysinternals' Strings app might be useful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With