Skip to content

[gen-l10n] Invalid dart file is generated by gen-l10n when (there are no "regular" characters in front of a dollar sign) and (there is a select clause in a message) #125461

Description

@mshurkaeu-public

Is there an existing issue for this?

Steps to reproduce

  1. Clone repository https://github.com/mshurkaeu-public/flutter-bugs-I-found-or-reported.git
  2. Switch into branch main.
  3. Navigate to folder 03-gen-l10n-dollar-sign+select-clause.
  4. Run command
flutter gen-l10n
  1. Check resulting file .dart_tool/flutter_gen/gen_l10n/app_localizations_en.dart. Methods helloBugManifistation1 and helloBugManifistation2 are generated incorrectly. And thus the whole generated file is invalid.

Expected results

The generated app_localizations_en.dart file contains correctly escaped dollar sign:

  @override
  String helloBugManifistation1(String selectPlaceholder) {
    String _temp0 = intl.Intl.selectLogic(
      selectPlaceholder,
      {
        'case': 'message',
        'other': 'messageOther',
      },
    );
    return '\$nice_bug\nHello Bug! Manifistation #1 $_temp0';
  }

  @override
  String helloBugManifistation2(String selectPlaceholder) {
    String _temp0 = intl.Intl.selectLogic(
      selectPlaceholder,
      {
        'case': '',
        'other': '',
      },
    );
    String _temp1 = intl.Intl.selectLogic(
      selectPlaceholder,
      {
        'case': 'message',
        'other': 'messageOther',
      },
    );
    return '${_temp0}\$nice_bug\nHello Bug! Manifistation #2 $_temp1';
  }

Actual results

The generated app_localizations_en.dart file is invalid:

  @override
  String helloBugManifistation1(String selectPlaceholder) {
    String _temp0 = intl.Intl.selectLogic(
      selectPlaceholder,
      {
        'case': 'message',
        'other': 'messageOther',
      },
    );
    return '${nice_bug
Hello Bug! Manifistation #1 }$_temp0';
  }

  @override
  String helloBugManifistation2(String selectPlaceholder) {
    String _temp0 = intl.Intl.selectLogic(
      selectPlaceholder,
      {
        'case': '',
        'other': '',
      },
    );
    String _temp1 = intl.Intl.selectLogic(
      selectPlaceholder,
      {
        'case': 'message',
        'other': 'messageOther',
      },
    );
    return '$_temp0${nice_bug
Hello Bug! Manifistation #2 }$_temp1';
  }

Code sample

Full code of the example is available in repository https://github.com/mshurkaeu-public/flutter-bugs-I-found-or-reported.git. Branch main. Folder 03-gen-l10n-dollar-sign+select-clause.
{
  "helloBugManifistation1": "$nice_bug\nHello Bug! Manifistation #1 {selectPlaceholder, select, case{message} other{messageOther}}",
  "@helloBugManifistation1": {
    "description": "This is a demo #1 of the bug",
    "placeholders": {
      "selectPlaceholder": {
        "type": "String"
      }
    }
  },
  "helloBugManifistation2": "{selectPlaceholder, select, case{} other{}}$nice_bug\nHello Bug! Manifistation #2 {selectPlaceholder, select, case{message} other{messageOther}}",
  "@helloBugManifistation2": {
    "description": "This is a demo #2 of the bug",
    "placeholders": {
      "selectPlaceholder": {
        "type": "String"
      }
    }
  },
  "workaroundTheBug": "\u200B$nice_bug\nHello Bug! A workaround... {selectPlaceholder, select, case{message} other{messageOther}}",
  "@helloBug1": {
    "description": "This is a demo of a workaround for the bug",
    "placeholders": {
      "selectPlaceholder": {
        "type": "String"
      }
    }
  }
}

Screenshots or Video

No response

Logs

Logs
flutter --verbose gen-l10n
[  +13 ms] executing: uname -m
[   +8 ms] Exit code 0 from: uname -m
[        ] x86_64
[        ] executing: [/home/vboxuser/snap/flutter/common/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[   +7 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[   +1 ms] 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
[        ] executing: [/home/vboxuser/snap/flutter/common/flutter/] git tag --points-at 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
[  +15 ms] Exit code 0 from: git tag --points-at 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
[        ] 3.7.12
[   +9 ms] executing: [/home/vboxuser/snap/flutter/common/flutter/] git rev-parse --abbrev-ref --symbolic @{upstream}
[   +3 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{upstream}
[        ] origin/stable
[        ] executing: [/home/vboxuser/snap/flutter/common/flutter/] git ls-remote --get-url origin
[   +1 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[  +21 ms] executing: [/home/vboxuser/snap/flutter/common/flutter/] git rev-parse --abbrev-ref HEAD
[   +2 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] stable
[  +14 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +2 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[  +24 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[  +14 ms] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[   +8 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[        ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'PubDependencies' is not required, skipping update.
[  +53 ms] Because l10n.yaml exists, the options defined there will be used instead.
           To use the command line arguments, delete the l10n.yaml file in the Flutter project.
           
           
[ +145 ms] "flutter gen-l10n" took 264ms.
[   +1 ms] Running 0 shutdown hooks
[   +1 ms] Shutdown hooks complete
[        ] exiting with code 0

Flutter Doctor output

Doctor output
flutter doctor -v
[✓] Flutter (Channel stable, 3.7.12, on Ubuntu 22.10 5.19.0-40-generic, locale en_US.UTF-8)
    • Flutter version 3.7.12 on channel stable at /home/vboxuser/snap/flutter/common/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4d9e56e694 (7 days ago), 2023-04-17 21:47:46 -0400
    • Engine revision 1a65d409c7
    • Dart version 2.19.6
    • DevTools version 2.20.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /home/vboxuser/Android/Sdk
    • Platform android-33-ext4, build-tools 33.0.2
    • Java binary at: /snap/android-studio/125/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 10.0.0-4ubuntu1
    • cmake version 3.16.3
    • ninja version 1.10.0
    • pkg-config version 0.29.1

[✓] Android Studio (version 2021.3)
    • Android Studio at /snap/android-studio/125/android-studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[✓] VS Code (version 1.77.3)
    • VS Code at /usr/share/code
    • Flutter extension version 3.62.0

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Ubuntu 22.10 5.19.0-40-generic
    • Chrome (web)    • chrome • web-javascript • Google Chrome 112.0.5615.121

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Activity

  1. added
    in triagePresently being triaged by the triage team
    on Apr 25, 2023
  2. huycozy commented on Apr 25, 2023

    @huycozy
    Member

    Thanks for your report @mshurkaeu-public! This issue is reproducible on the latest stable and master channels.

    As you mentioned in the sample code (the 3rd string), adding \u200B in front of the dollar sign ($nice_bug) can work around this.

    flutter doctor -v (stable and master)
    [✓] Flutter (Channel stable, 3.7.12, on macOS 13.0.1 22A400 darwin-x64, locale en-VN)
        • Flutter version 3.7.12 on channel stable at /Users/huynq/Documents/GitHub/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 4d9e56e694 (2 days ago), 2023-04-17 21:47:46 -0400
        • Engine revision 1a65d409c7
        • Dart version 2.19.6
        • DevTools version 2.20.1
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
        • Android SDK at /Users/huynq/Library/Android/sdk
        • Platform android-33, build-tools 32.0.0
        • ANDROID_HOME = /Users/huynq/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 14.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 14E222b
        • CocoaPods version 1.11.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2022.1)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    
    [✓] IntelliJ IDEA Community Edition (version 2022.1.1)
        • IntelliJ at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/221.5591.52/IntelliJ IDEA CE.app
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
    
    [✓] VS Code (version 1.77.3)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.62.0
    
    [✓] Connected device (3 available)
        • SM T225 (mobile) • R9JT3004VRJ • android-arm64  • Android 13 (API 33)
        • macOS (desktop)  • macos       • darwin-x64     • macOS 13.0.1 22A400 darwin-x64
        • Chrome (web)     • chrome      • web-javascript • Google Chrome 112.0.5615.137
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
    [!] Flutter (Channel master, 3.10.0-12.0.pre.47, on macOS 13.0.1 22A400 darwin-x64, locale en-VN)
        • Flutter version 3.10.0-12.0.pre.47 on channel master at /Users/huynq/Documents/GitHub/flutter_master
        ! Warning: `flutter` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
        ! Warning: `dart` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision d23dba223c (35 minutes ago), 2023-04-25 00:12:18 -0400
        • Engine revision 8fe8e94c02
        • Dart version 3.1.0 (build 3.1.0-38.0.dev)
        • DevTools version 2.23.1
        • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
        • Android SDK at /Users/huynq/Library/Android/sdk
        • Platform android-33, build-tools 32.0.0
        • ANDROID_HOME = /Users/huynq/Library/Android/sdk
        • Java binary at: /Applications/Android Studio Flamingo.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 14.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 14E222b
        • CocoaPods version 1.11.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2022.1)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    
    [✓] Android Studio (version 2022.2)
        • Android Studio at /Applications/Android Studio Flamingo.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    
    [✓] IntelliJ IDEA Community Edition (version 2022.1.1)
        • IntelliJ at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/221.5591.52/IntelliJ IDEA CE.app
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
    
    [✓] VS Code (version 1.77.3)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.62.0
    
    [✓] Connected device (3 available)
        • SM T225 (mobile) • R9JT3004VRJ • android-arm64  • Android 13 (API 33)
        • macOS (desktop)  • macos       • darwin-x64     • macOS 13.0.1 22A400 darwin-x64
        • Chrome (web)     • chrome      • web-javascript • Google Chrome 112.0.5615.137
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
  3. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    a: internationalizationSupporting other languages or locales. (aka i18n)
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Apr 25, 2023
  4. christopherfujino commented on Apr 25, 2023

    @christopherfujino
    Contributor

    @thkim1011 can you take a look at this one? Also, what priority do you think this is?

  5. self-assigned this
    on Apr 25, 2023
  6. added a commit that references this issue on Apr 25, 2023
    8be335f
  7. added
    r: fixedIssue is closed as already fixed in a newer version
    on Apr 26, 2023
  8. github-actions commented on May 10, 2023

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  9. locked as resolved and limited conversation to collaborators on May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

a: internationalizationSupporting other languages or locales. (aka i18n)found in release: 3.10Found to occur in 3.10found in release: 3.7Found to occur in 3.7has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versiontoolAffects the "flutter" command-line tool. See also t: labels.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions