Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding tabSemanticsLabel to CupertinoLocalizations #55336

Merged
merged 15 commits into from May 1, 2020

Conversation

Piinks
Copy link
Contributor

@Piinks Piinks commented Apr 21, 2020

Description

Closing out this TODO:

// TODO(xster): This needs localization support. https://github.com/flutter/flutter/issues/13452

This localizes the hint for the tab index to CupertinoTabBar.

Related Issues

#13452

Tests

Added unit test for CupertinoLocalizations.tabSemanticsLabel.
Updates affected tests.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

WIP

  • Yes, this is a breaking change. If not, delete the remainder of this section.
    • I wrote a design doc: https://flutter.dev/go/template Replace this with a link to your design doc's short link
    • I got input from the developer relations team, specifically from: Replace with the names of who gave advice
    • I wrote a migration guide: Replace with a link to your migration guide

@Piinks Piinks added team Infra upgrades, team productivity, code health, technical debt. See also team: labels. framework flutter/packages/flutter repository. See also f: labels. a: internationalization Supporting other languages or locales. (aka i18n) f: cupertino flutter/packages/flutter/cupertino repository labels Apr 21, 2020
@Piinks
Copy link
Contributor Author

Piinks commented Apr 21, 2020

@shihaohong does this look about right? I'm going to add some tests, just wanted to check that I wired this up right. :)

@Piinks
Copy link
Contributor Author

Piinks commented Apr 21, 2020

The script made a very large change to packages/flutter_localizations/lib/src/l10n/cupertino_kn.arb

@Piinks Piinks mentioned this pull request Apr 21, 2020
9 tasks
Copy link
Contributor

@shihaohong shihaohong left a comment

Choose a reason for hiding this comment

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

Everything looks good! The only thing that's missing is running the following commands from your Flutter repo:

dart dev/tools/localization/bin/gen_localizations.dart --overwrite
dart dev/tools/localization/bin/encode_kn_arb_files.dart

The first command generates the localization delegates for each locale so that it will display 'TBD' for non-English locales for the tab label until translations are completed

The second command encodes Kannada script into Unicode escapes so that some versions of emacs do not crash when opening the Flutter repository.

"copyButtonLabel": "\u0ca8\u0c95\u0cb2\u0cbf\u0cb8\u0cbf",
"pasteButtonLabel": "\u0c85\u0c82\u0c9f\u0cbf\u0cb8\u0cbf",
"selectAllButtonLabel": "\u0c8e\u0cb2\u0ccd\u0cb2\u0cb5\u0ca8\u0ccd\u0ca8\u0cc2\u0020\u0c86\u0caf\u0ccd\u0c95\u0cc6\u0cae\u0cbe\u0ca1\u0cbf"
"datePickerHourSemanticsLabelOne": "$hour ಗಂಟೆ",
Copy link
Contributor

Choose a reason for hiding this comment

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

This requires running flutter/dev/tools/localization/bin/encode_kn_arb_files.dart. There's a bug with emacs that causes the editor to crash when it detects certain characters in Kannada script.

I need to still make this part of the gen_localizations and gen_date_localizations scripts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Awesome! Thank you! Updates on the way.

@shihaohong
Copy link
Contributor

For a unit test, add something similar to https://github.com/flutter/flutter/blob/master/packages/flutter_localizations/test/cupertino/translations_test.dart#L87 and I think you should be good!

@Piinks Piinks marked this pull request as ready for review April 22, 2020 22:44
@Piinks Piinks changed the title [WIP] Adding tabLabel to CupertinoLocalizations Adding tabLabel to CupertinoLocalizations Apr 22, 2020
@Piinks
Copy link
Contributor Author

Piinks commented Apr 22, 2020

It looks like this may be a breaking change? I think I will have to update the existing tests with CupertinoTabBar to add Localizations. Unless these tests should be getting a default value (like the hard-coded value that was there)

@shihaohong
Copy link
Contributor

shihaohong commented Apr 22, 2020

I think you're right... I just realized that this also changes the behavior for the tab label in other locales (for example, using the es locale would now cause the text to show TBD instead of what we currently have), which is breaking and we should follow the policy for it, but seems acceptable since we've been doing this for every new localized message.

@Piinks Piinks added the c: API break Backwards-incompatible API changes label Apr 23, 2020
@Piinks
Copy link
Contributor Author

Piinks commented Apr 23, 2020

@Hixie and @HansMuller can you advise on this change?

This is breaking in that it

  • Changes the current hint provided in the CupertinoTabBar for various locales, and
  • Requires that the use of the CupertinoTabBar will require a Localizations parent to provide the appropriate hint.

@shihaohong mentioned that CupertinoApp should introduce the localizations delegate by default, which would make it less breaking in those cases... although the CupertinoTabBar may not be used in that context alone, as the framework tests prove out.

I'm still diagnosing a Semantics break here as well, just curious in general how this might be made less breaking. A similar change was made for MaterialLocalizations a few years back here: #13714

@Hixie
Copy link
Contributor

Hixie commented Apr 23, 2020

CupertinoApp should definitely introduce the l10ns, just like MaterialApp does.

@Hixie
Copy link
Contributor

Hixie commented Apr 23, 2020

i would check with devrel that they agree that having the Cupertino library follow the Material library's lead in how to do l10n is a good idea. assuming that they do, then a migration guide should be simple enough to provide.

@Piinks Piinks changed the title Adding tabLabel to CupertinoLocalizations Adding tabSemanticsLabel to CupertinoLocalizations Apr 23, 2020
@Piinks Piinks added the a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) label Apr 23, 2020
Copy link
Contributor

@shihaohong shihaohong left a comment

Choose a reason for hiding this comment

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

LGTM!

packages/flutter/lib/src/cupertino/bottom_tab_bar.dart Outdated Show resolved Hide resolved
packages/flutter/test/cupertino/tab_scaffold_test.dart Outdated Show resolved Hide resolved
Co-Authored-By: Shi-Hao Hong <shihaohong@google.com>
@Piinks
Copy link
Contributor Author

Piinks commented Apr 23, 2020

Thanks for the guidance and review @shihaohong! 🎉
I'm putting together a migration guide and gathering some feedback on the break. I'll mark this WIP in the meantime.

Copy link
Member

@xster xster left a comment

Choose a reason for hiding this comment

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

Great. Thanks Kate!

child: Directionality(
textDirection: TextDirection.ltr,
child: widget,
),
),
);
}
Copy link
Member

Choose a reason for hiding this comment

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

can you add one test for the semantics content of the tabs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is already a test for that which was checking the value of the hard-coded string, now it is checking the localized result. :)

testWidgets('tabs announce semantics', (WidgetTester tester) async {

@xster
Copy link
Member

xster commented Apr 29, 2020

@Hixie CupertinoApp does introduce localization

@codecov
Copy link

codecov bot commented Apr 30, 2020

Codecov Report

Merging #55336 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #55336   +/-   ##
=======================================
  Coverage   70.59%   70.59%           
=======================================
  Files         204      204           
  Lines       22590    22590           
=======================================
  Hits        15947    15947           
  Misses       6643     6643           
Flag Coverage Δ
#flutter_tool 70.59% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0549ab2...4adb35a. Read the comment docs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) a: internationalization Supporting other languages or locales. (aka i18n) c: API break Backwards-incompatible API changes f: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels. team Infra upgrades, team productivity, code health, technical debt. See also team: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants