We are trying to look at optimizing our localization testing.
Our QA group had a suggestion of a special mode to force all strings from the resources to be entirely contained of X. We already API hijack LoadString, and the MFC implementation of it, so doing it should not be a major hurdle.
My question is how would you solve the formatting issues?
Examples - CString str ; str . LoadString ( IDS_MYSTRING ) ; where IDS_MYSTRING is 'Hello World', should return 'XXXXX XXXXX' where IDS_MYSTRING is 'Hello\nWorld', should return 'XXXXX\nXXXXX' where IDS_MYSTRING is 'Hello%dWorld', should return 'XXXXX%dXXXXX' where IDS_MYSTRING is 'Hello%.2fWorld', should return 'XXXXX%.2fXXXXX' where IDS_MYSTRING is 'Hello%%World', should return 'XXXXX%%XXXXX'
So in summary the string should work if used in a printf or Format statement, it should honor escape characters.
So this is a pure code question, C++/MFC,
CString ConvertStringToXXXX ( const CString& aSource ) { CString lResult = aSource ; // Insert your code here return lResult ; }
I know this could be done using tools on the .RC files, but we want to build English, then run like so –
application -L10NTEST
If this approach is to highlight formatted strings (or format sequences) in the application (i.e. all text appearing other than XXXX), you could locate the escape sequence (using regex perhaps) and insert block quotes around the formatted (substituted) values,
e.g. Some\ntext -> Some[\n]text
You get readability (all strings as XXX might be hard to use the application) and also get to detect non-resource (hardcoded) strings.
Having said that, if you’re looking to detect non resource loaded strings (hardcoded strings), instead of substituting Xs, why not just prefix the string? You’ll easily be able to tell resource loaded strings from hardcoded strings easily,
e.g. Some\ntext -> [EN]Some\ntext
Hope it helps?