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

@mshurkaeu-public

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!

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