Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove {Locked} from localization machinery and localize the version command. #463

Merged
merged 9 commits into from
Mar 31, 2022

Conversation

BillyONeal
Copy link
Member

No description provided.

src/vcpkg.cpp Outdated
@@ -336,16 +320,23 @@ int main(const int argc, const char* const* const argv)
LockGuardPtr<Metrics>(g_metrics)->track_property("error", exc_msg);

fflush(stdout);
msg::println(msgVcpkgHasCrashed, msg::email = Commands::Contact::email());
msg::println(LocalizedString::from_raw("vcpkg.exe has crashed."));
Copy link
Member Author

Choose a reason for hiding this comment

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

This PR preserves the previous behavior, but I think this should be localized?

Copy link
Member

Choose a reason for hiding this comment

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

Side note, everyone I know from Mexico Spanglishes "has crashed" as "crasheo".

Copy link
Member

@vicroms vicroms Mar 29, 2022

Choose a reason for hiding this comment

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

It looks to me like this was actually localized before.

DECLARE_AND_REGISTER_MESSAGE(VcpkgHasCrashed, (msg::email), "", R"(vcpkg.exe has crashed...)");

Just this section was locked previously.

    DECLARE_AND_REGISTER_MESSAGE(VcpkgHasCrashedDataBlob,
                                 (msg::version, msg::error),
                                 "{Locked}",
                                 R"(
Version={version}
EXCEPTION='{error}'
CMD=)");

src/vcpkg/install.cpp Outdated Show resolved Hide resolved
Comment on lines +800 to 806
msg.append(LocalizedString()
.append_indent()
.append_raw(fmt::format("target_link_libraries(main PRIVATE {})",
Strings::join(" ", targets)))
.appendnl()
.appendnl()
.extract_data());
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
msg.append(LocalizedString()
.append_indent()
.append_raw(fmt::format("target_link_libraries(main PRIVATE {})",
Strings::join(" ", targets)))
.appendnl()
.appendnl()
.extract_data());
msg.append(fmt::format("target_link_libraries(main PRIVATE {})\n\n", Strings::join(" ", targets));

Copy link
Member Author

Choose a reason for hiding this comment

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

You lost the indent here?

Copy link
Contributor

@ras0219-msft ras0219-msft left a comment

Choose a reason for hiding this comment

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

LGTM with Victor's and my comments.

src/vcpkg.cpp Outdated
fflush(stdout);
for (int x = 0; x < argc; ++x)
{
#if defined(_WIN32)
msg::println(msgVcpkgHasCrashedArgument, msg::value = Strings::to_utf8(argv[x]));
msg::println(LocalizedString::from_raw(Strings::to_utf8(argv[x]) + "|"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Printing for each line here kinda sucks; I'd rather do something like:

LocalizedString arguments;
for (...) {
  arguments.append_raw(Strings::to_utf8(argv[x])).append_raw("|").append_nl();
}

@strega-nil-ms strega-nil-ms self-requested a review March 29, 2022 17:20
src/vcpkg.cpp Outdated
Comment on lines 333 to 346
LocalizedString data_blob;
data_blob.append_raw("Version=").append_raw(Commands::Version::version).appendnl();
data_blob.append_raw("EXCEPTION=").append_raw(exc_msg).appendnl();
data_blob.append_raw("CMD=").appendnl();
for (int x = 0; x < argc; ++x)
{
#if defined(_WIN32)
msg::println(LocalizedString::from_raw(Strings::to_utf8(argv[x]) + "|"));
data_blob.append_raw(Strings::to_utf8(argv[x])).append_raw("|").appendnl();
#else
msg::println(LocalizedString::from_raw(std::string(argv[x]) + "|"));
data_blob.append_raw(argv[x]).append_raw("|").appendnl();
#endif
}

msg::print(data_blob);
Copy link
Contributor

@ras0219-msft ras0219-msft Mar 30, 2022

Choose a reason for hiding this comment

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

Suggested change
LocalizedString data_blob;
data_blob.append_raw("Version=").append_raw(Commands::Version::version).appendnl();
data_blob.append_raw("EXCEPTION=").append_raw(exc_msg).appendnl();
data_blob.append_raw("CMD=").appendnl();
for (int x = 0; x < argc; ++x)
{
#if defined(_WIN32)
msg::println(LocalizedString::from_raw(Strings::to_utf8(argv[x]) + "|"));
data_blob.append_raw(Strings::to_utf8(argv[x])).append_raw("|").appendnl();
#else
msg::println(LocalizedString::from_raw(std::string(argv[x]) + "|"));
data_blob.append_raw(argv[x]).append_raw("|").appendnl();
#endif
}
msg::print(data_blob);
std::string msg = Strings::concat("Version=", Commands::Version::version, "\n", "EXCEPTION=", exc_msg, "\n", "CMD=\n");
for (int x = 0; x < argc; ++x)
{
#if defined(_WIN32)
Strings::append(msg, Strings::to_utf8(argv[x]), "|\n");
#else
Strings::append(msg, argv[x], "|\n");
#endif
}
print2(msg);

Copy link
Member Author

Choose a reason for hiding this comment

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

This goes backwards: the intent is for that everything that has been audited for localization goes through msg::print so that a 'find all references' on print2 finds everything yet to be fixed.

VersionCommandHeader,
(msg::version),
"",
"Vcpkg package management program version {version}\n\nSee LICENSE.txt for license information.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"Vcpkg package management program version {version}\n\nSee LICENSE.txt for license information.");
"vcpkg package management program version {version}\n\nSee LICENSE.txt for license information.");

nit, but it's spelled vcpkg; close as wontfix if you don't want to change behaviour

@BillyONeal
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@strega-nil-ms strega-nil-ms merged commit 904440f into microsoft:main Mar 31, 2022
@BillyONeal BillyONeal deleted the remove-locked branch April 1, 2022 02:33
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.

5 participants