From 365528aad67160368a7049fbd549db3bd8868cdf Mon Sep 17 00:00:00 2001 From: Shi-Hao Hong Date: Fri, 3 Apr 2020 11:56:02 -0700 Subject: [PATCH] Use `no` locale as synonym for `nb` (#53880) --- .../bin/gen_date_localizations.dart | 8 + .../localization/bin/gen_localizations.dart | 30 +- .../{cupertino_nb.arb => cupertino_no.arb} | 0 .../generated_cupertino_localizations.dart | 280 ++++++------ .../l10n/generated_date_localizations.dart | 236 ++++++++++ .../generated_material_localizations.dart | 408 ++++++++++-------- .../l10n/{material_nb.arb => material_no.arb} | 4 +- .../test/cupertino/translations_test.dart | 27 ++ .../test/material/date_time_test.dart | 14 + .../test/material/translations_test.dart | 30 ++ 10 files changed, 723 insertions(+), 314 deletions(-) rename packages/flutter_localizations/lib/src/l10n/{cupertino_nb.arb => cupertino_no.arb} (100%) rename packages/flutter_localizations/lib/src/l10n/{material_nb.arb => material_no.arb} (96%) diff --git a/dev/tools/localization/bin/gen_date_localizations.dart b/dev/tools/localization/bin/gen_date_localizations.dart index ee6c05a4e3..6fe40f1877 100644 --- a/dev/tools/localization/bin/gen_date_localizations.dart +++ b/dev/tools/localization/bin/gen_date_localizations.dart @@ -172,6 +172,14 @@ Set _supportedLocales() { if (FileSystemEntity.isFileSync(filePath) && filenameRE.hasMatch(filePath)) supportedLocales.add(filenameRE.firstMatch(filePath)[1]); } + + // See https://github.com/flutter/flutter/issues/53036 for context on why + // 'no' is being used as a synonym for 'nb'. It only uses this synonym + // if 'nb' is not detected as a valid arb file. + if (supportedLocales.contains('no') && !supportedLocales.contains('nb')) { + supportedLocales.add('nb'); + } + return supportedLocales; } diff --git a/dev/tools/localization/bin/gen_localizations.dart b/dev/tools/localization/bin/gen_localizations.dart index 65fa621438..7820b6c0ea 100644 --- a/dev/tools/localization/bin/gen_localizations.dart +++ b/dev/tools/localization/bin/gen_localizations.dart @@ -76,6 +76,11 @@ String generateArbBasedLocalizationSubclasses({ assert(supportedLanguagesConstant.isNotEmpty); assert(supportedLanguagesDocMacro.isNotEmpty); + // See https://github.com/flutter/flutter/issues/53036 for context on why + // 'no' is being used as a synonym for 'nb'. It only uses this synonym + // if 'nb' is not detected as a valid arb file. + bool isNbSynonymOfNo = false; + final StringBuffer output = StringBuffer(); output.writeln(generateHeader('dart dev/tools/localization/bin/gen_localizations.dart --overwrite')); @@ -101,6 +106,12 @@ String generateArbBasedLocalizationSubclasses({ allResourceIdentifiers.addAll(localeToResources[locale].keys.toList()..sort()); } + if (languageToLocales['no'] != null && languageToLocales['nb'] == null) { + languageToLocales['nb'] ??= []; + languageToLocales['nb'].add(LocaleInfo.fromString('nb')); + isNbSynonymOfNo = true; + } + // We generate one class per supported language (e.g. // `MaterialLocalizationEn`). These implement everything that is needed by the // superclass (e.g. GlobalMaterialLocalizations). @@ -117,7 +128,7 @@ String generateArbBasedLocalizationSubclasses({ // 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 + // the script subclass (e.g. `MaterialLocalizationZhHant`) and the generated // subclass will also contain the script code (e.g. `MaterialLocalizationZhHantTW`). // When scriptCodes are not defined for languages that use scriptCodes to distinguish @@ -130,6 +141,22 @@ String generateArbBasedLocalizationSubclasses({ final LocaleInfo canonicalLocale = LocaleInfo.fromString('en'); for (final String languageName in languageCodes) { final LocaleInfo languageLocale = LocaleInfo.fromString(languageName); + + // See https://github.com/flutter/flutter/issues/53036 for context on why + // 'no' is being used as a synonym for 'nb'. It only uses this synonym + // if 'nb' is not detected as a valid arb file. + if (languageName == 'nb' && isNbSynonymOfNo) { + output.writeln(generateClassDeclaration( + languageLocale, + generatedClassPrefix, + '${generatedClassPrefix}No'), + ); + output.writeln(generateConstructor(languageLocale)); + output.writeln('}'); + supportedLocales.writeln('/// * `$languageName` - ${describeLocale(languageName)}, which, in this library, is a synonym of `no`'); + continue; + } + output.writeln(generateClassDeclaration(languageLocale, generatedClassPrefix, baseClass)); output.writeln(generateConstructor(languageLocale)); @@ -212,6 +239,7 @@ String generateArbBasedLocalizationSubclasses({ output.writeln('}'); } } + final String scriptCodeMessage = scriptCodeCount == 0 ? '' : ' and $scriptCodeCount script' + (scriptCodeCount == 1 ? '' : 's'); if (countryCodeCount == 0) { if (scriptCodeCount == 0) diff --git a/packages/flutter_localizations/lib/src/l10n/cupertino_nb.arb b/packages/flutter_localizations/lib/src/l10n/cupertino_no.arb similarity index 100% rename from packages/flutter_localizations/lib/src/l10n/cupertino_nb.arb rename to packages/flutter_localizations/lib/src/l10n/cupertino_no.arb diff --git a/packages/flutter_localizations/lib/src/l10n/generated_cupertino_localizations.dart b/packages/flutter_localizations/lib/src/l10n/generated_cupertino_localizations.dart index 83ace73c22..128276152c 100644 --- a/packages/flutter_localizations/lib/src/l10n/generated_cupertino_localizations.dart +++ b/packages/flutter_localizations/lib/src/l10n/generated_cupertino_localizations.dart @@ -8398,7 +8398,7 @@ class CupertinoLocalizationMy extends GlobalCupertinoLocalizations { } /// The translations for Norwegian Bokmål (`nb`). -class CupertinoLocalizationNb extends GlobalCupertinoLocalizations { +class CupertinoLocalizationNb extends CupertinoLocalizationNo { /// Create an instance of the translation bundle for Norwegian Bokmål. /// /// For details on the meaning of the arguments, see [GlobalCupertinoLocalizations]. @@ -8423,126 +8423,6 @@ class CupertinoLocalizationNb extends GlobalCupertinoLocalizations { singleDigitSecondFormat: singleDigitSecondFormat, decimalFormat: decimalFormat, ); - - @override - String get alertDialogLabel => 'Varsel'; - - @override - String get anteMeridiemAbbreviation => 'AM'; - - @override - String get copyButtonLabel => 'Kopiér'; - - @override - String get cutButtonLabel => 'Klipp ut'; - - @override - String get datePickerDateOrderString => 'dmy'; - - @override - String get datePickerDateTimeOrderString => 'date_time_dayPeriod'; - - @override - String get datePickerHourSemanticsLabelFew => null; - - @override - String get datePickerHourSemanticsLabelMany => null; - - @override - String get datePickerHourSemanticsLabelOne => '\$hour null-null'; - - @override - String get datePickerHourSemanticsLabelOther => '\$hour null-null'; - - @override - String get datePickerHourSemanticsLabelTwo => null; - - @override - String get datePickerHourSemanticsLabelZero => null; - - @override - String get datePickerMinuteSemanticsLabelFew => null; - - @override - String get datePickerMinuteSemanticsLabelMany => null; - - @override - String get datePickerMinuteSemanticsLabelOne => '1 minutt'; - - @override - String get datePickerMinuteSemanticsLabelOther => '\$minute minutter'; - - @override - String get datePickerMinuteSemanticsLabelTwo => null; - - @override - String get datePickerMinuteSemanticsLabelZero => null; - - @override - String get pasteButtonLabel => 'Lim inn'; - - @override - String get postMeridiemAbbreviation => 'PM'; - - @override - String get selectAllButtonLabel => 'Velg alle'; - - @override - String get timerPickerHourLabelFew => null; - - @override - String get timerPickerHourLabelMany => null; - - @override - String get timerPickerHourLabelOne => 'time'; - - @override - String get timerPickerHourLabelOther => 'timer'; - - @override - String get timerPickerHourLabelTwo => null; - - @override - String get timerPickerHourLabelZero => null; - - @override - String get timerPickerMinuteLabelFew => null; - - @override - String get timerPickerMinuteLabelMany => null; - - @override - String get timerPickerMinuteLabelOne => 'min.'; - - @override - String get timerPickerMinuteLabelOther => 'min.'; - - @override - String get timerPickerMinuteLabelTwo => null; - - @override - String get timerPickerMinuteLabelZero => null; - - @override - String get timerPickerSecondLabelFew => null; - - @override - String get timerPickerSecondLabelMany => null; - - @override - String get timerPickerSecondLabelOne => 'sek.'; - - @override - String get timerPickerSecondLabelOther => 'sek.'; - - @override - String get timerPickerSecondLabelTwo => null; - - @override - String get timerPickerSecondLabelZero => null; - - @override - String get todayLabel => 'I dag'; } /// The translations for Nepali (`ne`). @@ -8841,6 +8721,154 @@ class CupertinoLocalizationNl extends GlobalCupertinoLocalizations { String get todayLabel => 'Vandaag'; } +/// The translations for Norwegian (`no`). +class CupertinoLocalizationNo extends GlobalCupertinoLocalizations { + /// Create an instance of the translation bundle for Norwegian. + /// + /// For details on the meaning of the arguments, see [GlobalCupertinoLocalizations]. + const CupertinoLocalizationNo({ + String localeName = 'no', + @required intl.DateFormat fullYearFormat, + @required intl.DateFormat dayFormat, + @required intl.DateFormat mediumDateFormat, + @required intl.DateFormat singleDigitHourFormat, + @required intl.DateFormat singleDigitMinuteFormat, + @required intl.DateFormat doubleDigitMinuteFormat, + @required intl.DateFormat singleDigitSecondFormat, + @required intl.NumberFormat decimalFormat, + }) : super( + localeName: localeName, + fullYearFormat: fullYearFormat, + dayFormat: dayFormat, + mediumDateFormat: mediumDateFormat, + singleDigitHourFormat: singleDigitHourFormat, + singleDigitMinuteFormat: singleDigitMinuteFormat, + doubleDigitMinuteFormat: doubleDigitMinuteFormat, + singleDigitSecondFormat: singleDigitSecondFormat, + decimalFormat: decimalFormat, + ); + + @override + String get alertDialogLabel => 'Varsel'; + + @override + String get anteMeridiemAbbreviation => 'AM'; + + @override + String get copyButtonLabel => 'Kopiér'; + + @override + String get cutButtonLabel => 'Klipp ut'; + + @override + String get datePickerDateOrderString => 'dmy'; + + @override + String get datePickerDateTimeOrderString => 'date_time_dayPeriod'; + + @override + String get datePickerHourSemanticsLabelFew => null; + + @override + String get datePickerHourSemanticsLabelMany => null; + + @override + String get datePickerHourSemanticsLabelOne => '\$hour null-null'; + + @override + String get datePickerHourSemanticsLabelOther => '\$hour null-null'; + + @override + String get datePickerHourSemanticsLabelTwo => null; + + @override + String get datePickerHourSemanticsLabelZero => null; + + @override + String get datePickerMinuteSemanticsLabelFew => null; + + @override + String get datePickerMinuteSemanticsLabelMany => null; + + @override + String get datePickerMinuteSemanticsLabelOne => '1 minutt'; + + @override + String get datePickerMinuteSemanticsLabelOther => '\$minute minutter'; + + @override + String get datePickerMinuteSemanticsLabelTwo => null; + + @override + String get datePickerMinuteSemanticsLabelZero => null; + + @override + String get pasteButtonLabel => 'Lim inn'; + + @override + String get postMeridiemAbbreviation => 'PM'; + + @override + String get selectAllButtonLabel => 'Velg alle'; + + @override + String get timerPickerHourLabelFew => null; + + @override + String get timerPickerHourLabelMany => null; + + @override + String get timerPickerHourLabelOne => 'time'; + + @override + String get timerPickerHourLabelOther => 'timer'; + + @override + String get timerPickerHourLabelTwo => null; + + @override + String get timerPickerHourLabelZero => null; + + @override + String get timerPickerMinuteLabelFew => null; + + @override + String get timerPickerMinuteLabelMany => null; + + @override + String get timerPickerMinuteLabelOne => 'min.'; + + @override + String get timerPickerMinuteLabelOther => 'min.'; + + @override + String get timerPickerMinuteLabelTwo => null; + + @override + String get timerPickerMinuteLabelZero => null; + + @override + String get timerPickerSecondLabelFew => null; + + @override + String get timerPickerSecondLabelMany => null; + + @override + String get timerPickerSecondLabelOne => 'sek.'; + + @override + String get timerPickerSecondLabelOther => 'sek.'; + + @override + String get timerPickerSecondLabelTwo => null; + + @override + String get timerPickerSecondLabelZero => null; + + @override + String get todayLabel => 'I dag'; +} + /// The translations for Oriya (`or`). class CupertinoLocalizationOr extends GlobalCupertinoLocalizations { /// Create an instance of the translation bundle for Oriya. @@ -12794,6 +12822,7 @@ final Set kCupertinoSupportedLanguages = HashSet.from(const kCupertinoSupportedLanguages = HashSet.from(const dateSymbols = { '{1} {0}', ], }, + 'no': { + 'NAME': 'no', + 'ERAS': [ + 'f.Kr.', + 'e.Kr.', + ], + 'ERANAMES': [ + 'før Kristus', + 'etter Kristus', + ], + 'NARROWMONTHS': [ + 'J', + 'F', + 'M', + 'A', + 'M', + 'J', + 'J', + 'A', + 'S', + 'O', + 'N', + 'D', + ], + 'STANDALONENARROWMONTHS': [ + 'J', + 'F', + 'M', + 'A', + 'M', + 'J', + 'J', + 'A', + 'S', + 'O', + 'N', + 'D', + ], + 'MONTHS': [ + 'januar', + 'februar', + 'mars', + 'april', + 'mai', + 'juni', + 'juli', + 'august', + 'september', + 'oktober', + 'november', + 'desember', + ], + 'STANDALONEMONTHS': [ + 'januar', + 'februar', + 'mars', + 'april', + 'mai', + 'juni', + 'juli', + 'august', + 'september', + 'oktober', + 'november', + 'desember', + ], + 'SHORTMONTHS': [ + 'jan.', + 'feb.', + 'mar.', + 'apr.', + 'mai', + 'jun.', + 'jul.', + 'aug.', + 'sep.', + 'okt.', + 'nov.', + 'des.', + ], + 'STANDALONESHORTMONTHS': [ + 'jan', + 'feb', + 'mar', + 'apr', + 'mai', + 'jun', + 'jul', + 'aug', + 'sep', + 'okt', + 'nov', + 'des', + ], + 'WEEKDAYS': [ + 'søndag', + 'mandag', + 'tirsdag', + 'onsdag', + 'torsdag', + 'fredag', + 'lørdag', + ], + 'STANDALONEWEEKDAYS': [ + 'søndag', + 'mandag', + 'tirsdag', + 'onsdag', + 'torsdag', + 'fredag', + 'lørdag', + ], + 'SHORTWEEKDAYS': [ + 'søn.', + 'man.', + 'tir.', + 'ons.', + 'tor.', + 'fre.', + 'lør.', + ], + 'STANDALONESHORTWEEKDAYS': [ + 'søn.', + 'man.', + 'tir.', + 'ons.', + 'tor.', + 'fre.', + 'lør.', + ], + 'NARROWWEEKDAYS': [ + 'S', + 'M', + 'T', + 'O', + 'T', + 'F', + 'L', + ], + 'STANDALONENARROWWEEKDAYS': [ + 'S', + 'M', + 'T', + 'O', + 'T', + 'F', + 'L', + ], + 'SHORTQUARTERS': [ + 'K1', + 'K2', + 'K3', + 'K4', + ], + 'QUARTERS': [ + '1. kvartal', + '2. kvartal', + '3. kvartal', + '4. kvartal', + ], + 'AMPMS': [ + 'a.m.', + 'p.m.', + ], + 'DATEFORMATS': [ + 'EEEE d. MMMM y', + 'd. MMMM y', + 'd. MMM y', + 'dd.MM.y', + ], + 'TIMEFORMATS': [ + 'HH:mm:ss zzzz', + 'HH:mm:ss z', + 'HH:mm:ss', + 'HH:mm', + ], + 'AVAILABLEFORMATS': null, + 'FIRSTDAYOFWEEK': 0, + 'WEEKENDRANGE': [ + 5, + 6, + ], + 'FIRSTWEEKCUTOFFDAY': 3, + 'DATETIMEFORMATS': [ + '{1} {0}', + '{1} \'kl\'. {0}', + '{1}, {0}', + '{1}, {0}', + ], + }, 'or': { 'NAME': 'or', 'ERAS': [ @@ -20400,6 +20590,52 @@ const Map> datePatterns = 'zzzz': 'zzzz', 'ZZZZ': 'ZZZZ', }, + 'no': { + 'd': 'd.', + 'E': 'ccc', + 'EEEE': 'cccc', + 'LLL': 'LLL', + 'LLLL': 'LLLL', + 'M': 'L.', + 'Md': 'd.M.', + 'MEd': 'EEE d.M.', + 'MMM': 'LLL', + 'MMMd': 'd. MMM', + 'MMMEd': 'EEE d. MMM', + 'MMMM': 'LLLL', + 'MMMMd': 'd. MMMM', + 'MMMMEEEEd': 'EEEE d. MMMM', + 'QQQ': 'QQQ', + 'QQQQ': 'QQQQ', + 'y': 'y', + 'yM': 'M.y', + 'yMd': 'd.M.y', + 'yMEd': 'EEE d.MM.y', + 'yMMM': 'MMM y', + 'yMMMd': 'd. MMM y', + 'yMMMEd': 'EEE d. MMM y', + 'yMMMM': 'MMMM y', + 'yMMMMd': 'd. MMMM y', + 'yMMMMEEEEd': 'EEEE d. MMMM y', + 'yQQQ': 'QQQ y', + 'yQQQQ': 'QQQQ y', + 'H': 'HH', + 'Hm': 'HH:mm', + 'Hms': 'HH:mm:ss', + 'j': 'HH', + 'jm': 'HH:mm', + 'jms': 'HH:mm:ss', + 'jmv': 'HH:mm v', + 'jmz': 'HH:mm z', + 'jz': 'HH z', + 'm': 'm', + 'ms': 'mm:ss', + 's': 's', + 'v': 'v', + 'z': 'z', + 'zzzz': 'zzzz', + 'ZZZZ': 'ZZZZ', + }, 'or': { 'd': 'd', 'E': 'ccc', diff --git a/packages/flutter_localizations/lib/src/l10n/generated_material_localizations.dart b/packages/flutter_localizations/lib/src/l10n/generated_material_localizations.dart index 00bf9629a8..0c79572373 100644 --- a/packages/flutter_localizations/lib/src/l10n/generated_material_localizations.dart +++ b/packages/flutter_localizations/lib/src/l10n/generated_material_localizations.dart @@ -12631,7 +12631,7 @@ class MaterialLocalizationMy extends GlobalMaterialLocalizations { } /// The translations for Norwegian Bokmål (`nb`). -class MaterialLocalizationNb extends GlobalMaterialLocalizations { +class MaterialLocalizationNb extends MaterialLocalizationNo { /// Create an instance of the translation bundle for Norwegian Bokmål. /// /// For details on the meaning of the arguments, see [GlobalMaterialLocalizations]. @@ -12658,189 +12658,6 @@ class MaterialLocalizationNb extends GlobalMaterialLocalizations { decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat, ); - - @override - String get aboutListTileTitleRaw => 'Om \$applicationName'; - - @override - String get alertDialogLabel => 'Varsel'; - - @override - String get anteMeridiemAbbreviation => 'AM'; - - @override - String get backButtonTooltip => 'Tilbake'; - - @override - String get cancelButtonLabel => 'AVBRYT'; - - @override - String get closeButtonLabel => 'LUKK'; - - @override - String get closeButtonTooltip => 'Lukk'; - - @override - String get collapsedIconTapHint => 'Vis'; - - @override - String get continueButtonLabel => 'FORTSETT'; - - @override - String get copyButtonLabel => 'KOPIÉR'; - - @override - String get cutButtonLabel => 'KLIPP UT'; - - @override - String get deleteButtonTooltip => 'Slett'; - - @override - String get dialogLabel => 'Dialogboks'; - - @override - String get drawerLabel => 'Navigasjonsmeny'; - - @override - String get expandedIconTapHint => 'Skjul'; - - @override - String get hideAccountsLabel => 'Skjul kontoer'; - - @override - String get licensesPageTitle => 'Lisenser'; - - @override - String get modalBarrierDismissLabel => 'Avvis'; - - @override - String get moreButtonTooltip => 'Mer'; - - @override - String get nextMonthTooltip => 'Neste måned'; - - @override - String get nextPageTooltip => 'Neste side'; - - @override - String get okButtonLabel => 'OK'; - - @override - String get openAppDrawerTooltip => 'Åpne navigasjonsmenyen'; - - @override - String get pageRowsInfoTitleRaw => '\$firstRow–\$lastRow av \$rowCount'; - - @override - String get pageRowsInfoTitleApproximateRaw => '\$firstRow–\$lastRow av omtrent \$rowCount'; - - @override - String get pasteButtonLabel => 'LIM INN'; - - @override - String get popupMenuLabel => 'Forgrunnsmeny'; - - @override - String get postMeridiemAbbreviation => 'PM'; - - @override - String get previousMonthTooltip => 'Forrige måned'; - - @override - String get previousPageTooltip => 'Forrige side'; - - @override - String get refreshIndicatorSemanticLabel => 'Laster inn på nytt'; - - @override - String get remainingTextFieldCharacterCountFew => null; - - @override - String get remainingTextFieldCharacterCountMany => null; - - @override - String get remainingTextFieldCharacterCountOne => '1 tegn gjenstår'; - - @override - String get remainingTextFieldCharacterCountOther => '\$remainingCount tegn gjenstår'; - - @override - String get remainingTextFieldCharacterCountTwo => null; - - @override - String get remainingTextFieldCharacterCountZero => 'TBD'; - - @override - String get reorderItemDown => 'Flytt ned'; - - @override - String get reorderItemLeft => 'Flytt til venstre'; - - @override - String get reorderItemRight => 'Flytt til høyre'; - - @override - String get reorderItemToEnd => 'Flytt til slutten'; - - @override - String get reorderItemToStart => 'Flytt til starten'; - - @override - String get reorderItemUp => 'Flytt opp'; - - @override - String get rowsPerPageTitle => 'Rader per side:'; - - @override - ScriptCategory get scriptCategory => ScriptCategory.englishLike; - - @override - String get searchFieldLabel => 'Søk'; - - @override - String get selectAllButtonLabel => 'VELG ALLE'; - - @override - String get selectedRowCountTitleFew => null; - - @override - String get selectedRowCountTitleMany => null; - - @override - String get selectedRowCountTitleOne => '1 element er valgt'; - - @override - String get selectedRowCountTitleOther => '\$selectedRowCount elementer er valgt'; - - @override - String get selectedRowCountTitleTwo => null; - - @override - String get selectedRowCountTitleZero => null; - - @override - String get showAccountsLabel => 'Vis kontoer'; - - @override - String get showMenuTooltip => 'Vis meny'; - - @override - String get signedInLabel => 'Pålogget'; - - @override - String get tabLabelRaw => 'Fane \$tabIndex av \$tabCount'; - - @override - TimeOfDayFormat get timeOfDayFormatRaw => TimeOfDayFormat.HH_colon_mm; - - @override - String get timePickerHourModeAnnouncement => 'Angi timer'; - - @override - String get timePickerMinuteModeAnnouncement => 'Angi minutter'; - - @override - String get viewLicensesButtonLabel => 'SE LISENSER'; } /// The translations for Nepali (`ne`). @@ -13269,6 +13086,219 @@ class MaterialLocalizationNl extends GlobalMaterialLocalizations { String get viewLicensesButtonLabel => 'LICENTIES BEKIJKEN'; } +/// The translations for Norwegian (`no`). +class MaterialLocalizationNo extends GlobalMaterialLocalizations { + /// Create an instance of the translation bundle for Norwegian. + /// + /// For details on the meaning of the arguments, see [GlobalMaterialLocalizations]. + const MaterialLocalizationNo({ + String localeName = 'no', + @required intl.DateFormat fullYearFormat, + @required intl.DateFormat compactDateFormat, + @required intl.DateFormat shortDateFormat, + @required intl.DateFormat mediumDateFormat, + @required intl.DateFormat longDateFormat, + @required intl.DateFormat yearMonthFormat, + @required intl.DateFormat shortMonthDayFormat, + @required intl.NumberFormat decimalFormat, + @required intl.NumberFormat twoDigitZeroPaddedFormat, + }) : super( + localeName: localeName, + fullYearFormat: fullYearFormat, + compactDateFormat: compactDateFormat, + shortDateFormat: shortDateFormat, + mediumDateFormat: mediumDateFormat, + longDateFormat: longDateFormat, + yearMonthFormat: yearMonthFormat, + shortMonthDayFormat: shortMonthDayFormat, + decimalFormat: decimalFormat, + twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat, + ); + + @override + String get aboutListTileTitleRaw => 'Om \$applicationName'; + + @override + String get alertDialogLabel => 'Varsel'; + + @override + String get anteMeridiemAbbreviation => 'AM'; + + @override + String get backButtonTooltip => 'Tilbake'; + + @override + String get cancelButtonLabel => 'AVBRYT'; + + @override + String get closeButtonLabel => 'LUKK'; + + @override + String get closeButtonTooltip => 'Lukk'; + + @override + String get collapsedIconTapHint => 'Vis'; + + @override + String get continueButtonLabel => 'FORTSETT'; + + @override + String get copyButtonLabel => 'KOPIÉR'; + + @override + String get cutButtonLabel => 'KLIPP UT'; + + @override + String get deleteButtonTooltip => 'Slett'; + + @override + String get dialogLabel => 'Dialogboks'; + + @override + String get drawerLabel => 'Navigasjonsmeny'; + + @override + String get expandedIconTapHint => 'Skjul'; + + @override + String get hideAccountsLabel => 'Skjul kontoer'; + + @override + String get licensesPageTitle => 'Lisenser'; + + @override + String get modalBarrierDismissLabel => 'Avvis'; + + @override + String get moreButtonTooltip => 'Mer'; + + @override + String get nextMonthTooltip => 'Neste måned'; + + @override + String get nextPageTooltip => 'Neste side'; + + @override + String get okButtonLabel => 'OK'; + + @override + String get openAppDrawerTooltip => 'Åpne navigasjonsmenyen'; + + @override + String get pageRowsInfoTitleRaw => '\$firstRow–\$lastRow av \$rowCount'; + + @override + String get pageRowsInfoTitleApproximateRaw => '\$firstRow–\$lastRow av omtrent \$rowCount'; + + @override + String get pasteButtonLabel => 'LIM INN'; + + @override + String get popupMenuLabel => 'Forgrunnsmeny'; + + @override + String get postMeridiemAbbreviation => 'PM'; + + @override + String get previousMonthTooltip => 'Forrige måned'; + + @override + String get previousPageTooltip => 'Forrige side'; + + @override + String get refreshIndicatorSemanticLabel => 'Laster inn på nytt'; + + @override + String get remainingTextFieldCharacterCountFew => null; + + @override + String get remainingTextFieldCharacterCountMany => null; + + @override + String get remainingTextFieldCharacterCountOne => '1 tegn gjenstår'; + + @override + String get remainingTextFieldCharacterCountOther => '\$remainingCount tegn gjenstår'; + + @override + String get remainingTextFieldCharacterCountTwo => null; + + @override + String get remainingTextFieldCharacterCountZero => 'TBD'; + + @override + String get reorderItemDown => 'Flytt ned'; + + @override + String get reorderItemLeft => 'Flytt til venstre'; + + @override + String get reorderItemRight => 'Flytt til høyre'; + + @override + String get reorderItemToEnd => 'Flytt til slutten'; + + @override + String get reorderItemToStart => 'Flytt til starten'; + + @override + String get reorderItemUp => 'Flytt opp'; + + @override + String get rowsPerPageTitle => 'Rader per side:'; + + @override + ScriptCategory get scriptCategory => ScriptCategory.englishLike; + + @override + String get searchFieldLabel => 'Søk'; + + @override + String get selectAllButtonLabel => 'VELG ALLE'; + + @override + String get selectedRowCountTitleFew => null; + + @override + String get selectedRowCountTitleMany => null; + + @override + String get selectedRowCountTitleOne => '1 element er valgt'; + + @override + String get selectedRowCountTitleOther => '\$selectedRowCount elementer er valgt'; + + @override + String get selectedRowCountTitleTwo => null; + + @override + String get selectedRowCountTitleZero => null; + + @override + String get showAccountsLabel => 'Vis kontoer'; + + @override + String get showMenuTooltip => 'Vis meny'; + + @override + String get signedInLabel => 'Pålogget'; + + @override + String get tabLabelRaw => 'Fane \$tabIndex av \$tabCount'; + + @override + TimeOfDayFormat get timeOfDayFormatRaw => TimeOfDayFormat.HH_colon_mm; + + @override + String get timePickerHourModeAnnouncement => 'Angi timer'; + + @override + String get timePickerMinuteModeAnnouncement => 'Angi minutter'; + + @override + String get viewLicensesButtonLabel => 'SE LISENSER'; +} + /// The translations for Oriya (`or`). class MaterialLocalizationOr extends GlobalMaterialLocalizations { /// Create an instance of the translation bundle for Oriya. @@ -19258,6 +19288,7 @@ final Set kMaterialSupportedLanguages = HashSet.from(const kMaterialSupportedLanguages = HashSet.from(const ()); + + final String pasteButtonLabelNo = localizations.pasteButtonLabel; + final String copyButtonLabelNo = localizations.copyButtonLabel; + final String cutButtonLabelNo = localizations.cutButtonLabel; + + locale = const Locale.fromSubtags(languageCode: 'nb', scriptCode: null, countryCode: null); + expect(GlobalCupertinoLocalizations.delegate.isSupported(locale), isTrue); + localizations = await GlobalCupertinoLocalizations.delegate.load(locale); + expect(localizations, isA()); + expect(localizations.pasteButtonLabel, pasteButtonLabelNo); + expect(localizations.copyButtonLabel, copyButtonLabelNo); + expect(localizations.cutButtonLabel, cutButtonLabelNo); + } + }); } diff --git a/packages/flutter_localizations/test/material/date_time_test.dart b/packages/flutter_localizations/test/material/date_time_test.dart index 0b7960630a..917473e191 100644 --- a/packages/flutter_localizations/test/material/date_time_test.dart +++ b/packages/flutter_localizations/test/material/date_time_test.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'dart:async'; +import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; @@ -28,6 +29,19 @@ void main() { }, throwsAssertionError); }); + // Regression test for https://github.com/flutter/flutter/issues/53036. + test('`nb` uses `no` as a synonym when `nb` arb file is not present', () async { + final File nbMaterialArbFile = File('lib/src/l10n/material_nb.arb'); + final File noMaterialArbFile = File('lib/src/l10n/material_no.arb'); + + // No need to run test if `nb` arb file exists or if `no` arb file does not exist. + if (noMaterialArbFile.existsSync() && !nbMaterialArbFile.existsSync()) { + final GlobalMaterialLocalizations localizations = await GlobalMaterialLocalizations.delegate + .load(const Locale('nb')) as GlobalMaterialLocalizations; + expect(localizations.formatMediumDate(DateTime(2020, 4, 3)), 'fre. 3. apr.'); + } + }); + group('formatHour', () { Future formatHour(WidgetTester tester, Locale locale, TimeOfDay timeOfDay) async { final Completer completer = Completer(); diff --git a/packages/flutter_localizations/test/material/translations_test.dart b/packages/flutter_localizations/test/material/translations_test.dart index 1bb5c635e1..b6cc3a2cdc 100644 --- a/packages/flutter_localizations/test/material/translations_test.dart +++ b/packages/flutter_localizations/test/material/translations_test.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -462,4 +464,32 @@ void main() { expect(localizations.closeButtonLabel, '關閉'); expect(localizations.okButtonLabel, '確定'); }); + + // Regression test for https://github.com/flutter/flutter/issues/53036. + testWidgets('`nb` uses `no` as its synonym when `nb` arb file is not present', (WidgetTester tester) async { + final File nbMaterialArbFile = File('lib/src/l10n/material_nb.arb'); + final File noMaterialArbFile = File('lib/src/l10n/material_no.arb'); + + // No need to run test if `nb` arb file exists or if `no` arb file does not exist. + if (noMaterialArbFile.existsSync() && !nbMaterialArbFile.existsSync()) { + Locale locale = const Locale.fromSubtags(languageCode: 'no', scriptCode: null, countryCode: null); + expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); + MaterialLocalizations localizations = await GlobalMaterialLocalizations.delegate.load(locale); + expect(localizations, isA()); + + final String alertDialogLabelNo = localizations.alertDialogLabel; + final String anteMeridiemAbbreviationNo = localizations.anteMeridiemAbbreviation; + final String closeButtonLabelNo = localizations.closeButtonLabel; + final String okButtonLabelNo = localizations.okButtonLabel; + + locale = const Locale.fromSubtags(languageCode: 'nb', scriptCode: null, countryCode: null); + expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); + localizations = await GlobalMaterialLocalizations.delegate.load(locale); + expect(localizations, isA()); + expect(localizations.alertDialogLabel, alertDialogLabelNo); + expect(localizations.anteMeridiemAbbreviation, anteMeridiemAbbreviationNo); + expect(localizations.closeButtonLabel, closeButtonLabelNo); + expect(localizations.okButtonLabel, okButtonLabelNo); + } + }); }