More localization friendly source strings and context commenting
What was done?
- Added support for string localization with placeholders. For example:
<data name="CommandArgumentDescription" xml:space="preserve">
<value>Filter results by command</value>
</data>
<data name="InvalidArgumentValueError" xml:space="preserve">
<value>The value provided for the `{0}` argument is invalid; valid values are: {1}</value>
<comment>Error message displayed when the user provides an invalid command line argument value. {0} is a placeholder replaced by the argument name. {1} is a placeholder replaced by a list of valid options.</comment>
</data>
info << String::CommandArgumentDescription; // => Filter results by command
info << String::InvalidArgumentValueError("First"_liv, "Second"_liv); // => The value provided for the `First` argument is invalid; valid values are: Second
- Applied the localization placeholder change to most use cases in the code. Some remaining use cases (e.g. ShowFlow.cpp) will be handled separately as it contains localized strings with a special rendering style (e.g. text printed in bold, different color, etc...).
- Updated existing unit tests
- Documented strings with placeholders in the
winget.reswfile.
Test
- Tested locally a randomly selected set of localized strings with placeholders.
- Added unit tests for newly added functions
Microsoft Reviewers: Open in CodeFlow
@check-spelling-bot Report
Unrecognized words, please review:
- arugment
- avialable
- dataand
- infom
- oss
To accept these unrecognized words as correct, run the following commands
... in a clone of the [email protected]:AmelBawa-msft/winget-cli.git repository
on the localization-format branch:
update_files() {
perl -e '
my $new_expect_file=".github/actions/spelling/expect.txt";
use File::Path qw(make_path);
use File::Basename qw(dirname);
make_path (dirname($new_expect_file));
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"$patch_add"');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a)."-".$a cmp lc($b)."-".$b} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;
system("git", "add", $new_expect_file);
'
}
comment_json=$(mktemp)
curl -L -s -S \
--header "Content-Type: application/json" \
"https://api.github.com/repos/microsoft/winget-cli/issues/comments/1216839860" > "$comment_json"
comment_body=$(mktemp)
jq -r .body < "$comment_json" > $comment_body
rm $comment_json
patch_add=$(perl -e '$/=undef;
$_=<>;
s{<details>.*}{}s;
s{^#.*}{};
s{\n##.*}{};
s{(?:^|\n)\s*\*}{}g;
s{\s+}{ }g;
print' < "$comment_body")
update_files
rm $comment_body
git add -u
@check-spelling-bot Report
:red_circle: Please review
See the :open_file_folder: files view or the :scroll:action log for details.
Unrecognized words (1)
placceholders
To accept :heavy_check_mark: these unrecognized words as correct, run the following commands
... in a clone of the [email protected]:AmelBawa-msft/winget-cli.git repository
on the localization-format branch (:information_source: how do I use this?):
curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.21/apply.pl' |
perl - 'https://github.com/microsoft/winget-cli/actions/runs/3699785722/attempts/1'
Available :books: dictionaries could cover words not in the :blue_book: dictionary
This includes both expected items (399) from .github/actions/spelling/expect.txt and unrecognized words (1)
| Dictionary | Entries | Covers |
|---|---|---|
| cspell:cpp/src/cpp.txt | 30216 | 26 |
| cspell:win32/src/win32.txt | 53509 | 18 |
| cspell:python/src/python/python-lib.txt | 3873 | 7 |
| cspell:php/php.txt | 2597 | 6 |
| cspell:java/java.txt | 7642 | 5 |
| cspell:python/src/python/python.txt | 453 | 3 |
| cspell:python/src/common/extra.txt | 741 | 3 |
| cspell:django/django.txt | 859 | 3 |
| cspell:typescript/typescript.txt | 1211 | 2 |
| cspell:npm/npm.txt | 288 | 2 |
Consider adding them using (in .github/workflows/spelling3.yml):
with:
extra_dictionaries:
cspell:cpp/src/cpp.txt
cspell:win32/src/win32.txt
cspell:python/src/python/python-lib.txt
cspell:php/php.txt
cspell:java/java.txt
cspell:python/src/python/python.txt
cspell:python/src/common/extra.txt
cspell:django/django.txt
cspell:typescript/typescript.txt
cspell:npm/npm.txt
To stop checking additional dictionaries, add:
with:
check_extra_dictionaries: ''
If the flagged items are :exploding_head: false positives
If items relate to a ...
-
binary file (or some other file you wouldn't want to check at all).
Please add a file path to the
excludes.txtfile matching the containing file.File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
^refers to the file's path from the root of the repository, so^README\.md$would exclude README.md (on whichever branch you're using). -
well-formed pattern.
If you can write a pattern that would match it, try adding it to the
patterns.txtfile.Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.
Note that patterns can't match multiline strings.