Skip to content

Commit dd96ce4

Browse files
Apply localization and documentation fixes for regex code (#18914)
Applies some localization fixes for the regex strings and Settings_ResetApplicationState.HelpText. Also renames the `_validateX()` functions to `_validateAndPopulateXRegex()` for clarity.
1 parent 076746a commit dd96ce4

File tree

4 files changed

+42
-42
lines changed

4 files changed

+42
-42
lines changed

src/cascadia/TerminalApp/Resources/en-US/Resources.resw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,6 @@
945945
<value>Move right</value>
946946
</data>
947947
<data name="InvalidRegex" xml:space="preserve">
948-
<value>An invalid regex was found.</value>
948+
<value>An invalid regular expression was found.</value>
949949
</data>
950950
</root>

src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,7 +2105,7 @@
21052105
<comment>Header for a control that adds any remaining profiles to the new tab menu.</comment>
21062106
</data>
21072107
<data name="NewTabMenu_AddMatchProfiles.HelpText" xml:space="preserve">
2108-
<value>Add a group of profiles that match at least one of the defined regex properties</value>
2108+
<value>Add a group of profiles that match at least one of the defined regular expression properties</value>
21092109
<comment>Additional information for a control that adds a terminal profile matcher to the new tab menu. Presented near "NewTabMenu_AddMatchProfiles".</comment>
21102110
</data>
21112111
<data name="NewTabMenu_AddRemainingProfiles.HelpText" xml:space="preserve">
@@ -2121,15 +2121,15 @@
21212121
<comment>Header for a control that adds a folder to the new tab menu.</comment>
21222122
</data>
21232123
<data name="NewTabMenu_AddMatchProfiles_Name.Header" xml:space="preserve">
2124-
<value>Profile name (Regex)</value>
2124+
<value>Profile name (regular expression)</value>
21252125
<comment>Header for a text box used to define a regex for the names of profiles to add.</comment>
21262126
</data>
21272127
<data name="NewTabMenu_AddMatchProfiles_Source.Header" xml:space="preserve">
2128-
<value>Profile source (Regex)</value>
2128+
<value>Profile source (regular expression)</value>
21292129
<comment>Header for a text box used to define a regex for the sources of profiles to add.</comment>
21302130
</data>
21312131
<data name="NewTabMenu_AddMatchProfiles_Commandline.Header" xml:space="preserve">
2132-
<value>Commandline (Regex)</value>
2132+
<value>Commandline (regular expression)</value>
21332133
<comment>Header for a text box used to define a regex for the commandlines of profiles to add.</comment>
21342134
</data>
21352135
<data name="NewTabMenu_AddMatchProfilesTextBlock.Text" xml:space="preserve">
@@ -2362,7 +2362,7 @@
23622362
<value>Clear cache</value>
23632363
</data>
23642364
<data name="Settings_ResetApplicationState.HelpText" xml:space="preserve">
2365-
<value>The cache stores data related to persisting sessions and automatic profile generation.</value>
2365+
<value>The cache stores data related to saved sessions and automatically generated profiles.</value>
23662366
</data>
23672367
<data name="Settings_ResetToDefaultSettingsButton.Content" xml:space="preserve">
23682368
<value>Reset</value>

src/cascadia/TerminalSettingsModel/MatchProfilesEntry.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
3636
auto entry = winrt::make_self<MatchProfilesEntry>();
3737

3838
JsonUtils::GetValueForKey(json, NameKey, entry->_Name);
39-
entry->_validateName();
39+
entry->_validateAndPopulateNameRegex();
4040

4141
JsonUtils::GetValueForKey(json, CommandlineKey, entry->_Commandline);
42-
entry->_validateCommandline();
42+
entry->_validateAndPopulateCommandlineRegex();
4343

4444
JsonUtils::GetValueForKey(json, SourceKey, entry->_Source);
45-
entry->_validateSource();
45+
entry->_validateAndPopulateSourceRegex();
4646

4747
return entry;
4848
}
@@ -53,22 +53,22 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
5353
return !(_invalidName || _invalidCommandline || _invalidSource);
5454
}
5555

56-
#define DEFINE_VALIDATE_FUNCTION(name) \
57-
void MatchProfilesEntry::_validate##name() noexcept \
58-
{ \
59-
_invalid##name = false; \
60-
if (_##name.empty()) \
61-
{ \
62-
/* empty field is valid*/ \
63-
return; \
64-
} \
65-
UErrorCode status = U_ZERO_ERROR; \
66-
_##name##Regex = til::ICU::CreateRegex(_##name, 0, &status); \
67-
if (U_FAILURE(status)) \
68-
{ \
69-
_invalid##name = true; \
70-
_##name##Regex.reset(); \
71-
} \
56+
#define DEFINE_VALIDATE_FUNCTION(name) \
57+
void MatchProfilesEntry::_validateAndPopulate##name##Regex() noexcept \
58+
{ \
59+
_invalid##name = false; \
60+
if (_##name.empty()) \
61+
{ \
62+
/* empty field is valid*/ \
63+
return; \
64+
} \
65+
UErrorCode status = U_ZERO_ERROR; \
66+
_##name##Regex = til::ICU::CreateRegex(_##name, 0, &status); \
67+
if (U_FAILURE(status)) \
68+
{ \
69+
_invalid##name = true; \
70+
_##name##Regex.reset(); \
71+
} \
7272
}
7373

7474
DEFINE_VALIDATE_FUNCTION(Name);

src/cascadia/TerminalSettingsModel/MatchProfilesEntry.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,23 @@ Author(s):
2323
// The setter tries to instantiate the regex immediately and caches
2424
// it if successful. If it fails, it sets a boolean flag to track that
2525
// it failed.
26-
#define DEFINE_MATCH_PROFILE_REGEX_PROPERTY(name) \
27-
public: \
28-
hstring name() const noexcept \
29-
{ \
30-
return _##name; \
31-
} \
32-
void name(const hstring& value) noexcept \
33-
{ \
34-
_##name = value; \
35-
_validate##name(); \
36-
} \
37-
\
38-
private: \
39-
void _validate##name() noexcept; \
40-
\
41-
hstring _##name; \
42-
til::ICU::unique_uregex _##name##Regex; \
26+
#define DEFINE_MATCH_PROFILE_REGEX_PROPERTY(name) \
27+
public: \
28+
hstring name() const noexcept \
29+
{ \
30+
return _##name; \
31+
} \
32+
void name(const hstring& value) noexcept \
33+
{ \
34+
_##name = value; \
35+
_validateAndPopulate##name##Regex(); \
36+
} \
37+
\
38+
private: \
39+
void _validateAndPopulate##name##Regex() noexcept; \
40+
\
41+
hstring _##name; \
42+
til::ICU::unique_uregex _##name##Regex; \
4343
bool _invalid##name{ false };
4444

4545
namespace winrt::Microsoft::Terminal::Settings::Model::implementation

0 commit comments

Comments
 (0)