Add support for compiling resx files to embedded resources - #548
Open
soda0289 wants to merge 2 commits into
Open
Add support for compiling resx files to embedded resources#548soda0289 wants to merge 2 commits into
soda0289 wants to merge 2 commits into
Conversation
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.
This PR adds support for compiling
.resxfiles that contain basic string data into resource files. It does this by using a new toolresourcegenthat compiles.resxfiles using dotnet ResourceWriter. This tool is called from a new ruleresx_resourcethat can take in.resxfiles as well as culture variants or translations of these filesStrings.fr.resxto support localization. Localization support has been brought up before in issue #466 and it would allow for existing dotnet projects to migrate to bazel without using extra tooling or moving away from resx.Here is an example that I added to the README.md in docs:
That would then create resources, one for the neutral Strings.resx that is built into the dll/exe and one for each language as a dll that is shipped alongside the dll/exe. It can be read using dotnet ResourceManager
This is the same thing as MSBuild csproj file EmbeddedResource item. MSBuild will automatically compile resx files and the culture variants into resources or satellite assemblies in the same way as this change does using the
resx_resourcerule.It also adds support for
LogicalNameattribute that can be used to rename<EmbeddedResource>instead of using the file name of the resx file. This is done usinglogical_namesattribute in theresx_resourcerule. Only the neutral resx file needs to be mapped.In the future this could be expanded to handle more types of resx files that include binary data but I think starting with just string data for localization is the most common use case.