-
Notifications
You must be signed in to change notification settings - Fork 455
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
Codebase Suggestion: Make Resource management and Multilingual support mechanisms consistent with WinUI #202
Comments
Great suggestion! Permission granted 😄 |
Hey @Kinnara, I've successfully created the automation tool (not automation TBH. "Converter" maybe?) in my fork's ResourceManagement branch. These are the drawbacks with the current version of this tool:
Now let's get to the convertion procedure:
It has a progress bar to show the convertion progress and each converted resources will get a check mark next to them. I did my best 😁. If have any suggestions, please tell them to me. |
Looks brilliant! Thanks a lot. I'll give it a try soon. |
Ooooooook. So, I just found out how big of a mess this change would introduce. Let me explain why.
We have to
|
Would this affect me as an app developer? Could I keep using RESX files for localization? I like ModernWPF having WinUI's color, layout, and control concepts. But going beyond that makes me concerned about the learning curve, and diminishing benefit since WinUI for Desktop is already in preview. I like the idea of supporting more languages, and automating how WinUI stuff is brought in. |
If done perfectly and completely, this change wouldn't affect any existing apps given that they didn't hard code the supporting assembly list (such as for MSI setups).
Your app using RESX for localization is completely independent of this library.
That's why I didn't want to merge the related PR any time soon. I just wanted to improve this project a bit. I don't want to scare away developers. And also this is not "my project" so the author can reject this change and preserve the current state.
If the author (@Kinnara) wants me to convert the WinUI resources (for languages which are only supported currently) and merge them into existing Strings.resx instead of separate RESX for each controls, I could do that. Thanks for sharing your opinion. |
Thank you @ShankarBUS. I understand now. 🙂 I appreciate the R&D work. |
Will moving
Good point. Basically WinUI has a superset of supported languages. I would probably start by renaming the Strings.*.resx files to use the WinUI language codes, e.g. zh-Hans to zh-CN and zh-Hant to zh-TW. Actually the existing zh-Hans and zh-Hant strings are indeed zh-CN and zh-TW, respectively, just named to match the resources in the .NET framework itself. |
That may solve it partially. But my method depends on the Ref:
So, to mitigate that issue, we may need to use Assembly.GetCallingAssembly Method. But that method has some pre-requisites to be made.
So, you're going to rename
I knew it! It should've been Some of the people were suggesting to use Edit: Wait a minute! You're from China, right? Whoa! Then you must know how to solve this issue. |
Any updates in this? |
Well, I'm ready to finish it. I rebased my branch, implemented all the suggestions by the owner (but not pushed yet, testing stuffs right now). We could come to a conclusion and merge this once @Kinnara give me the green signal. |
Well, I finished my work.
I didn't have time to check everything. So, I'll call my friend @Samuel12321 for reviewing my work. The PR is now completely ready to be merged. I even rebased to the latest master. Hope my PR helps 😄 |
If the related PR gets merged, you may need to update the satellite assemblies list in the PowerToys installer WixToolkit project. I'm obligated to notify you this. Since PowerToys uses WixToolkit for creating an installer you have to manually specify which files go where and this change could mess with the process. The related PR introduce a hot mess of changes. I'm not sure if this PR would be merged but I'm just letting you know 🙂. |
Currently this library supports localization by using the RESX localization present in .NET out-of-the-box. (all .NET projects support RESX natively).
While UWP projects use another file format called RESW (which is a highly restricted sibling of RESX).
The RESX comes with auto-code generation, eliminating the need to do manual fetching (storing the resource name and adding a method to fetch it) of the resources.
RESW only supports string resources whereas RESX supports images, icon and many more.
In the sense of WinUI, it makes use of RESW only for string resources and has its own method of fetching the resource (storing the resource name in a const within a static class like this
const string SR_RESOURCENAME = "RESOURCENAME"
and fetches the value by using some helpers).We can do the exact same!
It will eliminate the need for us to manually copy paste the resources from WinUI into the ModernWpf resource files (manual labour may result in errors).
It will give us the support for all the languages that WinUI supports! No extra work! (just have to change
%1!s!
to{0}
)We can clone the *.resw files from WinUI to ModernWpf as *.resx files using an automation tool.
Strikingly, the RESW & RESX formats look exactly the same (even xml comments are same!).
Benefits:
%1!s!
to{0}
,%1!u!
to{0:d}
& etc) to .NET specifc ones.Please consider this @Kinnara.
Just give me the permission, I'll do all the work (automation tool, converting existing resources).
The text was updated successfully, but these errors were encountered: