Multiple locale support for winget workflows - #903
Merged
Conversation
Misspellings found, please review:
To accept these changes, run the following commands from this repository on this branch |
Misspellings found, please review:
To accept these changes, run the following commands from this repository on this branch |
JohnMcPMS
reviewed
Apr 29, 2021
|
|
||
| The `locale` behavior affects the choice of installer based on installer locale. The matching parameter is `--locale`, and uses bcp47 language tag. | ||
|
|
||
| Note the locale preference will also be applied to `winget show` command if applicable. |
Member
There was a problem hiding this comment.
Should they? It feels like a separate setting should exist for display language. #Closed
JohnMcPMS
reviewed
Apr 29, 2021
| { | ||
| if (!Utility::IsWellFormedBcp47Tag(execArgs.GetArg(Args::Type::Locale))) | ||
| { | ||
| throw CommandException(Resource::String::InvalidArgumentValueError, s_ArgumentName_Locale, { "bcp47 language tags"_lis }); |
Member
JohnMcPMS
reviewed
Apr 30, 2021
| { | ||
| if (!Utility::IsWellFormedBcp47Tag(execArgs.GetArg(Args::Type::Locale))) | ||
| { | ||
| throw CommandException(Resource::String::InvalidArgumentValueError, s_ArgumentName_Locale, { "bcp47 language tags"_lis }); |
Member
JohnMcPMS
reviewed
Apr 30, 2021
| <data name="LanguageArgumentDescription" xml:space="preserve"> | ||
| <value>Language to install (if supported)</value> | ||
| <data name="LocaleArgumentDescription" xml:space="preserve"> | ||
| <value>Locale to install (if supported)</value> |
Member
JohnMcPMS
reviewed
Apr 30, 2021
| if (!preferredList.empty()) | ||
| { | ||
| // TODO: we only take the first one for now | ||
| preference = preferredList.at(0); |
Member
There was a problem hiding this comment.
This suggests that the setting should also be an array. What are the complications with taking the whole list? The only one that comes to mind is that the sort is harder, but I don't think that is insurmountable. #Closed
JohnMcPMS
reviewed
Apr 30, 2021
| #include <string> | ||
| #include <vector> | ||
|
|
||
| namespace AppInstaller::Utility |
JohnMcPMS
reviewed
Apr 30, 2021
| if (!preferredList.empty()) | ||
| { | ||
| // TODO: we only take the first one for now | ||
| targetLocale = preferredList.at(0); |
Member
JohnMcPMS
reviewed
Apr 30, 2021
| { | ||
| // See https://docs.microsoft.com/en-us/windows/win32/msi/uninstall-registry-key for details. | ||
| std::wstring SubKeyPath{ L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall" }; | ||
| inline static const std::wstring SubKeyPath{ L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall" }; |
Member
JohnMcPMS
reviewed
Apr 30, 2021
| double firstScore = first.Locale.empty() ? Locale::UnknownLanguageDistanceScore : Locale::GetDistanceOfLanguage(preferredLocale, first.Locale); | ||
| double secondScore = second.Locale.empty() ? Locale::UnknownLanguageDistanceScore : Locale::GetDistanceOfLanguage(preferredLocale, second.Locale); | ||
|
|
||
| if (firstScore > secondScore && firstScore >= Locale::MinimumDistanceScoreAsCompatibleMatch) |
Member
There was a problem hiding this comment.
if (firstScore > secondScore && firstScore >= Locale::MinimumDistanceScoreAsCompatibleMatch)
The search through m_preference needs to stop whenever either score is compatible. So:
if (firstScore >= Compat || secondScore => Compat)
return firstScore > secondScore;
This is required or you could have IsFirstBetter return true for both orderings of first and second. #Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
This change implements support for multi locale in winget workflows.
Validation
Microsoft Reviewers: Open in CodeFlow