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

Localization completely broken in IOS apps #12684

Closed
nevse opened this issue Jan 16, 2023 · 3 comments
Closed

Localization completely broken in IOS apps #12684

nevse opened this issue Jan 16, 2023 · 3 comments
Labels
external partner/macios Issues for the Mac / iOS SDK partner Issue or Request from a partner team platform/iOS 🍎 t/bug Something isn't working

Comments

@nevse
Copy link

nevse commented Jan 16, 2023

Description

It's impossible to add more than one additional language to an ios app.

Localization resx files are ignored for 2 and more additional languages when an ios app was built in release and run on device.

I created a simple app, source code available here. It contains three resx files (Resources/MyLocalization.resx, Resources/MyLocalization.de.resx, Resource/MyLocailzation.es.resx) which I use to obtain the localized string "MyString" in the following way:

        Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture = new CultureInfo("de");
        CultureStringLabel.Text = resourceManager.GetString("MyString");

It works fine when I build my app in release for an iphone simulator, but it doesn't work when I build it in release for a real device. It works only for one additional resx file.

Steps to Reproduce

  1. create an app from the default template: dotnet new maui
  2. add three buttons and create handlers for them
 <ScrollView>
      <VerticalStackLayout
          Spacing="25"
          Padding="30,0"
          VerticalOptions="Center">

          <Button Text="Set Eng Culture" Clicked="OnSetEngCulture" />
          <Button Text="Set De Culture" Clicked="OnSetDeCulture" />
          <Button Text="Set Es Culture" Clicked="OnSetEsCulture" />
          <Label x:Name="CultureStringLabel" />
      </VerticalStackLayout>
  </ScrollView>
private void OnSetEngCulture(object sender, EventArgs e)
{
      Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
      CultureStringLabel.Text = resourceManager.GetString("MyString");
}
private void OnSetDeCulture(object sender, EventArgs e)
{
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture = new CultureInfo("de");
      CultureStringLabel.Text = resourceManager.GetString("MyString");
  }
  private void OnSetEsCulture(object sender, EventArgs e)
  {
      Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture = new CultureInfo("es");
      CultureStringLabel.Text = resourceManager.GetString("MyString");
  }
  1. build the app in release and run on the real iphone device

Press each button - you should see different strings (string from eng, string from de, string from es).

Press "Set Eng Culture" to see "string from eng".
Press "Set De Culture" you should see the "string from de", but this string is "string from eng". It's wrong behaviour.
Press "Set Es Culture" to see "string from es".

Link to public reproduction project repository

https://github.com/nevse/maui-tests-iosreleaselocalization

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

ios 16

Did you find any workaround?

No response

Relevant log output

No response

@nevse nevse added the t/bug Something isn't working label Jan 16, 2023
@jfversluis
Copy link
Member

Is this maybe related or the same as xamarin/xamarin-macios#16847?

@rolfbjarne ?

@rolfbjarne
Copy link
Member

Is this maybe related or the same as xamarin/xamarin-macios#16847?

@rolfbjarne ?

No, this is something different, and I can reproduce it.

Add this to the project file to work around it:

<PropertyGroup>
    <EnableAssemblyILStripping>false</EnableAssemblyILStripping>
</PropertyGroup>

@rolfbjarne
Copy link
Member

This issue was moved to xamarin/xamarin-macios#17262

@dotnet dotnet locked as resolved and limited conversation to collaborators Feb 15, 2023
@samhouts samhouts added partner Issue or Request from a partner team partner/macios Issues for the Mac / iOS SDK external labels May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
external partner/macios Issues for the Mac / iOS SDK partner Issue or Request from a partner team platform/iOS 🍎 t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants