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

Localize binaryparagraph.cpp and sourceparagraph.cpp #631

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
575fe0e
WIP
JavierMatosD Jul 11, 2022
bef0248
WIP
JavierMatosD Jul 12, 2022
f4f2cee
Adding messages
JavierMatosD Jul 12, 2022
d840466
WIP: Added message
JavierMatosD Jul 12, 2022
dd2786e
WIP
JavierMatosD Jul 12, 2022
d85eafb
Moved messages to messages.h/cpp
JavierMatosD Jul 12, 2022
9400523
Sorted Messages
JavierMatosD Jul 12, 2022
7829c56
WIP: Add msg
JavierMatosD Jul 12, 2022
102f2ec
Localizing messages
JavierMatosD Jul 12, 2022
38cd9e7
Localizing messages in sourceparagraph.cpp
JavierMatosD Jul 12, 2022
feb7dde
Merge branch 'main' into localization_vcpkgcmdarguments
JavierMatosD Jul 14, 2022
ad461a2
Merge branch 'main' into localization_continued
JavierMatosD Jul 14, 2022
9e3ce1e
LM
JavierMatosD Jul 14, 2022
db70510
Formatting change
JavierMatosD Jul 14, 2022
85f6db3
Split large message in binaryparagraph.cpp
JavierMatosD Jul 15, 2022
642aaee
All messages are localized.
JavierMatosD Jul 15, 2022
258292b
Sorted Messages
JavierMatosD Jul 15, 2022
6e69b6e
WIP
JavierMatosD Jul 15, 2022
1265b0c
UndeterminedToolChainForTriplet
JavierMatosD Jul 15, 2022
57a045a
return_code lambda
JavierMatosD Jul 15, 2022
462127b
FailedToFindDependencyAbi
JavierMatosD Jul 15, 2022
f84aec4
InvalidCrtILinkage
JavierMatosD Jul 15, 2022
ae5e896
Rename: InvalidCrtLinkage -> InvalidLinkage
JavierMatosD Jul 15, 2022
805920b
InvalidLinkage re-use
JavierMatosD Jul 15, 2022
da5170a
UnknownPolicySetting
JavierMatosD Jul 15, 2022
6bcc262
InvalidBuildInfo
JavierMatosD Jul 15, 2022
f130f2d
UnknownSettingForBuildType
JavierMatosD Jul 15, 2022
b578ecc
Sort
JavierMatosD Jul 15, 2022
0f639b3
Update: FailedToFindDependencyAbi
JavierMatosD Jul 15, 2022
d8ba3db
Update: IncorrectNumberOfArgs
JavierMatosD Jul 15, 2022
9190e0d
Update:SpecifiedFeatureTurnedOff
JavierMatosD Jul 15, 2022
9fc4655
Edit: ConflictingValuesForOption
JavierMatosD Jul 15, 2022
f0fb958
PR feedback
JavierMatosD Jul 15, 2022
3d7b751
WIP
JavierMatosD Jul 15, 2022
dbb507d
update clang format
JavierMatosD Jul 15, 2022
4d3d4ee
Fix format
JavierMatosD Jul 15, 2022
b8a0624
Fix paths
JavierMatosD Jul 15, 2022
93d96bc
Fix paths
JavierMatosD Jul 15, 2022
cc597cf
Fix paths
JavierMatosD Jul 15, 2022
3beb0c7
Split BinaryParagraphDescription to avoid re-useing replacement varia…
JavierMatosD Jul 16, 2022
9abcac5
Sorted messages
JavierMatosD Jul 16, 2022
1c96ade
Revert CMakeSettings.json
JavierMatosD Jul 18, 2022
5791d4a
Revert CMakeSettings
JavierMatosD Jul 18, 2022
bc747d6
Revert CMakeSettings
JavierMatosD Jul 18, 2022
78019b6
Response to PR feedback
JavierMatosD Jul 18, 2022
071d8d7
Merge branch 'main' into localization_vcpkgcmdarguments
JavierMatosD Jul 18, 2022
b1498f2
Merge branch 'main' into localization_vcpkgcmdarguments
JavierMatosD Jul 18, 2022
36847bf
Merge branch 'main' into localization_vcpkgcmdarguments
JavierMatosD Jul 19, 2022
dcc61b4
Removed BinParagraph messages
JavierMatosD Jul 19, 2022
27812b2
Response to feedback
JavierMatosD Jul 19, 2022
de5967b
Merge branch 'main' into localization_binaryparagraph.cpp_and_sourcep…
JavierMatosD Jul 19, 2022
f61cc7d
resolve merge conflicts
JavierMatosD Jul 19, 2022
4a7ea97
Grammer fix + ensure environment variable goes through its formatter
JavierMatosD Jul 19, 2022
2512707
grammer fixes
JavierMatosD Jul 19, 2022
aea2345
Removed the format_env_variable for consistency
JavierMatosD Jul 19, 2022
e74d2dd
added -- to all options and scanned for command_name replacements tha…
JavierMatosD Jul 19, 2022
482d571
Update src/vcpkg/sourceparagraph.cpp
JavierMatosD Jul 19, 2022
3c6b6bd
Update src/vcpkg/sourceparagraph.cpp
JavierMatosD Jul 19, 2022
6afcd01
Update src/vcpkg/sourceparagraph.cpp
JavierMatosD Jul 19, 2022
177985f
Update src/vcpkg/build.cpp
JavierMatosD Jul 19, 2022
781eed3
update json
JavierMatosD Jul 20, 2022
9e83a72
Merge branch 'main' into localization_vcpkgcmdarguments
JavierMatosD Jul 21, 2022
3c3bbbd
Merge branch 'localization_vcpkgcmdarguments' into localize_build.cpp
JavierMatosD Jul 21, 2022
6ca19a5
Merge branch 'localize_build.cpp' into localization_binaryparagraph.c…
JavierMatosD Jul 21, 2022
10d7c5c
Feedback
JavierMatosD Jul 21, 2022
73f0919
Merge branch 'main' into localization_binaryparagraph.cpp_and_sourcep…
JavierMatosD Jul 21, 2022
27de5c3
wip
JavierMatosD Jul 21, 2022
9fe5448
wip
JavierMatosD Jul 21, 2022
efa5f3f
Merge branch 'main' into localization_binaryparagraph.cpp_and_sourcep…
JavierMatosD Jul 21, 2022
2dd2576
sort
JavierMatosD Jul 21, 2022
805643c
Update src/vcpkg/binaryparagraph.cpp
JavierMatosD Jul 21, 2022
53c2afb
Update src/vcpkg/binaryparagraph.cpp
JavierMatosD Jul 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions include/vcpkg/base/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -711,8 +711,8 @@ namespace vcpkg
(msg::value),
"'{value}' is a command line option.",
"'--{value}' specified multiple times.");
DECLARE_MESSAGE(EmptyArg, (msg::option), "", "The option --{option} must be passed a non-empty argument.");
DECLARE_MESSAGE(EmailVcpkgTeam, (msg::url), "", "Send an email to {url} with any feedback.");
DECLARE_MESSAGE(EmptyArg, (msg::option), "", "The option --{option} must be passed a non-empty argument.");
DECLARE_MESSAGE(EmptyLicenseExpression, (), "", "SPDX license expression was empty.");
DECLARE_MESSAGE(EnvStrFailedToExtract, (), "", "could not expand the environment string:");
DECLARE_MESSAGE(ErrorDetectingCompilerInfo,
Expand Down Expand Up @@ -1106,6 +1106,11 @@ namespace vcpkg
"paragraph.\nPlease open an issue at {url}, with the following output:");
DECLARE_MESSAGE(Missing7zHeader, (), "", "Unable to find 7z header.");
DECLARE_MESSAGE(MissingExtension, (msg::extension), "", "Missing '{extension}' extension.");
DECLARE_MESSAGE(MissmatchedBinParagraphs,
(),
"",
"The serialized binary paragraph was different from the original binary paragraph. Please open an "
"issue at https://github.com/microsoft/vcpkg with the following output:");
DECLARE_MESSAGE(MonoInstructions,
(),
"",
Expand All @@ -1116,6 +1121,7 @@ namespace vcpkg
(msg::path, msg::exit_code),
"",
"msiexec failed while extracting \"{path}\" with launch or exit code {exit_code} and message:");
DECLARE_MESSAGE(MultiArch, (msg::option), "", "Multi-Arch must be 'same' but was {option}");
DECLARE_MESSAGE(NavigateToNPS, (msg::url), "", "Please navigate to {url} in your preferred browser.");
DECLARE_MESSAGE(NewConfigurationAlreadyExists,
(msg::path),
Expand All @@ -1141,7 +1147,7 @@ namespace vcpkg
(msg::path),
"",
"NuGet package creation succeeded, but no .nupkg was produced. Expected: \"{path}\"");
DECLARE_MESSAGE(MultiArch, (msg::option), "", "Multi-Arch must be 'same' but was {option}");
DECLARE_MESSAGE(OriginalBinParagraphHeader, (), "", "\nOriginal Binary Paragraph");
DECLARE_MESSAGE(PackageFailedtWhileExtracting,
(msg::value, msg::path),
"'{value}' is either a tool name or a package name.",
Expand Down Expand Up @@ -1208,6 +1214,7 @@ namespace vcpkg
"{value} may be either a 'vendor' like 'Azure' or 'NuGet', or a file path like C:\\example or /usr/example",
"Restored {count} package(s) from {value} in {elapsed}. Use --debug to see more details.");
DECLARE_MESSAGE(ResultsHeader, (), "Displayed before a list of installation results.", "RESULTS");
DECLARE_MESSAGE(SerializedBinParagraphHeader, (), "", "\nSerialized Binary Paragraph");
DECLARE_MESSAGE(SettingEnvVar,
(msg::env_var, msg::url),
"An example of env_var is \"HTTP(S)_PROXY\""
Expand Down
1 change: 1 addition & 0 deletions include/vcpkg/binaryparagraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ namespace vcpkg
};

void serialize(const BinaryParagraph& pgh, std::string& out_str);
std::string format_binary_paragraph(BinaryParagraph paragraph);
}
3 changes: 3 additions & 0 deletions locales/messages.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@
"MismatchedBinaryParagraphs": "[sanity check] The serialized binary paragraph was different from the original binary paragraph.\nPlease open an issue at {url}, with the following output:",
"Missing7zHeader": "Unable to find 7z header.",
"MissingExtension": "Missing '{extension}' extension.",
"MissmatchedBinParagraphs": "The serialized binary paragraph was different from the original binary paragraph. Please open an issue at https://github.com/microsoft/vcpkg with the following output:",
"MonoInstructions": "This may be caused by an incomplete mono installation. Full mono is available on some systems via `sudo apt install mono-complete`. Ubuntu 18.04 users may need a newer version of mono, available at https://www.mono-project.com/download/stable/",
"MsiexecFailedToExtract": "msiexec failed while extracting \"{path}\" with launch or exit code {exit_code} and message:",
"MultiArch": "Multi-Arch must be 'same' but was {option}",
Expand All @@ -253,6 +254,7 @@
"NoRegistryForPort": "no registry configured for port {package_name}",
"NoteMessage": "note: ",
"NugetPackageFileSucceededButCreationFailed": "NuGet package creation succeeded, but no .nupkg was produced. Expected: \"{path}\"",
"OriginalBinParagraphHeader": "\nOriginal Binary Paragraph",
"PackageFailedtWhileExtracting": "'{value}' failed while extracting {path}.",
"PackageRootDir": "(Experimental) Specify the packages root directory.",
"PackingVendorFailed": "Packing {vendor} failed. Use --debug for more information.",
Expand All @@ -276,6 +278,7 @@
"RestoredPackagesFromVendor": "Restored {count} package(s) from {value} in {elapsed}. Use --debug to see more details.",
"ResultsHeader": "RESULTS",
"SeeURL": "See {url} for more information.",
"SerializedBinParagraphHeader": "\nSerialized Binary Paragraph",
"SettingEnvVar": "-- Setting \"{env_var}\" environment variables to \"{url}\".",
"SourceFieldPortNameMismatch": "The 'Source' field inside the CONTROL file, or \"name\" field inside the vcpkg.json file has the name {package_name} and does not match the port directory \"{path}\".",
"SpecifiedFeatureTurnedOff": "'{command_name}' feature specifically turned off, but --{option} was specified.",
Expand Down
3 changes: 3 additions & 0 deletions locales/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@
"Missing7zHeader": "Unable to find 7z header.",
"MissingExtension": "Missing '{extension}' extension.",
"_MissingExtension.comment": "An example of {extension} is .exe.",
"MissmatchedBinParagraphs": "The serialized binary paragraph was different from the original binary paragraph. Please open an issue at https://github.com/microsoft/vcpkg with the following output:",
"MonoInstructions": "This may be caused by an incomplete mono installation. Full mono is available on some systems via `sudo apt install mono-complete`. Ubuntu 18.04 users may need a newer version of mono, available at https://www.mono-project.com/download/stable/",
"MsiexecFailedToExtract": "msiexec failed while extracting \"{path}\" with launch or exit code {exit_code} and message:",
"_MsiexecFailedToExtract.comment": "An example of {path} is /foo/bar. An example of {exit_code} is 127.",
Expand All @@ -420,6 +421,7 @@
"NoteMessage": "note: ",
"NugetPackageFileSucceededButCreationFailed": "NuGet package creation succeeded, but no .nupkg was produced. Expected: \"{path}\"",
"_NugetPackageFileSucceededButCreationFailed.comment": "An example of {path} is /foo/bar.",
"OriginalBinParagraphHeader": "\nOriginal Binary Paragraph",
"PackageFailedtWhileExtracting": "'{value}' failed while extracting {path}.",
"_PackageFailedtWhileExtracting.comment": "'{value}' is either a tool name or a package name. An example of {path} is /foo/bar.",
"PackageRootDir": "(Experimental) Specify the packages root directory.",
Expand Down Expand Up @@ -460,6 +462,7 @@
"_ResultsHeader.comment": "Displayed before a list of installation results.",
"SeeURL": "See {url} for more information.",
"_SeeURL.comment": "An example of {url} is https://github.com/microsoft/vcpkg.",
"SerializedBinParagraphHeader": "\nSerialized Binary Paragraph",
"SettingEnvVar": "-- Setting \"{env_var}\" environment variables to \"{url}\".",
"_SettingEnvVar.comment": "An example of env_var is \"HTTP(S)_PROXY\"'--' at the beginning must be preserved An example of {env_var} is VCPKG_DEFAULT_TRIPLET. An example of {url} is https://github.com/microsoft/vcpkg.",
"SourceFieldPortNameMismatch": "The 'Source' field inside the CONTROL file, or \"name\" field inside the vcpkg.json file has the name {package_name} and does not match the port directory \"{path}\".",
Expand Down
3 changes: 3 additions & 0 deletions src/vcpkg/base/messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,7 @@ namespace vcpkg
REGISTER_MESSAGE(MismatchedBinaryParagraphs);
REGISTER_MESSAGE(Missing7zHeader);
REGISTER_MESSAGE(MissingExtension);
REGISTER_MESSAGE(MissmatchedBinParagraphs);
REGISTER_MESSAGE(MonoInstructions);
REGISTER_MESSAGE(MsiexecFailedToExtract);
REGISTER_MESSAGE(MultiArch);
Expand All @@ -652,6 +653,7 @@ namespace vcpkg
REGISTER_MESSAGE(NoLocalizationForMessages);
REGISTER_MESSAGE(NoRegistryForPort);
REGISTER_MESSAGE(NugetPackageFileSucceededButCreationFailed);
REGISTER_MESSAGE(OriginalBinParagraphHeader);
REGISTER_MESSAGE(PackageFailedtWhileExtracting);
REGISTER_MESSAGE(PackageRootDir);
REGISTER_MESSAGE(PackingVendorFailed);
Expand All @@ -673,6 +675,7 @@ namespace vcpkg
REGISTER_MESSAGE(RestoredPackage);
REGISTER_MESSAGE(RestoredPackagesFromVendor);
REGISTER_MESSAGE(ResultsHeader);
REGISTER_MESSAGE(SerializedBinParagraphHeader);
REGISTER_MESSAGE(SettingEnvVar);
REGISTER_MESSAGE(SourceFieldPortNameMismatch);
REGISTER_MESSAGE(SpecifiedFeatureTurnedOff);
Expand Down
74 changes: 24 additions & 50 deletions src/vcpkg/binaryparagraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,56 +289,30 @@ namespace vcpkg
auto binary_paragraph = BinaryParagraph(*parsed_paragraph.get());
if (binary_paragraph != pgh)
{
const auto& join_str = R"(", ")";
Checks::exit_maybe_upgrade(
VCPKG_LINE_INFO,
R"([sanity check] The serialized binary paragraph was different from the original binary paragraph.
Please open an issue at https://github.com/microsoft/vcpkg, with the following output:

=== Original BinaryParagraph ===
spec: "%s"
version: "%s"
port_version: %d
description: ["%s"]
maintainers: ["%s"]
feature: "%s"
default_features: ["%s"]
dependencies: ["%s"]
abi: "%s"
type: %s

=== Serialized BinaryParagraph ===
spec: "%s"
version: "%s"
port_version: %d
description: ["%s"]
maintainers: ["%s"]
feature: "%s"
default_features: ["%s"]
dependencies: ["%s"]
abi: "%s"
type: %s
)",
pgh.spec.to_string(),
pgh.version,
pgh.port_version,
Strings::join(join_str, pgh.description),
Strings::join(join_str, pgh.maintainers),
pgh.feature,
Strings::join(join_str, pgh.default_features),
Strings::join(join_str, pgh.dependencies),
pgh.abi,
Type::to_string(pgh.type),
binary_paragraph.spec.to_string(),
binary_paragraph.version,
binary_paragraph.port_version,
Strings::join(join_str, binary_paragraph.description),
Strings::join(join_str, binary_paragraph.maintainers),
binary_paragraph.feature,
Strings::join(join_str, binary_paragraph.default_features),
Strings::join(join_str, binary_paragraph.dependencies),
binary_paragraph.abi,
Type::to_string(binary_paragraph.type));
Checks::msg_exit_maybe_upgrade(VCPKG_LINE_INFO,
msg::format(msgMissmatchedBinParagraphs)
.append(msgOriginalBinParagraphHeader)
.append_raw(format_binary_paragraph(pgh))
.append(msgSerializedBinParagraphHeader)
.append_raw(format_binary_paragraph(binary_paragraph)));
}
}

std::string format_binary_paragraph(BinaryParagraph paragraph)
{
const auto& join_str = R"(", ")";
JavierMatosD marked this conversation as resolved.
Show resolved Hide resolved
return Strings::format(
"\nspec: \"%s\"\nversion: \"%s\"\nport_version: %d\ndescription: [\"%s\"]\nmaintainers: [\"%s\"]\nfeature: "
"\"%s\"\ndefault_features: [\"%s\"]\ndependencies: [\"%s\"]\nabi: \"%s\"\ntype: %s",
JavierMatosD marked this conversation as resolved.
Show resolved Hide resolved
paragraph.spec.to_string(),
paragraph.version,
paragraph.port_version,
Strings::join(join_str, paragraph.description),
Strings::join(join_str, paragraph.maintainers),
paragraph.feature,
Strings::join(join_str, paragraph.default_features),
Strings::join(join_str, paragraph.dependencies),
paragraph.abi,
Type::to_string(paragraph.type));
}
}
2 changes: 1 addition & 1 deletion src/vcpkg/sourceparagraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,7 @@ namespace vcpkg
}
if (start_of_chunk != end_of_chunk)
{
msg::println_error(LocalizedString::from_raw(StringView{start_of_chunk, end_of_chunk}));
msg::write_unlocalized_text_to_stdout(Color::error, StringView{start_of_chunk, end_of_chunk});
start_of_chunk = end_of_chunk;
}
}
Expand Down