microsoft / PowerToys

Windows system utilities to maximize productivity
MIT License
110.75k stars 6.52k forks source link

Missing German translation (Image Resizer tool (not settings of it)) #16792

Closed KiwiMonster364 closed 7 months ago

KiwiMonster364 commented 2 years ago

Microsoft PowerToys version

0.56.1

Utility with translation issue

Image Resizer

🌐 Language affected

German

❌ Actual phrase(s)

  1. missing translation: image

"fits within [resolution] [unit]"

  1. missing translation: (Option "user defined")

image

"Fill", "Fit", "Stretch"

  1. missing translation: (still the same option like 2. missing translation)

image

"Centimeter", "Inch", "Percent"

✔️ Expected phrase(s)

German translation

  1. missing translation: "Passt in [resolution] [unit]" (unit also in German) (Although I think this translation still isn't perfect (picked from the image resizer settings in the powertoys settings) (for (in my eyes) even better translation also have a look at this translation issue: https://github.com/microsoft/PowerToys/issues/16790)

image

  1. missing translation: "Ausfüllen", "Passen", "Strecken"

  2. missing translation: "Zentimeter", "Zoll", "Prozent"

ℹ Why is the current translation wrong

Missing translation

crutkas commented 2 years ago

@jaimecbernardo / @stefansjfw This should have been translated, no? it is in settings.

CleanCodeDeveloper commented 2 years ago

@crutkas: Feel free to assign me if @stefansjfw and @jaimecbernardo don't have the time to look into this

jaimecbernardo commented 2 years ago

Looked into this. Settings is translated. The note about German translation being weird is already in #16790 .

This issue is about the combobox fields not being localized in the Image Resizer UI. Those seem to have been in loc files for long but never have been translated properly in UI, it seems. I've tried going back some random versions to see where we broke this, and went back to 0.37.2 without seeing it translated once, so I suspect the localization of those has never been applied.

jaimecbernardo commented 2 years ago

@CleanCodeDeveloper , Thanks for picking this up! It seems the translations should be there but it's not being applied to the Image Resizer UI. ( I see ResizeFit_Fill in src/modules/imageresizer/ui/Porperties/Resources.resx, for example)

This will be though to test though, since I think there's no way to locally test localization. For testing translation, we need to have it go through the release CI since that's where those will be applied. Open a draft PR once you want to test something and I'll fire a full CI build so that translation is applied and see if it's fixed.

Another possible fix might be that these will have to have new keys in Resources.resw. That would be acceptable as well.

htcfreek commented 2 years ago

You have to not that translation not work for names of existing formats as they are saved to settings file.

The translated strings for ui aren't ever assigned in code. So they can't be shown localized. As I remember they are hard coded in enums or something else.

CleanCodeDeveloper commented 2 years ago

This will be though to test though, since I think there's no way to locally test localization. For testing translation, we need to have it go through the release CI since that's where those will be applied.

I was curious how this translation stuff works in PowerToys, so this seems to be a good learning opportunity. Unfortunately, the docs about localization are outdated, so I need to ask a few questions.

  1. Where are the translation files stored?
  2. Who does the translation?
CleanCodeDeveloper commented 2 years ago

The translated strings for ui aren't ever assigned in code. So they can't be shown localized. As I remember they are hard coded in enums or something else.

@htcfreek: I just stumbled about this genius implementation to localize enums: image

htcfreek commented 2 years ago

@CleanCodeDeveloper

  1. There is a folder called resources in each project. The resx file (for .net projects) in it contains the strings. You can edit this file easily in vs. I suggest you to add a using for <project namespace>. Properties. Then you can acces the strings via Resources.<StringId> (StringId == string key in resx file). For new projects you can copy an existing resx folder/file and in the installer (/installer/PowerToysSetup/product.wxs) you have to add an entry for the lang folder. (You can copy and edit an entry from an existing module.)

  2. The translation is happening automatically by an pipeline based on the resx file.

htcfreek commented 2 years ago

The translated strings for ui aren't ever assigned in code. So they can't be shown localized. As I remember they are hard coded in enums or something else.

@htcfreek: I just stumbled about this genius implementation to localize enums: image

This code looks correct. The question is if these localized values are used in the ui drop down too? 🤔

Jay-o-Way commented 9 months ago

Off-topic: why are we using RESX files when Microsoft changes to RESW like 10 years ago? https://learn.microsoft.com/windows/uwp/app-resources/localize-strings-ui-manifest https://softwareengineering.stackexchange.com/questions/236741/why-did-microsoft-dropped-the-resx-model-for-resw-in-windows-store-applications

Jay-o-Way commented 9 months ago

I've been digging for this for a while now (today) and it's complicated. Every idea I come up with, turns out not to be the cause. The localized data does exist in "C:\Program Files\PowerToys\nl-NL\PowerToys.ImageResizer.resources.dll", so it is included. It must be somewhere in the EnumValueConverter, but I haven't found it yet. Suspecting CultureInfo culture defaults to English.

microsoft-github-policy-service[bot] commented 9 months ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 5 days. It will be closed if no further activity occurs within 5 days of this comment.

stefansjfw commented 9 months ago

Suspecting CultureInfo culture defaults to English.

Looks like you're right. Here's what I did https://github.com/microsoft/PowerToys/commit/cd5819132f14be33e160f2111b61fa681cefbc3b

And I got this:

Screenshot 2024-01-26 165731
stefansjfw commented 9 months ago

I'll open a PR

Jay-o-Way commented 9 months ago

Oh wow, that's great, and such a simple solution! 🥳 I wonder what the core of the cause is...

jaimecbernardo commented 7 months ago

This has been worked on during the 0.79.0 release cycle. Please update to the latest: https://github.com/microsoft/PowerToys/releases