-
Notifications
You must be signed in to change notification settings - Fork 287
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
Fix localization irregularities. #553
Fix localization irregularities. #553
Conversation
I believe appendnl hails from a time when we thought we were going to be much more rigid about manipulation of LocalizedStrings as tokens. There are localized strings which themselves contain newlines. There are also formatted data strings, such as error message blocks join'd with \n, that we need to insert into localized messages. We also aren't likely to ever want to change our newlines to \r\n or something like that :) To that end, I think both original reasons for this to exist are gone, and it should go away. I think we should go all the way to removal rather than only removing the guidelines about it, because I think we, and contributors, will be confused if it exists and is relatively meaningless in the same way that people are confused (and use) std::endl today. The fact is that newlines aren't special in our LocalizedString structures, and we should be honest about that in our design. Contrast/note: append_indent must stay, and we must add a plain std::string version of that, to ensure consistency in how we handle indenting, as this is likely to be actually ambiguous (as opposed to newlines which are always and forever \n in vcpkg).
…enerates comments.
… println or similar components that already insert newlines.
…b rather than email.
…ocalized messages, and fix remaining edge case occurrences. Also removes allow-incorrect-comments from generate-message-map considering that we control all inputs here and extending this to block these other lints seemed unnecessary.
# Conflicts: # include/vcpkg/base/messages.h # src/vcpkg/base/parse.cpp # src/vcpkg/build.cpp
@@ -250,6 +250,28 @@ namespace vcpkg::msg | |||
|
|||
::size_t detail::number_of_messages() { return messages().names.size(); } | |||
|
|||
std::string detail::format_examples_for_args(StringView extra_comment, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole thing is just to fix trailing whitespace in the comments of localization messages. It was sucked out into a .cpp (after being flattened from template args to a struct in the header) so that it could use Strings::join
without creating header circularity or making messages.h
(which is included in everything now) huge.
LocalizedString format_string_parsing_error; | ||
Json::Object obj; | ||
for (Message& msg : messages) | ||
{ | ||
if (msg.name != "ErrorMessage" && Strings::case_insensitive_ascii_starts_with(msg.value, "error:")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the new lints. Note that I removed the switch to turn the lints off; we control all these inputs.
@@ -860,36 +860,30 @@ namespace vcpkg::Install | |||
return ret; | |||
} | |||
|
|||
DECLARE_AND_REGISTER_MESSAGE(ErrorRequirePackagesToInstall, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This message was deleted as it is unreferenced.
@@ -76,7 +73,7 @@ namespace vcpkg | |||
{ | |||
if (platform) | |||
{ | |||
return {msg::format(msgIllegalPlatformSpec).data(), expected_right_tag}; | |||
return {msg::format(msg::msgErrorMessage).append(msgIllegalPlatformSpec).data(), expected_right_tag}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to mess with it in this change, but I think we need a shorter way to get to msg::format(msg::msgErrorMessage)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format_error() has my vote.
VersionSpecMismatch, | ||
(msg::path, msg::expected_version, msg::actual_version), | ||
"", | ||
"Failed to load port because versions are inconsistent. The file \"{path}\" contains the version " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rewrote this error to make sense without the indent formatting. I could resolve it differently by breaking it up in to separate messages to preserve the indenting if people want.
@@ -76,7 +73,7 @@ namespace vcpkg | |||
{ | |||
if (platform) | |||
{ | |||
return {msg::format(msgIllegalPlatformSpec).data(), expected_right_tag}; | |||
return {msg::format(msg::msgErrorMessage).append(msgIllegalPlatformSpec).data(), expected_right_tag}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format_error() has my vote.
@@ -597,10 +597,10 @@ namespace vcpkg | |||
|
|||
DECLARE_AND_REGISTER_MESSAGE( | |||
ErrorMissingVcpkgRoot, | |||
(msg::url), | |||
(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had extracted out the url since it isn't localizable content.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's OK to for messages to have some content which isn't localizable; for example we talk about command line flags and stuff that aren't localized either. The comment needs to describe this. (Putting it back though)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, not putting it back because I changed these instructions to ask people to file GitHub issues.
…ning, respectively.
# Conflicts: # locales/messages.json # src/vcpkg/registries.cpp
@@ -268,7 +268,7 @@ namespace vcpkg::Build | |||
LocalizedString errorMsg = msg::format(msg::msgErrorMessage).append(msgBuildDependenciesMissing); | |||
for (const auto& p : result.unmet_dependencies) | |||
{ | |||
errorMsg.append_indent().append_raw(p.to_string()).append_raw('\n'); | |||
errorMsg.append_raw('\n').append_indent().append_raw(p.to_string()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noting that this changes behavior (one newline instead of two)
"architecture was {arch}\n " | ||
"The selected Visual Studio instance is at {path}\n The available toolchain combinations are {list}\n"); | ||
"in triplet {triplet}: Unable to find a valid toolchain for requested target architecture {arch}.\n" | ||
"The selected Visual Studio instance is at: {path}\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noting that this change drops indentation.
Those behavior changes seem reasonable to me. |
It fixes all violations of localization guidelines:
and adds enforcement to make sure we don't regress these.