[gen_l10n] A name that has any dollar sign ($) isn't allowed.

This issue has been created since 2022-09-23.

flutter_localizations(gen_l10n comamnd) doesn't allow a property name to have a dollar sign ($) in any postion.

Steps to Reproduce

  1. Execute flutter gen-l10n involved in any *.arb file which has a key that contains a dollar sign ($).
  2. Loot at the terminal output.

Expected results: Dollar sign can be a part of the property name, so it should succeed.

Actual results: gen-l10n failed.

Code sample

In app_en.arb file:

{
  "$address": "Address:"
}

Logs

Invalid ARB resource name "$address" in LocalFile: '<ProjectFolder>\lib/l10n\app_en.arb'.
Resources names must be valid Dart method names: they have to be camel case, cannot start with a number or
underscore, and cannot contain non-alphanumeric characters.
navaronbracke wrote this answer on 2022-09-23

In plain Dart the string "$address" would resolve to a string which interpolates the value of a variable called address,
i.e.

final int address = 42;

final out = "$address";

print(out); // "42" 

This is probably why it is disallowed.

Either the warning message should be expanded to include a mention of $ signs, or the tool should escape
the dollar sign when generating translations, using \$.

asashour wrote this answer on 2022-09-23

I guess the reason mentioned, that the name must be a valid Dart method name. However, methods are allowed to start with $, e.g.

class A {
  void $asdf() {}

  void f() {
    var x = $asdf();
  }
}

I think this should be handled, or there is another reason of rejection.

navaronbracke wrote this answer on 2022-09-23

@asashour I forgot to mention, the format "$foo" is used as a string with a parameter in the gen_l10n tool, that might be the reason for the rejection?

See https://github.com/flutter/flutter/blob/master/packages/flutter_localizations/lib/src/l10n/README.md#values-with-parameters-plurals

liplum wrote this answer on 2022-09-23

methods are allowed to start with $

Yes, I want to use it to overload the placeholders functions because dart doesn't have function overloading feature.

{
  "foo$A": "foo {a}",
  "@foo$A": {
    "placeholders": {
      "a": {
        "type": "int",
      }
    }
  },
  "foo$B": "bar {a} {b}",
  "@foo$B": {
    "placeholders": {
      "a": {
        "type": "int",
      },
      "b": {
        "type": "String",
      }
    }
  }
}

It's not only about prefix-$ but also includes a dollar sign in the middle.

asashour wrote this answer on 2022-09-23

... the format "$foo" is used as a string with a parameter in the gen_l10n tool, that might be the reason for the rejection?

Thanks, but this applies to the values, not keys.

What I recall, is that the key must be a valid method name, because a corresponding getter is created in AppLocalizations, which is overridden by the specific language class.

huycozy wrote this answer on 2022-09-23

Hi @liplum, thanks for filing the issue. This issue is reproducible on the latest stable and master channels with provided sample code (app_en.arb)

Logs
Invalid ARB resource name "$address" in LocalFile: '/Users/huynq/Documents/NEVERCODE.IO/RepoduceProjects/reproduce_issue_gen_l10n/lib/l10n/app_en.arb'.
Resources names must be valid Dart method names: they have to be camel case, cannot start with a number or underscore, and cannot contain non-alphanumeric characters.
flutter doctor -v
[✓] Flutter (Channel stable, 3.3.2, on macOS 12.6 21G115 darwin-x64, locale en-VN)
    • Flutter version 3.3.2 on channel stable at /Users/huynq/Documents/GitHub/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision e3c29ec00c (6 days ago), 2022-09-14 08:46:55 -0500
    • Engine revision a4ff2c53d8
    • Dart version 2.18.1
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/huynq/Library/Android/sdk
    • Platform android-33, build-tools 31.0.0
    • ANDROID_HOME = /Users/huynq/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 13E113
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • 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.12+0-b1504.28-7817840)

[✓] 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.71.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.48.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 12.6 21G115 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 105.0.5195.125

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

• No issues found!
[✓] Flutter (Channel master, 3.4.0-28.0.pre.123, on macOS 12.6 21G115 darwin-x64, locale en-VN)
    • Flutter version 3.4.0-28.0.pre.123 on channel master at /Users/huynq/Documents/GitHub/flutter_master
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4aa27d844e (3 minutes ago), 2022-09-22 21:00:22 -0700
    • Engine revision a5489ce4f9
    • Dart version 2.19.0 (build 2.19.0-229.0.dev)
    • DevTools version 2.17.0

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/huynq/Library/Android/sdk
    • Platform android-33, build-tools 31.0.0
    • ANDROID_HOME = /Users/huynq/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14A309
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • 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.12+0-b1504.28-7817840)

[✓] 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.71.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.48.0

[✓] Connected device (3 available)
    • SM T225 (mobile) • R9JT3004VRJ • android-arm64  • Android 12 (API 31)
    • macOS (desktop)  • macos       • darwin-x64     • macOS 12.6 21G115 darwin-x64
    • Chrome (web)     • chrome      • web-javascript • Google Chrome 105.0.5195.125
    ! Error: Failed to prepare the device for development. Please unlock and reconnect the device. (code 806)

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

• No issues found!

Labeling this issue for further insights from the team. Thanks!

More Details About Repo
Owner Name flutter
Repo Name flutter
Full Name flutter/flutter
Language Dart
Created Date 2015-03-06
Updated Date 2022-10-05
Star Count 145516
Watcher Count 3569
Fork Count 23400
Issue Count 11194

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
ctrlf shouldn't require a minor mode 11 2021-01-15 2022-10-05
Where I can find arrays of rendered words not passed any transformations? 2 2021-01-20 2022-09-29
canvasW and extension.MIN_EXT is not defined in TaobaoPlatform 2 2021-02-07 2022-09-28
xbox elite series 2 controller 0 2021-12-16 2022-10-04
RuntimeError: Sizes of tensors must match except in dimension 1. Got 12 and 11 in dimension 2 (The offending index is 1) 1 2021-12-08 2022-07-28
PLEASE ADD FULLSCREEN BACK! 4 2022-07-18 2022-09-28
Feature: Support language service traces 4 2022-01-25 2022-09-27
Add help for new functionality in Save-KBUpdate 1 2022-05-13 2022-08-18
Feature request - HUD 0 2021-06-21 2022-09-08
Question: permantent / evergreen campaigns, AKA how to not destroy the membership at the last step? 6 2022-07-06 2022-08-17
What is the correct way to forward events when using `<Route component={..}>`? 2 2021-04-25 2022-09-06
Simultaneous encodes 2 2021-07-26 2022-09-14
Allow overriding column setter 3 2022-05-12 2022-09-26
Bug: glb loading error when face-count is zero. 1 2022-06-14 2022-08-14
How can I fix the FBX animation and mesh are rotated 180 degrees in the left-hand coordinate system 1 2022-06-10 2022-09-12
Implement isLoop as a type guard 3 2021-03-29 2022-08-21
Create a configuration provider to configure ports from base addresses from CoreWCF.ConfigurationManager 0 2022-07-14 2022-09-20
Redraw failure and screen flicker under Linux 10 2022-04-29 2022-09-14
[FEATURE]希望环境加压功能增加通过ADB调用传参的接口 0 2022-07-07 2022-09-23
documentation request: List in DocSearch's prerequisites that it requires use of standard ports (80 / 443) 5 2022-06-19 2022-09-08
Implement search for Schema Registry 1 2021-12-09 2022-10-05
break not work well when exists more than one break point. 2 2022-04-23 2022-07-08
up down pry command never works for me. 0 2022-04-24 2022-07-08
Hi, when to release break 0.4.0 to rubygems? i saw you add changelog for 0.4.0 almost half years ago. 2 2022-05-05 2022-10-03
Fix matomo browser console errors on staking dapp 0 2021-09-17 2022-08-26
fix: NewMeeting updatedAt updates after meeting ends 0 2022-08-11 2022-08-23
ads are required 1 2021-11-24 2022-01-16
`download_job_artifact_file` method fails when the artifact is a non-JSON text file 1 2021-07-05 2022-09-23
home, invert entstop 1 2021-10-31 2022-09-11
Error generating android package: Unsupported MIME type: image/x-icon 3 2021-08-29 2022-09-28
Option to stop bot after sell 0 2021-11-09 2022-07-17
Removing child nodes will not update range 0 2021-10-27 2022-09-29
Is it appropriate to use halving grid search as a hyper-parameter tuning strategy? 2 2021-09-25 2022-10-03
play ui shows nothing (js error play:579 Uncaught TypeError: response.data[0][0].startsWith is not a function) 1 2022-05-13 2022-07-16
Storybook can't run within an ESM package 12 2021-09-28 2022-09-28
Question - Does Single SPA support SystemJS Depcache? 1 2021-02-08 2022-08-17
update workflow regarding compiling Wish.app 0 2021-11-08 2022-08-27
Google Play: com.dragonflow.android.orbi 0 2022-10-01 2022-09-24
Geomap Dynamic Geojson Style Mapping 1 2022-09-22 2022-09-25
How to pre-train from scratch? 4 2020-06-24 2022-08-17
PowerShell spelled improperly in RabbitMQTrigger-PowerShell/metadata.json 0 2022-01-21 2022-09-28
springboot使用jar包部署后,下载的excel文件打不开,求解 2 2022-07-15 2022-09-28
aws-s3-notifications: Cannot delete lambda notification 2 2022-05-25 2022-09-28
[Bug] [RD] Login time-zone problem leads to blank UI interfaces 2 2022-03-22 2022-09-10
[BUG] tab org-cycle appears no longer bound/working in org-journal Journal mode 10 2022-05-19 2022-09-22
Support for azurerm_storage_blob SAS token 4 2021-11-05 2022-09-25
Samae validation rule with null values 3 2022-08-11 2022-09-19
😵‍💫 New object based style config for vite-plugin-vuetify makes vite reload the browser 3 2022-09-08 2022-09-27
Example use unavailable dep 1 2016-01-27 2022-09-10
typo fixed in Wrap.debugFillProperties for crossAxisAlignment 1 2021-09-03 2022-09-28