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

Windows image localization papercut #16755

Open
davidbritch opened this issue Aug 15, 2023 · 7 comments · May be fixed by #23314
Open

Windows image localization papercut #16755

davidbritch opened this issue Aug 15, 2023 · 7 comments · May be fixed by #23314
Labels
area-localization Localization and globalization issues area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer i/great-reporter This issue is opened by an author who is known to open high-quality issues platform/windows 🪟 s/needs-attention Issue has more information and needs another look s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@davidbritch
Copy link
Contributor

davidbritch commented Aug 15, 2023

Description

In a .NET MAUI app you can follow the .NET Android approach to handling localized images and it works correctly. On iOS/MacCat you can follow the platform approach to handling localized images and it works with a workaround (see #16734).

Windows is equally mysterious. If you place your localized images, in locale folders, in the root of your MAUI project then image localization works:

MicrosoftTeams-image

This isn't great though. But placing them in Platform/Windows doesn't work:

MicrosoftTeams-image (1)

Similarly, placing them in Platform/Windows/Assets/Images doesn't work, which I'd hoped would work due to it being the UWP approach.

However, it's possible to make it work. Place your localized images in Platforms/Windows/Assets/Images (or whatever you want to call your images folder):

MicrosoftTeams-image

Those images will get copied to bin/.../win10-x64/AppX/Platforms/Windows/Assets/Images, which means to retrieve them in XAML you'll need to specify the path:

<Image Source="{OnPlatform flag.png, WinUI=Platforms/Windows/Assets/Images/flag.png}" />

So while this works I'd label it a papercut because the behaviour on one platform is different to the other platforms, where you don't have to worry about the path to the images.

Version with bug

7.0.92

Is this a regression from previous behavior?

No, this is something new

Affected platforms

Windows

@davidbritch davidbritch added the t/bug Something isn't working label Aug 15, 2023
@ghost ghost added the i/great-reporter This issue is opened by an author who is known to open high-quality issues label Aug 15, 2023
@rachelkang rachelkang added area-image Image loading, sources, caching area-localization Localization and globalization issues platform/windows 🪟 area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer labels Aug 15, 2023
@rachelkang
Copy link
Member

Thanks @davidbritch! Could you share a repro and binlog with us? Thanks :)

@rachelkang rachelkang added the s/needs-repro Attach a solution or code which reproduces the issue label Aug 15, 2023
@ghost
Copy link

ghost commented Aug 15, 2023

Hi @davidbritch. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@drasticactions
Copy link
Contributor

Related to #16734, was image localization ever an officially supported feature within MAUI? Both of these behaviors in this and the other issue are how you would handle localization for specific target frameworks but if you wanted to have one set of images to be localized on all platforms, we couldn't. IMO that kinda defeats the point of a single project since I would think the idea would be to have one set of images that work correctly on all supported platforms.

To be clear, this is still an issue that should be addressed (You may want to have specific platform image localization and that should most likely be handled within the Platform folder) but should the concept of image localization be something supported within single project?

@davidbritch
Copy link
Contributor Author

Another related Windows loc papercut: #16814

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-repro Attach a solution or code which reproduces the issue labels Aug 17, 2023
@rmarinho rmarinho added this to the Backlog milestone Aug 17, 2023
@ghost
Copy link

ghost commented Aug 17, 2023

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

@davidbritch
Copy link
Contributor Author

davidbritch commented Sep 5, 2023

Rather than using OnPlatform, a better workaround on Windows is to add the following to your .csproj:

	<ItemGroup Condition="$(TargetFramework.Contains('-windows'))">
		<Content Include="Platforms\Windows\Assets\Images\**" TargetPath="%(RecursiveDir)%(Filename)%(Extension)" />
	</ItemGroup>

This redirects all files in the Platforms\Windows\Assets\Images to the app root.

On all four platforms you can then consume localized images with:

<Image Source="image.png" />

@RoiChen001 RoiChen001 added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Feb 19, 2024
@RoiChen001
Copy link
Collaborator

RoiChen001 commented Feb 19, 2024

dotnet-maui-issues-main.zip
Verified this issue with Visual Studio Enterprise 17.10.0 Preview 1. Can repro on windows platform with repro steps.
image

@Eilon Eilon removed the area-image Image loading, sources, caching label May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-localization Localization and globalization issues area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer i/great-reporter This issue is opened by an author who is known to open high-quality issues platform/windows 🪟 s/needs-attention Issue has more information and needs another look s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants