Commit 96a70e89 authored by Hans Muller's avatar Hans Muller Committed by GitHub

More Localizations (#12021)

parent 3e21c070
...@@ -4,7 +4,14 @@ ...@@ -4,7 +4,14 @@
"closeButtonTooltip": "إغلا", "closeButtonTooltip": "إغلا",
"nextMonthTooltip": "الشهر القادم", "nextMonthTooltip": "الشهر القادم",
"previousMonthTooltip": "الشهر الماضى", "previousMonthTooltip": "الشهر الماضى",
"nextPageTooltip": "الصفحة التالية",
"previousPageTooltip": "الصفحة السابقة",
"showMenuTooltip": "قائمة العرض",
"licensesPageTitle": "التّراخيص", "licensesPageTitle": "التّراخيص",
"pageRowsInfoTitle": "$firstRow–$lastRow أو $rowCount",
"pageRowsInfoTitleApproximate": "$firstRow–$lastRow من حوالي $rowCount",
"rowsPerPageTitle": "الصفوف في الصفحة:",
"selectedRowCountTitleOther": "$selectedRowCount العناصر المحددة",
"cancelButtonLabel": "إلغاء", "cancelButtonLabel": "إلغاء",
"closeButtonLabel": "أغلاق", "closeButtonLabel": "أغلاق",
"continueButtonLabel": "استمر", "continueButtonLabel": "استمر",
......
...@@ -4,7 +4,17 @@ ...@@ -4,7 +4,17 @@
"closeButtonTooltip": "Schließen", "closeButtonTooltip": "Schließen",
"nextMonthTooltip": "Nächster Monat", "nextMonthTooltip": "Nächster Monat",
"previousMonthTooltip": "Vorheriger Monat", "previousMonthTooltip": "Vorheriger Monat",
"nextPageTooltip": "Nächste Seite",
"previousPageTooltip": "Vorherige Seite",
"showMenuTooltip": "Menü anzeigen",
"licensesPageTitle": "Lizenzen", "licensesPageTitle": "Lizenzen",
"pageRowsInfoTitle": "$firstRow–$lastRow von $rowCount",
"pageRowsInfoTitleApproximate": "$firstRow–$lastRow von etwa $rowCount",
"rowsPerPageTitle": "Zeilen pro Seite:",
"selectedRowCountTitleZero": "Keine Objekte ausgewählt",
"selectedRowCountTitleOne": "1 Objekt ausgewählt",
"selectedRowCountTitleOther": "$selectedRowCount Objekte ausgewählt",
"cancelButtonLabel": "ABBRECHEN", "cancelButtonLabel": "ABBRECHEN",
"closeButtonLabel": "SCHLIESSEN", "closeButtonLabel": "SCHLIESSEN",
"continueButtonLabel": "FORTSETZEN", "continueButtonLabel": "FORTSETZEN",
......
...@@ -29,12 +29,51 @@ ...@@ -29,12 +29,51 @@
"type": "text" "type": "text"
}, },
"nextPageTooltip": "Next page",
"@nextMonthTooltip": {
"description": "The tooltip for the [PaginatedDataTables]'s 'next page' button.",
"type": "text"
},
"previousPageTooltip": "Previous page",
"@previousMonthTooltip": {
"description": "The tooltip for the PaginatedDataTables's 'previous page' button.",
"type": "text"
},
"showMenuTooltip": "Show menu",
"@showMenuTooltip": {
"description": "The default PopupMenuButton tooltip",
"type": "text"
},
"licensesPageTitle": "Licenses", "licensesPageTitle": "Licenses",
"@licensesPageTitle": { "@licensesPageTitle": {
"description": "The title for the Flutter licenses page.", "description": "The title for the Flutter licenses page.",
"type": "text" "type": "text"
}, },
"pageRowsInfoTitle": "$firstRow–$lastRow of $rowCount",
"pageRowsInfoTitleApproximate": "$firstRow–$lastRow of about $rowCount",
"@pageRowInfoTitle": {
"description": "Title for the [PaginatedDataTable]'s row info footer",
"type": "text"
},
"rowsPerPageTitle": "Rows per page:",
"@rowsPerPageTitle": {
"description": "Title for the [PaginatedDataTable]'s 'rows per page' footer.",
"type": "text"
},
"selectedRowCountTitleZero": "No items selected",
"selectedRowCountTitleOne": "1 item selected",
"selectedRowCountTitleOther": "$selectedRowCount items selected",
"@selectedRowCountTitle": {
"description": "Title for the PaginatedDataTable's selected row count header",
"type": "text"
},
"cancelButtonLabel": "CANCEL", "cancelButtonLabel": "CANCEL",
"@cancelButtonLabel": { "@cancelButtonLabel": {
"description": "The label for cancel buttons and menu items.", "description": "The label for cancel buttons and menu items.",
......
...@@ -4,7 +4,16 @@ ...@@ -4,7 +4,16 @@
"closeButtonTooltip": "Cerrar", "closeButtonTooltip": "Cerrar",
"nextMonthTooltip": "Próximo mes", "nextMonthTooltip": "Próximo mes",
"previousMonthTooltip": "Mes anterior", "previousMonthTooltip": "Mes anterior",
"nextPageTooltip": "Siguiente página",
"previousPageTooltip": "Pagina anterior",
"showMenuTooltip": "Muestrame el menu",
"licensesPageTitle": "Licencias", "licensesPageTitle": "Licencias",
"pageRowsInfoTitle": "$firstRow–$lastRow de $rowCount",
"pageRowsInfoTitleApproximate": "$firstRow–$lastRow de aproximadamente $rowCount",
"rowsPerPageTitle": "Filas por página:",
"selectedRowCountTitleZero": "No se han seleccionado elementos",
"selectedRowCountTitleOne": "1 artículo seleccionado",
"selectedRowCountTitleOther": "$selectedRowCount artículos seleccionados",
"cancelButtonLabel": "CANCELAR", "cancelButtonLabel": "CANCELAR",
"closeButtonLabel": "CERRAR", "closeButtonLabel": "CERRAR",
"continueButtonLabel": "CONTINUAR", "continueButtonLabel": "CONTINUAR",
......
...@@ -4,7 +4,14 @@ ...@@ -4,7 +4,14 @@
"closeButtonTooltip": "بستن", "closeButtonTooltip": "بستن",
"nextMonthTooltip": "ماه بعد", "nextMonthTooltip": "ماه بعد",
"previousMonthTooltip": "ماه گذشته", "previousMonthTooltip": "ماه گذشته",
"nextPageTooltip": "صفحه بعد",
"previousPageTooltip": "صفحه قبلی",
"showMenuTooltip": "نمایش منو",
"licensesPageTitle": "مجوز", "licensesPageTitle": "مجوز",
"pageRowsInfoTitle": "$firstRow–$lastRow از $rowCount",
"pageRowsInfoTitleApproximate": "$firstRow–$lastRow از حدود $rowCount",
"rowsPerPageTitle": "ردیف در صفحه:",
"selectedRowCountTitleOther": "$selectedRowCount آیتم های انتخاب شده",
"cancelButtonLabel": "لغو", "cancelButtonLabel": "لغو",
"closeButtonLabel": "بستن", "closeButtonLabel": "بستن",
"continueButtonLabel": "ادامه دهید", "continueButtonLabel": "ادامه دهید",
......
...@@ -4,7 +4,16 @@ ...@@ -4,7 +4,16 @@
"closeButtonTooltip": "Fermer", "closeButtonTooltip": "Fermer",
"nextMonthTooltip": "Mois Suivant", "nextMonthTooltip": "Mois Suivant",
"previousMonthTooltip": "Mois précédent", "previousMonthTooltip": "Mois précédent",
"nextPageTooltip": "Page suivante",
"previousPageTooltip": "Page précédente",
"showMenuTooltip": "Afficher le menu",
"licensesPageTitle": "Licences", "licensesPageTitle": "Licences",
"pageRowsInfoTitle": "$firstRow–$lastRow de $rowCount",
"pageRowsInfoTitleApproximate": "$firstRow–$lastRow d'environ $rowCount",
"rowsPerPageTitle": "Lignes par page:",
"selectedRowCountTitleZero": "Aucun élément sélectionné",
"selectedRowCountTitleOne": "1 élément sélectionné",
"selectedRowCountTitleOther": "$selectedRowCount éléments sélectionnés",
"cancelButtonLabel": "ANNULER", "cancelButtonLabel": "ANNULER",
"closeButtonLabel": "FERMER", "closeButtonLabel": "FERMER",
"continueButtonLabel": "CONTINUER", "continueButtonLabel": "CONTINUER",
......
...@@ -4,7 +4,14 @@ ...@@ -4,7 +4,14 @@
"closeButtonTooltip": "סגור", "closeButtonTooltip": "סגור",
"nextMonthTooltip": "חודש הבא", "nextMonthTooltip": "חודש הבא",
"previousMonthTooltip": "חודש שעבר", "previousMonthTooltip": "חודש שעבר",
"nextPageTooltip": "עמוד הבא",
"previousPageTooltip": "עמוד קודם",
"showMenuTooltip": "הצג תפריט",
"licensesPageTitle": "רישיונות", "licensesPageTitle": "רישיונות",
"pageRowsInfoTitle": "$firstRow–$lastRow מתוך $rowCount",
"pageRowsInfoTitleApproximate": "$firstRow–$lastRow מתוך כ $rowCount",
"rowsPerPageTitle": "שורות לעמוד:",
"selectedRowCountTitleOther": "$selectedRowCount פריטים שנבחרו",
"cancelButtonLabel": "ביטול", "cancelButtonLabel": "ביטול",
"closeButtonLabel": "סגור", "closeButtonLabel": "סגור",
"continueButtonLabel": "לְהַמשִׁיך", "continueButtonLabel": "לְהַמשִׁיך",
......
...@@ -4,7 +4,14 @@ ...@@ -4,7 +4,14 @@
"closeButtonTooltip": "Chiudi", "closeButtonTooltip": "Chiudi",
"nextMonthTooltip": "Il prossimo mese", "nextMonthTooltip": "Il prossimo mese",
"previousMonthTooltip": "Il mese scorso", "previousMonthTooltip": "Il mese scorso",
"nextPageTooltip": "Pagina successiva",
"previousPageTooltip": "Pagina precedente",
"showMenuTooltip": "Mostra il menu",
"licensesPageTitle": "Licenze", "licensesPageTitle": "Licenze",
"pageRowsInfoTitle": "$firstRow–$lastRow di $rowCount",
"pageRowsInfoTitleApproximate": "$firstRow–$lastRow di circa $rowCount",
"rowsPerPageTitle": "Righe per pagina:",
"selectedRowCountTitleOther": "$selectedRowCount selezionati",
"cancelButtonLabel": "ANNULLA", "cancelButtonLabel": "ANNULLA",
"closeButtonLabel": "CHIUDI", "closeButtonLabel": "CHIUDI",
"continueButtonLabel": "CONTINUA", "continueButtonLabel": "CONTINUA",
......
...@@ -4,7 +4,14 @@ ...@@ -4,7 +4,14 @@
"closeButtonTooltip": "閉じる", "closeButtonTooltip": "閉じる",
"nextMonthTooltip": "前の月へ", "nextMonthTooltip": "前の月へ",
"previousMonthTooltip": "前の月へ", "previousMonthTooltip": "前の月へ",
"nextPageTooltip": "次のページ",
"previousPageTooltip": "前のページ",
"showMenuTooltip": "メニューを表示",
"licensesPageTitle": "ライセンス", "licensesPageTitle": "ライセンス",
"pageRowsInfoTitle": "$rowCount行中の$firstRow–$lastRow",
"pageRowsInfoTitleApproximate": "約$rowCount行中の$firstRow–$lastRow",
"rowsPerPageTitle": "1ページあたりの行数:",
"selectedRowCountTitleOther": "$selectedRowCount個のアイテムが選択されています",
"cancelButtonLabel": "キャンセル", "cancelButtonLabel": "キャンセル",
"closeButtonLabel": "閉じる", "closeButtonLabel": "閉じる",
"continueButtonLabel": "次へ", "continueButtonLabel": "次へ",
......
...@@ -4,7 +4,14 @@ ...@@ -4,7 +4,14 @@
"closeButtonTooltip": "بنده", "closeButtonTooltip": "بنده",
"nextMonthTooltip": "بله میاشت", "nextMonthTooltip": "بله میاشت",
"previousMonthTooltip": "تیره میاشت", "previousMonthTooltip": "تیره میاشت",
"nextPageTooltip": "بله پاڼه",
"previousPageTooltip": "مخکینی مخ",
"showMenuTooltip": "غورنۍ ښودل",
"licensesPageTitle": "جوازونه", "licensesPageTitle": "جوازونه",
"pageRowsInfoTitle": "$firstRow–$lastRow د $rowCount",
"pageRowsInfoTitleApproximate": "$firstRow–$lastRow څخه $rowCount د",
"rowsPerPageTitle": "د هرې پاڼې پاڼې:",
"selectedRowCountTitleOther": "$selectedRowCount توکي غوره شوي",
"cancelButtonLabel": "لغوه کول", "cancelButtonLabel": "لغوه کول",
"closeButtonLabel": "تړل", "closeButtonLabel": "تړل",
"continueButtonLabel": "منځپانګې", "continueButtonLabel": "منځپانګې",
......
...@@ -4,7 +4,14 @@ ...@@ -4,7 +4,14 @@
"closeButtonTooltip": "Fechar", "closeButtonTooltip": "Fechar",
"nextMonthTooltip": "Próximo mês", "nextMonthTooltip": "Próximo mês",
"previousMonthTooltip": "Mês anterior", "previousMonthTooltip": "Mês anterior",
"nextPageTooltip": "Próxima página",
"previousPageTooltip": "Página anterior",
"showMenuTooltip": "Mostrar menu",
"licensesPageTitle": "Licenças", "licensesPageTitle": "Licenças",
"pageRowsInfoTitle": "$firstRow–$lastRow de $rowCount",
"pageRowsInfoTitleApproximate": "$firstRow–$lastRow de cerca de $rowCount",
"rowsPerPageTitle": "Linhas por página:",
"selectedRowCountTitleOther": "$selectedRowCount selecionados",
"cancelButtonLabel": "CANCELAR", "cancelButtonLabel": "CANCELAR",
"closeButtonLabel": "FECHAR", "closeButtonLabel": "FECHAR",
"continueButtonLabel": "CONTINUAR", "continueButtonLabel": "CONTINUAR",
......
...@@ -4,7 +4,14 @@ ...@@ -4,7 +4,14 @@
"closeButtonTooltip": "Закрыть", "closeButtonTooltip": "Закрыть",
"nextMonthTooltip": "В следующем месяце", "nextMonthTooltip": "В следующем месяце",
"previousMonthTooltip": "Предыдущий месяц", "previousMonthTooltip": "Предыдущий месяц",
"nextPageTooltip": "Следущая страница",
"previousPageTooltip": "Предыдущая страница",
"showMenuTooltip": "Показать меню",
"pageRowsInfoTitle": "$firstRow–$lastRow из $rowCount",
"pageRowsInfoTitleApproximate": "$firstRow–$lastRow около $rowCount",
"rowsPerPageTitle": "Строки на страницу:",
"licensesPageTitle": "Лицензии", "licensesPageTitle": "Лицензии",
"selectedRowCountTitleOther": "$selectedRowCount выбранные предметы",
"cancelButtonLabel": "ОТМЕНА", "cancelButtonLabel": "ОТМЕНА",
"closeButtonLabel": "ЗАКРЫТЬ", "closeButtonLabel": "ЗАКРЫТЬ",
"continueButtonLabel": "ПРОДОЛЖАТЬ", "continueButtonLabel": "ПРОДОЛЖАТЬ",
......
...@@ -4,7 +4,14 @@ ...@@ -4,7 +4,14 @@
"closeButtonTooltip": "بند ڪريو", "closeButtonTooltip": "بند ڪريو",
"nextMonthTooltip": "ايندڙ مهيني", "nextMonthTooltip": "ايندڙ مهيني",
"previousMonthTooltip": "پويون مهينو", "previousMonthTooltip": "پويون مهينو",
"nextPageTooltip": "اڳيون پيج",
"previousPageTooltip": "پويون صفحو",
"showMenuTooltip": "ڏيکاريو",
"licensesPageTitle": "لائسنس", "licensesPageTitle": "لائسنس",
"pageRowsInfoTitle": "$firstRow–$lastRow جي $rowCount",
"pageRowsInfoTitleApproximate": "$firstRow–$lastRow کان $rowCount تقريبن",
"rowsPerPageTitle": "رني پاسي وارو صفحو",
"selectedRowCountTitleOther": "$selectedRowCount شيون چونڊيل",
"cancelButtonLabel": "منسوخ ڪيو", "cancelButtonLabel": "منسوخ ڪيو",
"closeButtonLabel": "بند ڪريو", "closeButtonLabel": "بند ڪريو",
"continueButtonLabel": "جاري رکو", "continueButtonLabel": "جاري رکو",
......
...@@ -4,7 +4,14 @@ ...@@ -4,7 +4,14 @@
"closeButtonTooltip": "بند کریں", "closeButtonTooltip": "بند کریں",
"nextMonthTooltip": "اگلا مھینہ", "nextMonthTooltip": "اگلا مھینہ",
"previousMonthTooltip": "پچھلا مھینہ", "previousMonthTooltip": "پچھلا مھینہ",
"nextPageTooltip": "اگلا صفحہ",
"previousPageTooltip": "سابقہ ​​صفحہ",
"showMenuTooltip": "مینو دکھائیں",
"licensesPageTitle": "لائسنس", "licensesPageTitle": "لائسنس",
"pageRowsInfoTitle": "$firstRow–$lastRow کے $rowCount",
"pageRowsInfoTitleApproximate": "$firstRow–$lastRow میں سے $rowCount تقریبا",
"rowsPerPageTitle": "رویوں فی صفحہ:",
"selectedRowCountTitleOther": "$selectedRowCount منتخب کردہ اشیاء",
"cancelButtonLabel": "منسوخ کریں", "cancelButtonLabel": "منسوخ کریں",
"closeButtonLabel": "بند کریں", "closeButtonLabel": "بند کریں",
"continueButtonLabel": "جاری رکھیں", "continueButtonLabel": "جاری رکھیں",
......
...@@ -4,7 +4,14 @@ ...@@ -4,7 +4,14 @@
"closeButtonTooltip": "关闭", "closeButtonTooltip": "关闭",
"nextMonthTooltip": "下一个月", "nextMonthTooltip": "下一个月",
"previousMonthTooltip": "上一个月", "previousMonthTooltip": "上一个月",
"nextPageTooltip": "下一页",
"previousPageTooltip": "上一页",
"showMenuTooltip": "显示菜单",
"licensesPageTitle": "许可证", "licensesPageTitle": "许可证",
"pageRowsInfoTitle": "$rowCount中的$firstRow-$lastRow",
"pageRowsInfoTitleApproximate": "约$rowCount中的$firstRow-$lastRow",
"rowsPerPageTitle": "每页行数:",
"selectedRowCountTitleOther": "$selectedRowCount行所选",
"cancelButtonLabel": "取消", "cancelButtonLabel": "取消",
"continueButtonLabel": "继续", "continueButtonLabel": "继续",
"closeButtonLabel": "关闭", "closeButtonLabel": "关闭",
......
...@@ -6,6 +6,7 @@ import 'dart:async'; ...@@ -6,6 +6,7 @@ import 'dart:async';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:intl/intl.dart';
import 'i18n/localizations.dart'; import 'i18n/localizations.dart';
...@@ -16,7 +17,7 @@ import 'i18n/localizations.dart'; ...@@ -16,7 +17,7 @@ import 'i18n/localizations.dart';
/// * [DefaultMaterialLocalizations], which implements this interface /// * [DefaultMaterialLocalizations], which implements this interface
/// and supports a variety of locales. /// and supports a variety of locales.
abstract class MaterialLocalizations { abstract class MaterialLocalizations {
/// The tooltip for the leading [AppBar] menu (aka 'hamburger') button /// The tooltip for the leading [AppBar] menu (aka 'hamburger') button.
String get openAppDrawerTooltip; String get openAppDrawerTooltip;
/// The [BackButton]'s tooltip. /// The [BackButton]'s tooltip.
...@@ -31,9 +32,27 @@ abstract class MaterialLocalizations { ...@@ -31,9 +32,27 @@ abstract class MaterialLocalizations {
/// The tooltip for the [MonthPicker]'s "previous month" button. /// The tooltip for the [MonthPicker]'s "previous month" button.
String get previousMonthTooltip; String get previousMonthTooltip;
/// The tooltip for the [PaginatedDataTables]'s "next page" button.
String get nextPageTooltip;
/// The tooltip for the [PaginatedDataTables]'s "previous page" button.
String get previousPageTooltip;
/// The default [PopupMenuButton] tooltip.
String get showMenuTooltip;
/// Title for the [LicensePage] widget. /// Title for the [LicensePage] widget.
String get licensesPageTitle; String get licensesPageTitle;
/// Title for the [PaginatedDataTable]'s row info footer.
String pageRowsInfoTitle(int firstRow, int lastRow, int rowCount, bool rowCountIsApproximate);
/// Title for the [PaginatedDataTable]'s "rows per page" footer.
String get rowsPerPageTitle;
/// Title for the PaginatedDataTable's selected row count header.
String selectedRowCountTitle(int selectedRowCount);
/// Label for "cancel" buttons and menu items. /// Label for "cancel" buttons and menu items.
String get cancelButtonLabel; String get cancelButtonLabel;
...@@ -87,7 +106,7 @@ class DefaultMaterialLocalizations implements MaterialLocalizations { ...@@ -87,7 +106,7 @@ class DefaultMaterialLocalizations implements MaterialLocalizations {
/// function, rather than constructing this class directly. /// function, rather than constructing this class directly.
DefaultMaterialLocalizations(this.locale) { DefaultMaterialLocalizations(this.locale) {
assert(locale != null); assert(locale != null);
_nameToValue = localizations[locale.toString()] _nameToValue = localizations[_localeName]
?? localizations[locale.languageCode] ?? localizations[locale.languageCode]
?? localizations['en'] ?? localizations['en']
?? <String, String>{}; ?? <String, String>{};
...@@ -99,50 +118,111 @@ class DefaultMaterialLocalizations implements MaterialLocalizations { ...@@ -99,50 +118,111 @@ class DefaultMaterialLocalizations implements MaterialLocalizations {
/// have been translated. /// have been translated.
final Locale locale; final Locale locale;
String get _localeName {
final String localeName = locale.countryCode.isEmpty ? locale.languageCode : locale.toString();
return Intl.canonicalizedLocale(localeName);
}
// TODO(hmuller): the rules for mapping from an integer value to
// "one" or "two" etc. are locale specific and an additional "few" category
// is needed. See http://cldr.unicode.org/index/cldr-spec/plural-rules
String _nameToPluralValue(int count, String key) {
String text;
if (count == 0)
text = _nameToValue['${key}Zero'];
else if (count == 1)
text = _nameToValue['${key}One'];
else if (count == 2)
text = _nameToValue['${key}Two'];
else if (count > 2)
text = _nameToValue['${key}Many'];
text ??= _nameToValue['${key}Other'];
assert(text != null);
return text;
}
String _formatInteger(int n) {
final String localeName = _localeName;
if (!NumberFormat.localeExists(localeName))
return n.toString();
return new NumberFormat.decimalPattern(localeName).format(n);
}
@override @override
String get openAppDrawerTooltip => _nameToValue["openAppDrawerTooltip"]; String get openAppDrawerTooltip => _nameToValue['openAppDrawerTooltip'];
@override @override
String get backButtonTooltip => _nameToValue["backButtonTooltip"]; String get backButtonTooltip => _nameToValue['backButtonTooltip'];
@override @override
String get closeButtonTooltip => _nameToValue["closeButtonTooltip"]; String get closeButtonTooltip => _nameToValue['closeButtonTooltip'];
@override @override
String get nextMonthTooltip => _nameToValue["nextMonthTooltip"]; String get nextMonthTooltip => _nameToValue['nextMonthTooltip'];
@override @override
String get previousMonthTooltip => _nameToValue["previousMonthTooltip"]; String get previousMonthTooltip => _nameToValue['previousMonthTooltip'];
@override @override
String get licensesPageTitle => _nameToValue["licensesPageTitle"]; String get nextPageTooltip => _nameToValue['nextPageTooltip'];
@override
String get previousPageTooltip => _nameToValue['previousPageTooltip'];
@override
String get showMenuTooltip => _nameToValue['showMenuTooltip'];
@override
String get licensesPageTitle => _nameToValue['licensesPageTitle'];
@override
String pageRowsInfoTitle(int firstRow, int lastRow, int rowCount, bool rowCountIsApproximate) {
String text = rowCountIsApproximate ? _nameToValue['pageRowsInfoTitleApproximate'] : null;
text ??= _nameToValue['pageRowsInfoTitle'];
assert(text != null, 'A $locale localization was not found for pageRowsInfoTitle or pageRowsInfoTitleApproximate');
// TODO(hansmuller): this could be more efficient.
return text
.replaceFirst(r'$firstRow', _formatInteger(firstRow))
.replaceFirst(r'$lastRow', _formatInteger(lastRow))
.replaceFirst(r'$rowCount', _formatInteger(rowCount));
}
@override
String get rowsPerPageTitle => _nameToValue['rowsPerPageTitle'];
@override
String selectedRowCountTitle(int selectedRowCount) {
return _nameToPluralValue(selectedRowCount, 'selectedRowCountTitle') // asserts on no match
.replaceFirst(r'$selectedRowCount', _formatInteger(selectedRowCount));
}
@override @override
String get cancelButtonLabel => _nameToValue["cancelButtonLabel"]; String get cancelButtonLabel => _nameToValue['cancelButtonLabel'];
@override @override
String get closeButtonLabel => _nameToValue["closeButtonLabel"]; String get closeButtonLabel => _nameToValue['closeButtonLabel'];
@override @override
String get continueButtonLabel => _nameToValue["continueButtonLabel"]; String get continueButtonLabel => _nameToValue['continueButtonLabel'];
@override @override
String get copyButtonLabel => _nameToValue["copyButtonLabel"]; String get copyButtonLabel => _nameToValue['copyButtonLabel'];
@override @override
String get cutButtonLabel => _nameToValue["cutButtonLabel"]; String get cutButtonLabel => _nameToValue['cutButtonLabel'];
@override @override
String get okButtonLabel => _nameToValue["okButtonLabel"]; String get okButtonLabel => _nameToValue['okButtonLabel'];
@override @override
String get pasteButtonLabel => _nameToValue["pasteButtonLabel"]; String get pasteButtonLabel => _nameToValue['pasteButtonLabel'];
@override @override
String get selectAllButtonLabel => _nameToValue["selectAllButtonLabel"]; String get selectAllButtonLabel => _nameToValue['selectAllButtonLabel'];
@override @override
String get viewLicensesButtonLabel => _nameToValue["viewLicensesButtonLabel"]; String get viewLicensesButtonLabel => _nameToValue['viewLicensesButtonLabel'];
/// Creates an object that provides localized resource values for the /// Creates an object that provides localized resource values for the
/// for the widgets of the material library. /// for the widgets of the material library.
......
...@@ -16,6 +16,7 @@ import 'data_table_source.dart'; ...@@ -16,6 +16,7 @@ import 'data_table_source.dart';
import 'dropdown.dart'; import 'dropdown.dart';
import 'icon_button.dart'; import 'icon_button.dart';
import 'icons.dart'; import 'icons.dart';
import 'material_localizations.dart';
import 'progress_indicator.dart'; import 'progress_indicator.dart';
import 'theme.dart'; import 'theme.dart';
...@@ -286,6 +287,7 @@ class PaginatedDataTableState extends State<PaginatedDataTable> { ...@@ -286,6 +287,7 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
// TODO(ianh): This whole build function doesn't handle RTL yet. // TODO(ianh): This whole build function doesn't handle RTL yet.
final ThemeData themeData = Theme.of(context); final ThemeData themeData = Theme.of(context);
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
// HEADER // HEADER
final List<Widget> headerWidgets = <Widget>[]; final List<Widget> headerWidgets = <Widget>[];
double startPadding = 24.0; double startPadding = 24.0;
...@@ -300,11 +302,10 @@ class PaginatedDataTableState extends State<PaginatedDataTable> { ...@@ -300,11 +302,10 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
// TODO(ianh): Better magic. See https://github.com/flutter/flutter/issues/4460 // TODO(ianh): Better magic. See https://github.com/flutter/flutter/issues/4460
startPadding = 12.0; startPadding = 12.0;
} }
} else if (_selectedRowCount == 1) {
// TODO(ianh): Real l10n.
headerWidgets.add(const Expanded(child: const Text('1 item selected')));
} else { } else {
headerWidgets.add(new Expanded(child: new Text('$_selectedRowCount items selected'))); headerWidgets.add(new Expanded(
child: new Text(localizations.selectedRowCountTitle(_selectedRowCount)),
));
} }
if (widget.actions != null) { if (widget.actions != null) {
headerWidgets.addAll( headerWidgets.addAll(
...@@ -332,7 +333,7 @@ class PaginatedDataTableState extends State<PaginatedDataTable> { ...@@ -332,7 +333,7 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
}) })
.toList(); .toList();
footerWidgets.addAll(<Widget>[ footerWidgets.addAll(<Widget>[
const Text('Rows per page:'), new Text(localizations.rowsPerPageTitle),
new DropdownButtonHideUnderline( new DropdownButtonHideUnderline(
child: new DropdownButton<int>( child: new DropdownButton<int>(
items: availableRowsPerPage, items: availableRowsPerPage,
...@@ -347,20 +348,25 @@ class PaginatedDataTableState extends State<PaginatedDataTable> { ...@@ -347,20 +348,25 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
footerWidgets.addAll(<Widget>[ footerWidgets.addAll(<Widget>[
new Container(width: 32.0), new Container(width: 32.0),
new Text( new Text(
'${_firstRowIndex + 1}\u2013${_firstRowIndex + widget.rowsPerPage} ${ _rowCountApproximate ? "of about" : "of" } $_rowCount' localizations.pageRowsInfoTitle(
_firstRowIndex + 1,
_firstRowIndex + widget.rowsPerPage,
_rowCount,
_rowCountApproximate
)
), ),
new Container(width: 32.0), new Container(width: 32.0),
new IconButton( new IconButton(
icon: const Icon(Icons.chevron_left), icon: const Icon(Icons.chevron_left),
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
tooltip: 'Previous page', tooltip: localizations.previousPageTooltip,
onPressed: _firstRowIndex <= 0 ? null : _handlePrevious onPressed: _firstRowIndex <= 0 ? null : _handlePrevious
), ),
new Container(width: 24.0), new Container(width: 24.0),
new IconButton( new IconButton(
icon: const Icon(Icons.chevron_right), icon: const Icon(Icons.chevron_right),
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
tooltip: 'Next page', tooltip: localizations.nextPageTooltip,
onPressed: (!_rowCountApproximate && (_firstRowIndex + widget.rowsPerPage >= _rowCount)) ? null : _handleNext onPressed: (!_rowCountApproximate && (_firstRowIndex + widget.rowsPerPage >= _rowCount)) ? null : _handleNext
), ),
new Container(width: 14.0), new Container(width: 14.0),
......
...@@ -14,6 +14,7 @@ import 'icons.dart'; ...@@ -14,6 +14,7 @@ import 'icons.dart';
import 'ink_well.dart'; import 'ink_well.dart';
import 'list_tile.dart'; import 'list_tile.dart';
import 'material.dart'; import 'material.dart';
import 'material_localizations.dart';
import 'theme.dart'; import 'theme.dart';
// Examples can assume: // Examples can assume:
...@@ -674,7 +675,7 @@ class PopupMenuButton<T> extends StatefulWidget { ...@@ -674,7 +675,7 @@ class PopupMenuButton<T> extends StatefulWidget {
@required this.itemBuilder, @required this.itemBuilder,
this.initialValue, this.initialValue,
this.onSelected, this.onSelected,
this.tooltip: 'Show menu', this.tooltip,
this.elevation: 8.0, this.elevation: 8.0,
this.padding: const EdgeInsets.all(8.0), this.padding: const EdgeInsets.all(8.0),
this.child, this.child,
...@@ -765,7 +766,7 @@ class _PopupMenuButtonState<T> extends State<PopupMenuButton<T>> { ...@@ -765,7 +766,7 @@ class _PopupMenuButtonState<T> extends State<PopupMenuButton<T>> {
: new IconButton( : new IconButton(
icon: widget.icon ?? _getIcon(Theme.of(context).platform), icon: widget.icon ?? _getIcon(Theme.of(context).platform),
padding: widget.padding, padding: widget.padding,
tooltip: widget.tooltip, tooltip: widget.tooltip ?? MaterialLocalizations.of(context).showMenuTooltip,
onPressed: showButtonMenu, onPressed: showButtonMenu,
); );
} }
......
...@@ -299,6 +299,21 @@ class _WidgetsAppState extends State<WidgetsApp> implements WidgetsBindingObserv ...@@ -299,6 +299,21 @@ class _WidgetsAppState extends State<WidgetsApp> implements WidgetsBindingObserv
Locale _locale; Locale _locale;
Locale _resolveLocale(Locale newLocale, Iterable<Locale> supportedLocales) { Locale _resolveLocale(Locale newLocale, Iterable<Locale> supportedLocales) {
// Android devices (Java really) report 3 deprecated language codes, see
// http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4140555
// and https://developer.android.com/reference/java/util/Locale.html
switch(newLocale.languageCode) {
case 'iw':
newLocale = new Locale('he', newLocale.countryCode); // Hebrew
break;
case 'ji':
newLocale = new Locale('yi', newLocale.countryCode); // Yiddish
break;
case 'in':
newLocale = new Locale('id', newLocale.countryCode); // Indonesian
break;
}
if (widget.localeResolutionCallback != null) { if (widget.localeResolutionCallback != null) {
final Locale locale = widget.localeResolutionCallback(newLocale, widget.supportedLocales); final Locale locale = widget.localeResolutionCallback(newLocale, widget.supportedLocales);
if (locale != null) if (locale != null)
......
...@@ -8,14 +8,15 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -8,14 +8,15 @@ import 'package:flutter_test/flutter_test.dart';
Widget buildFrame({ Widget buildFrame({
Locale locale, Locale locale,
WidgetBuilder buildContent, WidgetBuilder buildContent,
Iterable<Locale> supportedLocales: const <Locale>[
const Locale('en', 'US'),
const Locale('es', 'es'),
],
}) { }) {
return new MaterialApp( return new MaterialApp(
color: const Color(0xFFFFFFFF), color: const Color(0xFFFFFFFF),
locale: locale, locale: locale,
supportedLocales: const <Locale>[ supportedLocales: supportedLocales,
const Locale('en', 'US'),
const Locale('es', 'es'),
],
onGenerateRoute: (RouteSettings settings) { onGenerateRoute: (RouteSettings settings) {
return new MaterialPageRoute<Null>( return new MaterialPageRoute<Null>(
builder: (BuildContext context) { builder: (BuildContext context) {
...@@ -77,12 +78,17 @@ void main() { ...@@ -77,12 +78,17 @@ void main() {
for (String language in languages) { for (String language in languages) {
final Locale locale = new Locale(language, ''); final Locale locale = new Locale(language, '');
final MaterialLocalizations localizations = new DefaultMaterialLocalizations(locale); final MaterialLocalizations localizations = new DefaultMaterialLocalizations(locale);
expect(localizations.openAppDrawerTooltip, isNotNull); expect(localizations.openAppDrawerTooltip, isNotNull);
expect(localizations.backButtonTooltip, isNotNull); expect(localizations.backButtonTooltip, isNotNull);
expect(localizations.closeButtonTooltip, isNotNull); expect(localizations.closeButtonTooltip, isNotNull);
expect(localizations.nextMonthTooltip, isNotNull); expect(localizations.nextMonthTooltip, isNotNull);
expect(localizations.previousMonthTooltip, isNotNull); expect(localizations.previousMonthTooltip, isNotNull);
expect(localizations.nextPageTooltip, isNotNull);
expect(localizations.previousPageTooltip, isNotNull);
expect(localizations.showMenuTooltip, isNotNull);
expect(localizations.licensesPageTitle, isNotNull); expect(localizations.licensesPageTitle, isNotNull);
expect(localizations.rowsPerPageTitle, isNotNull);
expect(localizations.cancelButtonLabel, isNotNull); expect(localizations.cancelButtonLabel, isNotNull);
expect(localizations.closeButtonLabel, isNotNull); expect(localizations.closeButtonLabel, isNotNull);
expect(localizations.continueButtonLabel, isNotNull); expect(localizations.continueButtonLabel, isNotNull);
...@@ -92,6 +98,77 @@ void main() { ...@@ -92,6 +98,77 @@ void main() {
expect(localizations.pasteButtonLabel, isNotNull); expect(localizations.pasteButtonLabel, isNotNull);
expect(localizations.selectAllButtonLabel, isNotNull); expect(localizations.selectAllButtonLabel, isNotNull);
expect(localizations.viewLicensesButtonLabel, isNotNull); expect(localizations.viewLicensesButtonLabel, isNotNull);
expect(localizations.selectedRowCountTitle(0), isNotNull);
expect(localizations.selectedRowCountTitle(1), isNotNull);
expect(localizations.selectedRowCountTitle(2), isNotNull);
expect(localizations.selectedRowCountTitle(100), isNotNull);
expect(localizations.selectedRowCountTitle(0).contains(r'$selectedRowCount'), isFalse);
expect(localizations.selectedRowCountTitle(1).contains(r'$selectedRowCount'), isFalse);
expect(localizations.selectedRowCountTitle(2).contains(r'$selectedRowCount'), isFalse);
expect(localizations.selectedRowCountTitle(100).contains(r'$selectedRowCount'), isFalse);
expect(localizations.pageRowsInfoTitle(1, 10, 100, true), isNotNull);
expect(localizations.pageRowsInfoTitle(1, 10, 100, false), isNotNull);
expect(localizations.pageRowsInfoTitle(1, 10, 100, true).contains(r'$firstRow'), isFalse);
expect(localizations.pageRowsInfoTitle(1, 10, 100, true).contains(r'$lastRow'), isFalse);
expect(localizations.pageRowsInfoTitle(1, 10, 100, true).contains(r'$rowCount'), isFalse);
expect(localizations.pageRowsInfoTitle(1, 10, 100, false).contains(r'$firstRow'), isFalse);
expect(localizations.pageRowsInfoTitle(1, 10, 100, false).contains(r'$lastRow'), isFalse);
expect(localizations.pageRowsInfoTitle(1, 10, 100, false).contains(r'$rowCount'), isFalse);
} }
}); });
testWidgets('spot check selectedRowCount translations', (WidgetTester tester) async {
MaterialLocalizations localizations = new DefaultMaterialLocalizations(const Locale('en', ''));
expect(localizations.selectedRowCountTitle(0), 'No items selected');
expect(localizations.selectedRowCountTitle(1), '1 item selected');
expect(localizations.selectedRowCountTitle(2), '2 items selected');
expect(localizations.selectedRowCountTitle(123456789), '123,456,789 items selected');
localizations = new DefaultMaterialLocalizations(const Locale('es', ''));
expect(localizations.selectedRowCountTitle(0), 'No se han seleccionado elementos');
expect(localizations.selectedRowCountTitle(1), '1 artículo seleccionado');
expect(localizations.selectedRowCountTitle(2), '2 artículos seleccionados');
expect(localizations.selectedRowCountTitle(123456789), '123.456.789 artículos seleccionados');
});
testWidgets('deprecated Android/Java locales are modernized', (WidgetTester tester) async {
final Key textKey = new UniqueKey();
await tester.pumpWidget(
buildFrame(
supportedLocales: <Locale>[
const Locale('en', 'US'),
const Locale('he', 'IL'),
const Locale('yi', 'IL'),
const Locale('id', 'JV'),
],
buildContent: (BuildContext context) {
return new Text(
'${Localizations.localeOf(context)}',
key: textKey,
);
},
)
);
expect(tester.widget<Text>(find.byKey(textKey)).data, 'en_US');
// Hebrew was iw (ISO-639) is he (ISO-639-1)
await tester.binding.setLocale('iw', 'IL');
await tester.pump();
expect(tester.widget<Text>(find.byKey(textKey)).data, 'he_IL');
// Yiddish was ji (ISO-639) is yi (ISO-639-1)
await tester.binding.setLocale('ji', 'IL');
await tester.pump();
expect(tester.widget<Text>(find.byKey(textKey)).data, 'yi_IL');
// Indonesian was in (ISO-639) is id (ISO-639-1)
await tester.binding.setLocale('in', 'JV');
await tester.pump();
expect(tester.widget<Text>(find.byKey(textKey)).data, 'id_JV');
});
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment