Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

internationalization: fix select with incorrect message#90096

Merged
HansMuller merged 3 commits intoflutter:masterfrom
asashour:90094_select
Sep 16, 2021
Merged

internationalization: fix select with incorrect message#90096
HansMuller merged 3 commits intoflutter:masterfrom
asashour:90094_select

Conversation

@asashour
Copy link
Contributor

When the user specifies incorrectselect message, there is a null exception thrown.

This PR fixes it.

Fixes#90094

  • I read theContributor Guide and followed the process outlined there for submitting PRs.
  • I read theTree Hygiene wiki page, which explains my responsibilities.
  • I read and followed theFlutter Style Guide, includingFeatures we expect every widget to implement.
  • I signed theCLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt.
  • All existing and new tests are passing.

@flutter-dashboardflutter-dashboardbot added the toolAffects the "flutter" command-line tool. See also t: labels. labelSep 15, 2021
);
});

testWithoutContext('should throw attempting to generate a select message with an incorrect message', () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@asashour do you think it's worth doing a similar test for plurals ?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Why not. However the plurals use a different mechanism as I thought before raising the PR.

Anyhow, test to be shortly added.

ened reacted with heart emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

A test case was added to ensure we don'tfail. However I am not sure if we should throw an exception instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I am not sure@asashour. For example. Intl.plural eventually has a check like this:

    ArgumentError.checkNotNull(other, 'other');    ArgumentError.checkNotNull(howMany, 'howMany');

So we can assume that a invalid input like{count, plural,} really IS an error, except when it means thatother is set to''. (I think this is unlikely but don't know).

For Intl.selectsomething has be to be defined, like shown in the code:

  /// Internal: Implements the logic for select - use [select] for  /// normal messages.  static T selectLogic<T>(Object choice, Map<Object, T> cases) {    // This will work if choice is a string, or if it's e.g. an    // enum and the map uses the enum values as choices.    var exact = cases[choice];    if (exact != null) return exact;    // If it didn't match exactly, take the toString and    // take the part after the period. We need to do this    // because enums print as 'EnumType.enumName' and periods    // aren't acceptable in ICU select choices.    var stringChoice = '$choice'.split('.').last;    var stringMatch = cases[stringChoice];    if (stringMatch != null) return stringMatch;    var other = cases['other'];    if (other == null) {      throw ArgumentError("The 'other' case must be specified");    }    return other;  }

So I think that failing meaningfully in both cases is acceptable.

@jmagman WDYT

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I don't have familiarity with this code,@HansMuller may have opinions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Looking ....

@HansMullerHansMuller added the a: internationalizationSupporting other languages or locales. (aka i18n) labelSep 15, 2021
Copy link
Contributor

@HansMullerHansMuller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This looks good, although I'd leave the plurals test out for now.

The user-guide needs to be updated to coverselect:#90153

);
});

testWithoutContext('should not fail attempting to generate a plural message with an incorrect message', () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

According to our documentation - flutter.dev/go/i18n-user-guide, "Messages With Plurals" - theother variation is required. As@enedpointed out,Intl.plural may accept this and assume thatother is an empty string, however that seems likely to mask an error.

It might be best to leave the plural test out for now, since this PR was really about fixing upselect.

Also: a more ambitious update to select/plurals has been proposed:#86906

Copy link
Contributor

@HansMullerHansMuller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM

@HansMullerHansMuller merged commiteb185d7 intoflutter:masterSep 16, 2021
@asashourasashour deleted the 90094_select branchSeptember 16, 2021 16:52
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@enedenedened left review comments

@jmagmanjmagmanjmagman left review comments

+1 more reviewer

@HansMullerHansMullerHansMuller approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

a: internationalizationSupporting other languages or locales. (aka i18n)toolAffects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

_CastError: Null check operator used on a null value at _generateSelectMethod(gen_l10n.dart:308)

4 participants

@asashour@ened@jmagman@HansMuller

Comments


[8]ページ先頭

©2009-2026 Movatter.jp