Skip to content

iOS/Mac Catalyst image localization #16734

@davidbritch

Description

@davidbritch

Description

The technique for localizing images on iOS are well known. It involves creating folders with the locale name, followed by .lproj, with the images in these folders. These would normally go in a Resources folder. So for MAUI I translated this to the Platforms\iOS\Resources folder:

image

The images have a build action of BundleResource.

This doesn't work for iOS, or on Mac Catalyst (using the equivalent MacCatalyst folder).

What does work is putting the .lproj folders in the root of the MAUI project:

image

Localized images are then displayed (on both iOS + MacCat).

While it works it makes me feel dirty having the root of your project contaminated with Apple only resources.

UPDATE: @rolfbjarne has told me that updating the .csproj to include <IPhoneResourcePrefix>Platforms/iOS/Resources</IPhoneResourcePrefix> makes localised images, contained in that specific folder, work on iOS + MacCat.

Steps to Reproduce

  1. Run attached sample on iOS.

Link to public reproduction project repository

https://github.com/davidbritch/dotnet-maui-issues/tree/main/LocalizationDemo

Version with bug

7.0.92

Is this a regression from previous behavior?

Don't think this has ever worked!

Affected platforms

iOS, macOS

Did you find any workaround?

Place .lproj folders in the root of your MAUI project.

OR (better)

Update your .csproj with the following:

	<PropertyGroup Condition="$(TargetFramework.Contains('-ios'))">
		<IPhoneResourcePrefix>Platforms/iOS/Resources</IPhoneResourcePrefix>
	</PropertyGroup>

	<PropertyGroup Condition="$(TargetFramework.Contains('-maccatalyst'))">
		<IPhoneResourcePrefix>Platforms/MacCatalyst/Resources</IPhoneResourcePrefix>
	</PropertyGroup>

Metadata

Metadata

Assignees

Labels

area-single-projectSplash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizerfixed-in-8.0.70fixed-in-9.0.0-preview.7.24407.4i/great-reporterThis issue is opened by an author who is known to open high-quality issuesplatform/iosplatform/macosmacOS / Mac Catalysts/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions