Skip to content

flutter gen-i10n throws Found syntax errors. after upgrading to 3.7.0 (mostly affecting china mirror) #119435

Description

@bluealert455

In flutter 3.3.10,everything is fine.
Since upgrading to 3.7.0,flutter gen-l10n throws "found syntax errors" exception.
app_en.arb:
{
"helloWorld": "Hello World!",
"@helloworld": {
"description": "The conventional newborn programmer greeting"
}
}

app_es.arb:
{
"helloWorld": "¡Hola Mundo!"
}

Activity

  1. codespearhead commented on Jan 29, 2023

    @codespearhead

    Send us a link to the repository with a minimal working example, so we can reproduce the error ourselves.

  2. bluealert455 commented on Jan 29, 2023

    @bluealert455
    Author
  3. dbds commented on Jan 30, 2023

    @dbds

    I have the same problem ,after upgrading to 3.7.0, build fail because gen-l10n report error: found syntax errors.

  4. conghaonet commented on Jan 30, 2023

    @conghaonet

    I have the same problem.
    run flutter gen-l10n, output:

    Found syntax errors.
    

    my code:

    # lib/l10n/app_en.arb
    {
      "helloWorld": "Hello World!",
      "@helloWorld": {
        "description": "The conventional newborn programmer greeting"
      }
    }
    
    # lib/l10n/app_es.arb
    {
      "helloWorld": "¡Hola Mundo!"
    }
    
    # l10n.yaml
    arb-dir: lib/l10n
    template-arb-file: app_en.arb
    output-localization-file: app_localizations.dart
    
    # pubspec.yaml
    ...
    flutter:
      generate: true
    ...
    

    flutter doctor -v

    [√] Flutter (Channel stable, 3.7.0, on Microsoft Windows [版本 10.0.19045.2486], locale zh-CN)
        • Flutter version 3.7.0 on channel stable at C:\myDev\flutter
        • Upstream repository https://github.com/flutter/flutter.git           
        • Framework revision b06b8b2710 (6 days ago), 2023-01-23 16:55:55 -0800
        • Engine revision b24591ed32                                           
        • Dart version 2.19.0                                                  
        • DevTools version 2.20.1                                              
        • Pub download mirror https://pub.flutter-io.cn                        
        • Flutter download mirror https://storage.flutter-io.cn                
                                                                               
    [√] Windows Version (Installed version of Windows is version 10 or higher) 
    
    [√] VS Code (version 1.73.0)
        • VS Code at C:\Users\haoco\AppData\Local\Programs\Microsoft VS Code
        • Flutter extension version 3.52.0
    
    [√] Connected device (3 available)
        • Windows (desktop) • windows • windows-x64    • Microsoft Windows [版本 10.0.19045.2486]
        • Chrome (web)      • chrome  • web-javascript • Google Chrome 109.0.5414.120
        • Edge (web)        • edge    • web-javascript • Microsoft Edge 109.0.1518.70
    
    [√] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
    
  5. darshankawar commented on Jan 30, 2023

    @darshankawar
    Member

    Thanks for the report. I am unable to replicate this error on latest stable or master version. I cloned the repo provided and then ran flutter gen l10n which didn't result in the said error.
    I also have a demo app which has the setup as mentioned in above comment using which too, I am unable to replicate the error.

    There's an issue which throws the Found syntax errors. but only when we manually update one of the .arb files as mentioned in that issue and then trying to run the command flutter gen l10n throws the error which is similar to the one reported in this thread.

    Please check if there's any syntax error in your .arb files and also check this documentation for proper config.

  6. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jan 30, 2023
  7. fuhaixiao commented on Jan 30, 2023

    @fuhaixiao

    @darshankawar I have this problem too, it only happens on windows

  8. darshankawar commented on Jan 30, 2023

    @darshankawar
    Member

    Thanks for the details @motionz-von. Eveyone else facing this issue, can you please confirm if you see same log or you are using Flutter China mirror ?

  9. conghaonet commented on Jan 30, 2023

    @conghaonet

    @darshankawar
    I am using Flutter China mirror( https://storage.flutter-io.cn ).
    running flutter gen-l10n -v, output:

    [  +10 ms] executing: [C:\myDev\flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
    [ +113 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
    [   +1 ms] b06b8b2710955028a6b562f5aa6fe62941d6febf                                                   
    [        ] executing: [C:\myDev\flutter/] git tag --points-at b06b8b2710955028a6b562f5aa6fe62941d6febf
    [ +147 ms] Exit code 0 from: git tag --points-at b06b8b2710955028a6b562f5aa6fe62941d6febf
    [        ] 3.7.0
    [   +9 ms] executing: [C:\myDev\flutter/] git rev-parse --abbrev-ref --symbolic @{upstream}
    [  +92 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{upstream}
    [        ] origin/stable                                                
    [        ] executing: [C:\myDev\flutter/] git ls-remote --get-url origin
    [  +99 ms] Exit code 0 from: git ls-remote --get-url origin
    [        ] https://github.com/flutter/flutter.git
    [ +108 ms] executing: [C:\myDev\flutter/] git rev-parse --abbrev-ref HEAD
    [ +106 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
    [        ] stable
    [  +54 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.
    [   +2 ms] Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
    [  +38 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
    [        ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
    [        ] 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.
    [  +51 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.
    
    
    [ +109 ms] "flutter gen-l10n" took 369ms.
    [   +3 ms] Found syntax errors.
    [        ] 
               #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
               #1      generateLocalizations (package:flutter_tools/src/localizations/gen_l10n.dart:75:5)
               #2      GenerateLocalizationsCommand.runCommand (package:flutter_tools/src/commands/generate_localizations.dart:241:24)
               #3      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:1426:12)
               <asynchronous suspension>
               #4      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1257:27)
               <asynchronous suspension>
               #5      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
               <asynchronous suspension>
               #6      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
               <asynchronous suspension>
               #7      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:283:9)
               <asynchronous suspension>
               #8      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
               <asynchronous suspension>
               #9      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
               <asynchronous suspension>
               #10     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:64:9)
               <asynchronous suspension>
               #11     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
               <asynchronous suspension>
               #12     main (package:flutter_tools/executable.dart:91:3)
               <asynchronous suspension>
    
    
    [ +264 ms] ensureAnalyticsSent: 261ms
    [        ] Running 0 shutdown hooks
    [        ] Shutdown hooks complete
    [        ] exiting with code 1
    
  10. AndreBlumenthal commented on Jan 30, 2023

    @AndreBlumenthal

    So in my case I have syntax error because i use {PLACEHOLDER_NAMES} with underscores. I think the purpose of this is to have a unified approach of naming. But why are keys with underscores allowed then?
    Secondly I have some placeholders in the format of {{.Name}}. This is, because our Go backend uses the same translations and expects this behaviour. It is debatable if this is a good approach of having shared translations.
    Third, I have a translation string that shows all allowed characters for a password. So it looks like this ...(){}[]... but this fails, because of the {}. But there is no way for me to escape these characters

  11. deczaloth commented on Jan 30, 2023

    @deczaloth

    So in my case I have syntax error because i use {PLACEHOLDER_NAMES} with underscores. I think the purpose of this is to have a unified approach of naming. But why are keys with underscores allowed then? Secondly I have some placeholders in the format of {{.Name}}. This is, because our Go backend uses the same translations and expects this behaviour. It is debatable if this is a good approach of having shared translations. Third, I have a translation string that shows all allowed characters for a password. So it looks like this ...(){}[]... but this fails, because of the {}. But there is no way for me to escape these characters

    @AndreBlumenthal, I think your problem would be more related to the issue described here:
    #119375

  12. zakblacki commented on Jan 31, 2023

    @zakblacki

    I can confirm it's the same problem after upgrading ! here the result :

    `      `[  +86 ms] "flutter gen-l10n" took 287ms.
            [   +3 ms] Found syntax errors.
             [        ] 
               #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
               #1      generateLocalizations (package:flutter_tools/src/localizations/gen_l10n.dart:75:5)
               #2      GenerateLocalizationsCommand.runCommand (package:flutter_tools/src/commands/generate_localizations.dart:241:24)
               #3      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:1426:12)
               <asynchronous suspension>
               #4      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1257:27)
               <asynchronous suspension>
               #5      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
               <asynchronous suspension>
               #6      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
               <asynchronous suspension>
               #7      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:283:9)
               <asynchronous suspension>
               #8      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
               <asynchronous suspension>
               #9      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
               <asynchronous suspension>
               #10     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:64:9)
               <asynchronous suspension>
               #11     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
               <asynchronous suspension>
               #12     main (package:flutter_tools/executable.dart:91:3)
               <asynchronous suspension>
    `
    
  13. 8 remaining items

  14. darshankawar commented on Jan 31, 2023

    @darshankawar
    Member
  15. changed the title [-]Since upgrading to 3.7.0,l10n doesn't work[/-] [+]`flutter gen-i10n` throws `Found syntax errors.` after upgrading to 3.7.0[/+] on Jan 31, 2023
  16. changed the title [-]`flutter gen-i10n` throws `Found syntax errors.` after upgrading to 3.7.0[/-] [+]`flutter gen-i10n` throws `Found syntax errors.` after upgrading to 3.7.0 (mostly affecting china mirror)[/+] on Jan 31, 2023
  17. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    platform-windowsBuilding on or for Windows specifically
    on Jan 31, 2023
  18. darshankawar commented on Jan 31, 2023

    @darshankawar
    Member

    Please see #119593 which has a potential fix.

  19. AlexV525 commented on Jan 31, 2023

    @AlexV525
    Member

    The problem is related to any mirrors rather than China-specific, please see #119593 (comment) for the temporary workaround until the PR fixes this.

  20. bluealert455 commented on Jan 31, 2023

    @bluealert455
    Author

    Thx!
    Problem solved!
    Workaround from @AlexV525 in #119593
    #119593 (comment)

    PS:The message "Flutter assets will be downloaded from $overrideUrl. Make sure you trust this source!" should be a warning rather than a error.

  21. AlexV525 commented on Feb 3, 2023

    @AlexV525
    Member

    It seems to be more related to plural and variables with l10n.

    Your issue is not related to this one, it's the new syntax that breaks previous arb files.

  22. remi-martin commented on Feb 3, 2023

    @remi-martin

    Your issue is not related to this one, it's the new syntax that breaks previous arb files.

    Thanks, I deleted my message because it was just a missing "}" at the end of the String.
    However I don't understand why I never had an issue with this String before as the app was built successfully several times with it and no error was thrown.

  23. thkim1011 commented on Feb 6, 2023

    @thkim1011
    Contributor

    @remi-martin Previously, the gen-l10n tool used RegEx matching to see if a message has a plural or select, and did some replacements. If it didn't match it would silently do nothing to the string.

  24. 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.

  25. 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)c: crashStack traces logged to the consolec: regressionIt was better in the past than it is nowframeworkflutter/packages/flutter repository. See also f: labels.from: chinaIssues from the Flutter China communityplatform-windowsBuilding on or for Windows specificallyr: duplicateIssue is closed as a duplicate of an existing issuetoolAffects 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