Skip to content

i18n works in debug mode, but in release it only takes the first supportedLocales on iOS #53119

@kelvinmontini

Description

@kelvinmontini

My application is behaving very strange in profile / release.

I currently have the following code in my main.dart:

supportedLocales: [
   const Locale('en', 'US'),
   const Locale('pt', 'BR'),
],
localizationsDelegates: [
        AppLocalizations.delegate,
        GlobalMaterialLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
],
localeResolutionCallback: (locale, supportedLocales) {
     for (var supportedLocale in supportedLocales) {
          if (locale?.languageCode == supportedLocale.languageCode) {
            print('DENTRO DO FOR: $supportedLocale');
            return supportedLocale;
          }
        }
    return locale;
},

In the xcode project I also added Localizations
Both in Targets: Runner> Info> Localizations > items > Item 0: en-US and Item 1: pt-BR
As in Project: Runner> Info> Localizations > items > Base (2 files Localized) / English (United States) (2 files Localized) / Portuguese (Brazil) (2 files Localized) / English - Development Language (0 files Localized)

The strange thing is that this works perfectly in debug mode, however when I run it as a profile or release, the application always stays with the language that is first in supportedLocales, regardless of the language the device uses.

❯ flutter doctor -v                
[✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.15.3 19D76, locale en-BR)
    • Flutter version 1.12.13+hotfix.8 at /Users/kelvinmontini/Development/flutter
    • Framework revision 0b8abb4724 (6 weeks ago), 2020-02-11 11:44:36 -0800
    • Engine revision e1e6ced81d
    • Dart version 2.7.0

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/kelvinmontini/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • ANDROID_HOME = /Users/kelvinmontini/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3.1, Build version 11C504
    • CocoaPods version 1.8.4

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 43.0.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] VS Code (version 1.43.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.8.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: internationalizationSupporting other languages or locales. (aka i18n)a: releaseChallenges faced when attempting to productionize an appf: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.platform-iosiOS applications specifically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions