Skip to content

ICU Lexing Error: Unexpected character #119375

Description

@deczaloth

Steps to Reproduce

  1. Follow steps for adding l10n support to app
  2. In app_es.arb file update the hello world string with this one: "helloWorld": "This character {"
  3. Run the app.

Expected results:
I was expecting to be able to use the localization string to get that string in my app.

Actual results:
Error is thrown:

[app_es.arb:helloWorld] ICU Syntax Error: Expected "identifier" but found no tokens.
This character {
^
Generating synthetic localizations package failed with 1 error:

Exception: Found syntax errors.

Logs
[  +19 ms] executing: [C:\src\flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[  +97 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] b06b8b2710955028a6b562f5aa6fe62941d6febf
[        ] executing: [C:\src\flutter/] git tag --points-at b06b8b2710955028a6b562f5aa6fe62941d6febf
[ +103 ms] Exit code 0 from: git tag --points-at b06b8b2710955028a6b562f5aa6fe62941d6febf
[   +2 ms] 3.7.0
[  +18 ms] executing: [C:\src\flutter/] git rev-parse --abbrev-ref --symbolic @{upstream}
[  +89 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{upstream}
[        ] origin/stable
[   +1 ms] executing: [C:\src\flutter/] git ls-remote --get-url origin
[  +83 ms] Exit code 0 from: git ls-remote --get-url origin
[   +1 ms] https://github.com/flutter/flutter.git
[ +100 ms] executing: [C:\src\flutter/] git rev-parse --abbrev-ref HEAD
[  +93 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] stable
[  +72 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.
[   +3 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.
[  +79 ms] executing: C:\Users\Julian\AppData\Local\Android\sdk\platform-tools\adb.exe devices -l
[  +94 ms] List of devices attached
           R9YT60RH43P            device product:gta8wifieea model:SM_X200 device:gta8wifi transport_id:1
[   +8 ms] C:\Users\Julian\AppData\Local\Android\sdk\platform-tools\adb.exe -s R9YT60RH43P shell getprop
[  +98 ms] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[  +12 ms] 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.
[ +180 ms] Initializing file store
[   +4 ms] Done initializing file store
[  +23 ms] gen_localizations: Starting due to {}
[ +113 ms] [app_es.arb:helloWorld] ICU Syntax Error: Expected "identifier" but found no tokens.
                        This character {
                                         ^
[  +16 ms] Persisting file store
[   +6 ms] Done persisting file store
[  +16 ms] "flutter run" took 824ms.
[  +36 ms] Generating synthetic localizations package failed with 1 error:

           Exception: Found syntax errors.
[   +1 ms] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      generateLocalizationsSyntheticPackage (package:flutter_tools/src/dart/generate_synthetic_packages.dart:67:5)
           <asynchronous suspension>
           #2      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:1402:7)
           <asynchronous suspension>
           #3      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1257:27)
           <asynchronous suspension>
           #4      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #5      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
           <asynchronous suspension>
           #6      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:283:9)
           <asynchronous suspension>
           #7      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #8      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
           <asynchronous suspension>
           #9      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:64:9)
           <asynchronous suspension>
           #10     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #11     main (package:flutter_tools/executable.dart:91:3)
           <asynchronous suspension>


[ +218 ms] ensureAnalyticsSent: 213ms
[   +1 ms] Running 0 shutdown hooks
[        ] Shutdown hooks complete
[        ] exiting with code 1

[app_es.arb:helloWorld] ICU Syntax Error: Expected "identifier" but found no tokens.
    This character {
                     ^
Generating synthetic localizations package failed with 1 error:

Exception: Found syntax errors.

[√] Flutter (Channel stable, 3.7.0, on Microsoft Windows [Version 10.0.19045.2486], locale de-DE)
    • Flutter version 3.7.0 on channel stable at C:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b06b8b2710 (4 days ago), 2023-01-23 16:55:55 -0800
    • Engine revision b24591ed32
    • Dart version 2.19.0
    • DevTools version 2.20.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at C:\Users\Julian\AppData\Local\Android\sdk
    • Platform android-33, build-tools 33.0.1
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Professional 2022 17.4.2)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Professional
    • Visual Studio Professional 2022 version 17.4.33122.133
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2022.1)
    • Android Studio at C:\Program Files\Android\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.15+0-b2043.56-8887301)

[√] Connected device (4 available)
    • SM X200 (mobile)  • R9YT60RH43P • android-arm64  • Android 13 (API 33)
    • Windows (desktop) • windows     • windows-x64    • Microsoft Windows [Version 10.0.19045.2486]
    • Chrome (web)      • chrome      • web-javascript • Google Chrome 109.0.5414.76
    • Edge (web)        • edge        • web-javascript • Microsoft Edge 109.0.1518.69

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

• No issues found!

Activity

  1. BetterB0y commented on Jan 28, 2023

    @BetterB0y

    Its seems it is now checking some errors at runtime. Just check this line where it shows you and check if you have everything correct.

    And its seems it now has some issue with placeholder with camelCase
    for example.
    selectedItems

  2. deczaloth commented on Jan 28, 2023

    @deczaloth
    Author

    @BetterB0y, the problem is the curly brackets. They are part of the syntax to declare variables inside a string in an arb file. I tried a few things to escape the curly brackets to be able to show them in text in my App, but all i tried failed included simple quotes, double quotes, backslash...

    I already oppened two related questions in SO, but i am affraid it is a but in the parser...

    https://stackoverflow.com/questions/75263861/how-to-fix-icu-lexing-error-unexpected-character-in-flutter
    https://stackoverflow.com/questions/75235288/how-to-fix-icu-syntax-error-expected-identifier-but-found-0-error-in-f

  3. darshankawar commented on Jan 30, 2023

    @darshankawar
    Member

    Thanks for the report.
    I followed the steps mentioned to add localization in the document and then ran flutter gen-l10n which resulted in below:

    [app_es.arb:helloWorld] ICU Syntax Error: Expected "identifier" but found no tokens.
        This character {
                         ^
    Found syntax errors.
    dhs@Dhss-MacBook-Pro test_app % 
    
    

    Keeping this issue open for team's insights on expected behavior.

    stable, master flutter doctor -v
    [!] Flutter (Channel stable, 3.7.0, on macOS 12.2.1 21D62 darwin-x64, locale
        en-GB)
        • Flutter version 3.7.0 on channel stable at
          /Users/dhs/documents/fluttersdk/flutter
        ! Warning: `flutter` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
          your current Flutter SDK checkout at
          /Users/dhs/documents/fluttersdk/flutter. Consider adding
          /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
        ! Warning: `dart` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
          current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
          Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
          of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision b06b8b2710 (28 hours ago), 2023-01-23 16:55:55 -0800
        • Engine revision b24591ed32
        • Dart version 2.19.0
        • DevTools version 2.20.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.
    
    [!] Xcode - develop for iOS and macOS (Xcode 12.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        ! Flutter recommends a minimum Xcode version of 13.
          Download the latest version or update via the Mac App Store.
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] VS Code (version 1.62.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.21.0
    
    [✓] Connected device (5 available)
        • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
        • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
          ios            • iOS 14.4.1 18D61
        • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
          ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
        • macOS (desktop)            • macos                                    •
          darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
        • Chrome (web)               • chrome                                   •
          web-javascript • Google Chrome 98.0.4758.80
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    ! Doctor found issues in 1 category.
    
    [!] Flutter (Channel master, 3.7.0-29.0.pre.26, on macOS 12.2.1 21D62
        darwin-x64, locale en-GB)
        • Flutter version 3.7.0-29.0.pre.26 on channel master at
          /Users/dhs/documents/fluttersdk/flutter
        ! Warning: `flutter` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
          your current Flutter SDK checkout at
          /Users/dhs/documents/fluttersdk/flutter. Consider adding
          /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
        ! Warning: `dart` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
          current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
          Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
          of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 15cd00f1ed (2 hours ago), 2023-01-29 21:58:05 -0500
        • Engine revision a7bb0e4108
        • Dart version 3.0.0 (build 3.0.0-179.0.dev)
        • DevTools version 2.20.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.
    
    [!] Xcode - develop for iOS and macOS (Xcode 12.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        ! Flutter recommends a minimum Xcode version of 13.
          Download the latest version or update via the Mac App Store.
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] VS Code (version 1.62.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.21.0
    
    [✓] Connected device (5 available)
        • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
        • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
          ios            • iOS 14.4.1 18D61
        • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
          ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
        • macOS (desktop)            • macos                                    •
          darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
        • Chrome (web)               • chrome                                   •
          web-javascript • Google Chrome 98.0.4758.80
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    ! Doctor found issues in 1 category.
    
    
    
    
  4. added
    frameworkflutter/packages/flutter repository. See also f: 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 Jan 30, 2023
  5. darshankawar commented on Jan 30, 2023

    @darshankawar
    Member
  6. thkim1011 commented on Jan 31, 2023

    @thkim1011
    Contributor

    Helllo! There is an escaping syntax that is implemented but not enabled by default as it is a new feature that wasn't completely backward compatible with existing ICU message strings.

    First, add the following to your l10n.yaml file:

    use-escaping: true
    

    Then, this will allow you to wrap parts of your strings in single quotes to ignore any syntax within the single quotes; to use a single quote normally as a character and not an escape, use a double single quote. For example,

    {
      message: "This '{isn''t}' obvious"
    }
    

    becomes

    String get message => "This {isn't} obvious";
    

    See here for information on the syntax. I'll add this to the documentation later.

    See here for the PR in which this was introduced.

  7. thkim1011 commented on Feb 6, 2023

    @thkim1011
    Contributor

    By the way the documentation has been updated to include how to escape parts of the syntax. See here: https://docs.flutter.dev/development/accessibility-and-localization/internationalization#escaping-syntax.

  8. github-actions commented on Mar 3, 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 Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: internationalizationSupporting other languages or locales. (aka i18n)found in release: 3.7Found to occur in 3.7frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: solvedIssue is closed as solved

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions