Skip to content

Conversation

@shihaohong
Copy link
Contributor

@shihaohong shihaohong commented Apr 2, 2020

Description

Uses the no locale as a synonym for the nb locale. This is done because some systems like Android use nb to identify Norwegian Bokmål. However, in other systems, like internally at Google, no is used instead. This adds some logic to the Material and Cupertino localizations generation code to have nb be synonymous with no in the event that an _nb.arb file is not provided.

I switched _nb.arb files back to to _no.arb files, since that is how it is named and pulled down from the Google translation console internally. The name was manually updated to _nb.arb ever since #17788, but keeping it as _no.arb keeps things consistent with how these files are pulled down.

Related Issues

Fixes #53036

Tests

I added the following tests:

A test to ensure that nb is currently being generated as a synonym for no. However, this test wouldn't hold up in the event that an _nb.arb file is introduced with different message strings than no. Any feedback here would be appreciated on how to better test this behavior.

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.

  • No, no existing tests failed, so this is not a breaking change.
  • Yes, this is a breaking change. If not, delete the remainder of this section.

@fluttergithubbot fluttergithubbot added a: internationalization Supporting other languages or locales. (aka i18n) f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. c: contributor-productivity Team-specific productivity, code health, technical debt. labels Apr 2, 2020
@shihaohong shihaohong changed the title [WIP] Use no locale as synonym for nb Use no locale as synonym for nb Apr 2, 2020
assert(supportedLanguagesConstant.isNotEmpty);
assert(supportedLanguagesDocMacro.isNotEmpty);

bool isNbSynonymOfNo = false;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe I can come up with a better variable name. It reads oddly when I say it out loud

Copy link
Contributor

Choose a reason for hiding this comment

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

The name seems OK (we're deep in a corner here) but a comment that referred to #53036 would be helpful

Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

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

This change, and the analysis in #53036, looks good. Only concern is about the changes in material_nb.arb when it was renamed (?) material_no.arb.

assert(supportedLanguagesConstant.isNotEmpty);
assert(supportedLanguagesDocMacro.isNotEmpty);

bool isNbSynonymOfNo = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

The name seems OK (we're deep in a corner here) but a comment that referred to #53036 would be helpful


// If scriptCodes for a language are defined, we expect a scriptCode to be
// defined for locales that contain a countryCode. The superclass becomes
// the script sublcass (e.g. `MaterialLocalizationZhHant`) and the generated
Copy link
Contributor

Choose a reason for hiding this comment

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

NICE

@@ -48,9 +49,7 @@
"reorderItemRight": "Flytt til høyre",
"expandedIconTapHint": "Skjul",
"collapsedIconTapHint": "Vis",
"remainingTextFieldCharacterCountZero": "TBD",
Copy link
Contributor

Choose a reason for hiding this comment

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

If this file was just renamed, why did the messages it contains change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My description was misleading, I actually ran the translation console script to regenerate the _no.arb files in case anything had changed. I'm not sure why this would be removed instead of saying 'TBD'. Do we want to keep it as-is, or re-introduce the original arb file setup?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, didn't realize we were updating translations. Removing this line is OK; just means that there's no special case for zero.

Copy link
Contributor Author

@shihaohong shihaohong Apr 3, 2020

Choose a reason for hiding this comment

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

Turns out there was a manual step to introduce the 'TBD' for any message that does not have a translation in google's translation console. I re-introduced the removed 'TBD' string.

With that, none of the strings are actually updated, the order is somehow different now though (alphabetical, which seems more correct).

expect(localizations.timerPickerMinute(10), '10');
});

// See https://github.com/flutter/flutter/issues/53036 for context on why
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add the standard "Regression test for ..." comment as well.

}, throwsAssertionError);
});

test('`nb` uses `no` as a synonym when `nb` arb file is not present', () async {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add the standard "Regression test for ..." comment here.


// See https://github.com/flutter/flutter/issues/53036 for context on why
// `no` is being used as a synonym for `nb`.
testWidgets('`nb` uses `no` as its synonym when `nb` arb file is not present', (WidgetTester tester) async {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add the standard "Regression test for ..." comment as well.

Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -48,9 +49,7 @@
"reorderItemRight": "Flytt til høyre",
"expandedIconTapHint": "Skjul",
"collapsedIconTapHint": "Vis",
"remainingTextFieldCharacterCountZero": "TBD",
Copy link
Contributor

Choose a reason for hiding this comment

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

I see, didn't realize we were updating translations. Removing this line is OK; just means that there's no special case for zero.

@shihaohong shihaohong added waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds waiting for tree to go green and removed waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds labels Apr 3, 2020
@fluttergithubbot fluttergithubbot merged commit 365528a into flutter:master Apr 3, 2020
@shihaohong shihaohong deleted the norwegian-translations branch April 3, 2020 19:03
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

a: internationalization Supporting other languages or locales. (aka i18n) c: contributor-productivity Team-specific productivity, code health, technical debt. customer: dream (g3) f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Norwegian code (no) translations are missing

4 participants