Skip to content

gen-l10n ignores explicit false values for arguments #118203

@maRci002

Description

@maRci002

Use case

There are multiple arguments for gen-l10n which has two syntax: --[no-]nullable-getter --[no-]synthetic-package --[no-]use-deferred-loading --[no-]required-resource-attributes.

Note: I'm going to use only nullable-getter in the examples just for simplicity.

In case of l10n.yaml configuration nullable-getter: false will be recognized however in case of gen-l10n tool the --nullable-getter false won't be recognized moreover no error is raised.

Steps:

  1. Create app with arb resource file
    • terminal:
      flutter create flutter_app && cd flutter_app && mkdir l10n && cd l10n && echo '{"test": "test"}' > app_en.arb
    • Windows cmd
      flutter create flutter_app && cd flutter_app && mkdir l10n && cd l10n && echo {"test": "test"} > app_en.arb
  2. Add dependencies in pubspec.yaml
    dependencies:
      flutter:
        sdk: flutter
      flutter_localizations:
        sdk: flutter
      intl: ^0.17.0
  3. Generate app_localizations.dart (note: this command will create a non synthetic package so AppLocalizations can be found under lib/l10n folder)
    flutter gen-l10n --nullable-getter false --no-synthetic-package --arb-dir l10n --output-dir lib/l10n --template-arb-file app_en.arb --output-localization-file app_localizations.dart --output-class AppLocalizations --preferred-supported-locales en
  4. In main.dart import app_localizations.dart
    import 'package:flutter_app/l10n/app_localizations.dart';
  5. In a build method use
    AppLocalizations.of(context).test;

If rerunning command via --no-nullable-getter the no nullable getter should work properly:
flutter gen-l10n --no-nullable-getter --no-synthetic-package --arb-dir l10n --output-dir lib/l10n --template-arb-file app_en.arb --output-localization-file app_localizations.dart --output-class AppLocalizations --preferred-supported-locales en

Proposal

  • --nullable-getter false / synthetic-package false ... should just work or throw error.
  • If it cannot be modified, it should be properly documented when calling to flutter gen-l10n -h

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: internationalizationSupporting other languages or locales. (aka i18n)c: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamtoolAffects 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