<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request Fix two broken links to style.md in devcods. This file was moved to development/style.md in PR #43399, but these references were not updated. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [ ] Closes: #xxx <!-- - [ ] Closes: #yyy (add separate lines for additional resolved issues) --> - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [x] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx <!-- Provide a more detailed description of the PR, other things fixed, or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments Fixed broken links in: - doc/devdocs/readme.md (line 60) - doc/devdocs/guidance.md (line 61) <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed Manually verified that the links resolve correctly.
2.9 KiB
Coding Guidance
Working With Strings
In order to support localization YOU SHOULD NOT have hardcoded UI display strings in your code. Instead, use resource files to consume strings.
For CPP
Use StringTable resource to store the strings and resource header file(resource.h) to store Id's linked to the UI display string. Add the strings with Id's referenced from the header file to the resource-definition script file. You can use Visual Studio Resource Editor to create and manage resource files.
resource.h:
XXX must be a unique int in the list (mostly the int ID of the last string id plus one):
#define IDS_MODULE_DISPLAYNAME XXX
StringTablein resource-definition script filevalidmodulename.rc:
STRINGTABLE
BEGIN
IDS_MODULE_DISPLAYNAME L"Module Name"
END
- Use the
GET_RESOURCE_STRING(UINT resource_id)method to consume strings in your code.
#include <common.h>
std::wstring GET_RESOURCE_STRING(IDS_MODULE_DISPLAYNAME)
For C#
Use XML resource file(.resx) to store the UI display strings and Resource Manager to consume those strings in the code. You can use Visual Studio to create and manage XML resources files.
Resources.resx
<data name="ValidUIDisplayString" xml:space="preserve">
<value>Description to be displayed on UI.</value>
<comment>This text is displayed when XYZ button clicked.</comment>
</data>
- Use
Resource Managerto consume strings in code.
System.Resources.ResourceManager manager = new System.Resources.ResourceManager(baseName, assembly);
string validUIDisplayString = manager.GetString("ValidUIDisplayString", resourceCulture);
In case of Visual Studio is used to create the resource file. Simply use the Resources class in auto-generated Resources.Designer.cs file to access the strings which encapsulate the Resource Manager logic.
string validUIDisplayString = Resources.ValidUIDisplayString;
More On Coding Guidance
Please review these brief docs below relating to our coding standards, etc.