• Tae Hyung Kim's avatar
    Relax syntax for gen-l10n (#130736) · c6b93b2d
    Tae Hyung Kim authored
    To preserve backward compatibility with the old parser which would
    ignore syntax errors, this PR introduces a way to treat the special
    characters `{` and `}` in the following way:
    1. If we encounter a `{` which searching for a string token and this `{`
    is not followed by a valid placeholder, then we treat the `{` as a
    string and continue lexing for strings.
    2. If we encounter a `}` while not within some expression (i.e.
    placeholders, arguments, plurals, or selects), then we treat the `}` as
    a string and continue lexing for strings.
    
    This makes it so that
    ```
    "helloWorld": "{ } { placeholder }",
    "@@helloWorld": {
      "placeholders": {
        "placeholder" {}
      }
    }
    ```
    treats the `{ }` as a string while `{ placeholder } ` is treated as a
    placeholder.
    
    Fixes https://github.com/flutter/flutter/issues/122404.
    c6b93b2d
localizations_utils.dart 20.4 KB