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

Internationalize dsc_lib #631

Merged
merged 7 commits into from
Jan 31, 2025
Merged

Conversation

SteveL-MSFT
Copy link
Member

@SteveL-MSFT SteveL-MSFT commented Jan 31, 2025

PR Summary

  • move all strings used in dsc_lib to a localizable file
  • update some tests due to string changes
  • added i18n test to verifies all use of t!() macro finds a corresponding entry in toml file since it's case sensitive and typos don't result in build error, also verifies that all entries in toml get used
  • fix brew example as macOS is lowercase

All future PRs should include i18n for strings. Usage with parameters looks like this:

[parser]
parsingStatement = "Parsing statement: %{statement}"

used as:

debug!("{}", t!("parser.statement.parsingStatement", statement = statement));

Where when using the trace macros, you must have the first arg as "{}" as the t!() macro doesn't return a string that can be used directly. Then the parameter in the string is assigned the variable value.

However, if you need to use the debug rendering of a variable, then the syntax looks like:

trace!("{}", t!("dscresources.commandResource.groupGetResponse", response = &group_response : {:?}));

Where normally it would look like:

trace!("Foo {:?}", bar);

So with the t!() macro, you use the : {:?} to specify formatting rules as part of parameter replacement. All the normal formatting can be used like number of decimal places, hex, etc...

@SteveL-MSFT SteveL-MSFT added this to the 3.0-Approved milestone Jan 31, 2025
@SteveL-MSFT SteveL-MSFT added this pull request to the merge queue Jan 31, 2025
Merged via the queue into PowerShell:main with commit 92a40d9 Jan 31, 2025
4 checks passed
@SteveL-MSFT SteveL-MSFT deleted the dsclib-i18n branch January 31, 2025 22:46
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.

2 participants