Skip to content

Localize option strings#35

Merged
benmcmorran merged 4 commits into
dev15from
dev/bemcmorr/loc
Sep 15, 2017
Merged

Localize option strings#35
benmcmorran merged 4 commits into
dev15from
dev/bemcmorr/loc

Conversation

@benmcmorran
Copy link
Copy Markdown
Member

@Microsoft/vcls please review

@msftclas
Copy link
Copy Markdown

@benmcmorran,
Thanks for your contribution as a Microsoft full-time employee or intern. You do not need to sign a CLA.
Thanks,
Microsoft Pull Request Bot

@benmcmorran benmcmorran requested a review from a team September 13, 2017 23:54
@LukaszMendakiewicz LukaszMendakiewicz added this to the next milestone Sep 15, 2017
public const string PageGeneralName = "General";
public const string PageParallelizationName = CategoryParallelizationName;
public const string PageGoogleTestName = "Google Test";
public static string CategoryTestExecutionName = Resources.CategoryTestExecutionName;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the strings that were const should become static **readonly**.

Comment thread GoogleTestAdapter/Core/Resources.resx Outdated
<comment>{0} represents the path of a test executable</comment>
</data>
<data name="DescriptionOfSolutionDirPlaceHolder" xml:space="preserve">
<value>{0} - directory of the solution (only available inside VS)</value>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please say "Visual Studio".

TestDirPlaceholder + " - path of a directory which can be used by the tests\n" +
ThreadIdPlaceholder + " - id of thread executing the current tests\n" +
DescriptionOfSolutionDirPlaceHolder;
// Set in constructor because it depends on other strings
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this to avoid initialization order issues? Aren't fields initialized top-to-bottom anyway?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I think this is left over from back before I marked all the fields static.

Comment thread GoogleTestAdapter/Core/Resources.resx Outdated
</data>
<data name="DescriptionOfPlaceholdersForBatches" xml:space="preserve">
<value>{0} - path of a directory which can be used by the tests
{1} - id of thread executing the current tests</value>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"the thread"?

public const string OptionTestDiscoveryRegexDescription =
"If non-empty, this regex will be used to discover the Google Test executables containing your tests.\nDefault regex: "
+ TestFinderRegex;
public static string OptionTestDiscoveryRegexDescription = Resources.OptionTestDiscoveryRegexDescription + TestFinderRegex;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't TestFinderRegex rather be a fill-in for string.Format?

Comment thread GoogleTestAdapter/Core/Resources.resx Outdated
</data>
<data name="OptionParseSymbolInformationDescription" xml:space="preserve">
<value>Parse debug symbol information for test executables to obtain source location information and traits (defined via the macros in GTA_Traits.h).
If this is set to false step 2 of traits discovery will be left out and only traits regexes will be effective.</value>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comma after "false"?

Comment thread GoogleTestAdapter/Core/Resources.resx Outdated
<value>Kill processes on cancel</value>
</data>
<data name="OptionKillProcessesOnCancelDescription" xml:space="preserve">
<value>If true, running test executables are actively killed if the test execution is canceled. Note that killing a test process might have all kinds of side effects; in particular, Google Test will not be able to perform any shutdown tasks.</value>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use "terminate" verbiage instead.

[Category(SettingsWrapper.CategoryTestExecutionName)]
[DisplayName(SettingsWrapper.OptionTestDiscoveryRegex)]
[Description(SettingsWrapper.OptionTestDiscoveryRegexDescription)]
[LocalizedCategory("CategoryTestExecutionName")]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears to me that this change is not strictly necessary, as the code as before would have been reading localized strings from SettingsWrapper. What is the benefit of this indirection?

Copy link
Copy Markdown
Member Author

@benmcmorran benmcmorran Sep 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attribute parameters must be compile-time constant, but the localized strings are not known until runtime. The indirection allows us to defer actual localized string lookup until runtime, while still having a constant parameter in the attribute.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks!

<data name="400" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\Resources\Icons\Icon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="501" xml:space="preserve">
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain to me how this works?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name (number) is used in GoogleTestExtensionOptionsPage.cs:26 to specify localized lookups for the category and page names in the options window:

[ProvideOptionPage(typeof(GeneralOptionsDialogPage), OptionsCategoryName, "General", 110, 501, true)]

Parameters 2 and 3 specify non-localized canonical names for the category and page names, while parameters 3 and 4 specify resource ids for the corresponding localized versions. ProvideOptionPage only allows shorts in these positions, so we are forced to use numbers.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation.

</data>
<data name="501" xml:space="preserve">
<value>General</value>
<comment>The name of page of options</comment>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comment is suspiciously missing from the entries below.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in new commit.

</data>
<data name="503" xml:space="preserve">
<value>Google Test</value>
<comment>The name of page of options</comment>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a comment (if it makes sense) that this is a name of the library and should probably not be localized?

@benmcmorran benmcmorran merged commit 190a253 into dev15 Sep 15, 2017
@benmcmorran benmcmorran deleted the dev/bemcmorr/loc branch September 15, 2017 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants