Commit 60c4ff93 authored by Hans Muller's avatar Hans Muller Committed by GitHub

More localizations for Material (#11989)

parent ca7d2d23
......@@ -13,6 +13,7 @@ import 'debug.dart';
import 'dialog.dart';
import 'flat_button.dart';
import 'list_tile.dart';
import 'material_localizations.dart';
import 'page.dart';
import 'progress_indicator.dart';
import 'scaffold.dart';
......@@ -287,7 +288,7 @@ class AboutDialog extends StatelessWidget {
),
actions: <Widget>[
new FlatButton(
child: const Text('VIEW LICENSES'),
child: new Text(MaterialLocalizations.of(context).viewLicensesButtonLabel),
onPressed: () {
showLicensePage(
context: context,
......@@ -299,7 +300,7 @@ class AboutDialog extends StatelessWidget {
}
),
new FlatButton(
child: const Text('CLOSE'),
child: new Text(MaterialLocalizations.of(context).closeButtonLabel),
onPressed: () {
Navigator.pop(context);
}
......@@ -440,7 +441,7 @@ class _LicensePageState extends State<LicensePage> {
}
return new Scaffold(
appBar: new AppBar(
title: const Text('Licenses')
title: new Text(MaterialLocalizations.of(context).licensesPageTitle),
),
body: new DefaultTextStyle(
style: Theme.of(context).textTheme.caption,
......
......@@ -800,15 +800,16 @@ class _DatePickerDialogState extends State<_DatePickerDialog> {
child: _buildPicker(),
),
);
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
final Widget actions = new ButtonTheme.bar(
child: new ButtonBar(
children: <Widget>[
new FlatButton(
child: const Text('CANCEL'),
child: new Text(localizations.cancelButtonLabel),
onPressed: _handleCancel,
),
new FlatButton(
child: const Text('OK'),
child: new Text(localizations.okButtonLabel),
onPressed: _handleOk,
),
],
......
......@@ -3,5 +3,15 @@
"backButtonTooltip": "الى الخلف",
"closeButtonTooltip": "إغلا",
"nextMonthTooltip": "الشهر القادم",
"previousMonthTooltip": "الشهر الماضى"
"previousMonthTooltip": "الشهر الماضى",
"licensesPageTitle": "التّراخيص",
"cancelButtonLabel": "إلغاء",
"closeButtonLabel": "أغلاق",
"continueButtonLabel": "استمر",
"copyButtonLabel": "نسخ",
"cutButtonLabel": "كِم جارح",
"okButtonLabel": "حسنا",
"pasteButtonLabel": "عجين",
"selectAllButtonLabel": "اختر الكل",
"viewLicensesButtonLabel": "عرض التراخيص"
}
{
"openAppDrawerTooltip": "Navigationsmenü öffnen",
"backButtonTooltip": "Zurück",
"closeButtonTooltip": "Schließen ",
"closeButtonTooltip": "Schließen",
"nextMonthTooltip": "Nächster Monat",
"previousMonthTooltip": "Letzter Monat"
"previousMonthTooltip": "Vorheriger Monat",
"licensesPageTitle": "Lizenzen",
"cancelButtonLabel": "ABBRECHEN",
"closeButtonLabel": "SCHLIESSEN",
"continueButtonLabel": "FORTSETZEN",
"copyButtonLabel": "KOPIEREN",
"cutButtonLabel": "AUSSCHNEIDEN",
"okButtonLabel": "OK",
"pasteButtonLabel": "EINFÜGEN",
"selectAllButtonLabel": "ALLES AUSWÄHLEN",
"viewLicensesButtonLabel": "LIZENZEN ANZEIGEN"
}
......@@ -27,5 +27,65 @@
"@previousMonthTooltip": {
"description": "The tooltip for the MonthPicker's 'previous month' button.",
"type": "text"
},
"licensesPageTitle": "Licenses",
"@licensesPageTitle": {
"description": "The title for the Flutter licenses page.",
"type": "text"
},
"cancelButtonLabel": "CANCEL",
"@cancelButtonLabel": {
"description": "The label for cancel buttons and menu items.",
"type": "text"
},
"closeButtonLabel": "CLOSE",
"@closeButtonLabel": {
"description": "The label for close buttons and menu items.",
"type": "text"
},
"continueButtonLabel": "CONTINUE",
"@continueButtonLabel": {
"description": "The label for continue buttons and menu items.",
"type": "text"
},
"copyButtonLabel": "COPY",
"@copyButtonLabel": {
"description": "The label for copy buttons and menu items.",
"type": "text"
},
"cutButtonLabel": "CUT",
"@cutButtonLabel": {
"description": "The label for cut buttons and menu items",
"type": "text"
},
"okButtonLabel": "OK",
"@okButtonLabel": {
"description": "The label for OK buttons and menu items.",
"type": "text"
},
"pasteButtonLabel": "PASTE",
"@pasteButtonLabel": {
"description": "The label for paste buttons and menu items.",
"type": "text"
},
"selectAllButtonLabel": "SELECT ALL",
"@selectButtonLabel": {
"description": "The label for select-all buttons and menu items.",
"type": "text"
},
"viewLicensesButtonLabel": "VIEW LICENSES",
"@viewLicensesButtonLabel": {
"description": "The label for the about box's view licenses button.",
"type": "text"
}
}
......@@ -3,5 +3,15 @@
"backButtonTooltip": "Espalda",
"closeButtonTooltip": "Cerrar",
"nextMonthTooltip": "Próximo mes",
"previousMonthTooltip": "mes anterior"
"previousMonthTooltip": "Mes anterior",
"licensesPageTitle": "Licencias",
"cancelButtonLabel": "CANCELAR",
"closeButtonLabel": "CERRAR",
"continueButtonLabel": "CONTINUAR",
"copyButtonLabel": "COPIAR",
"cutButtonLabel": "CORTAR",
"okButtonLabel": "OK",
"pasteButtonLabel": "PEGAR",
"selectAllButtonLabel": "SELECCIONAR TODO",
"viewLicensesButtonLabel": "VER LICENCIAS"
}
......@@ -3,5 +3,15 @@
"backButtonTooltip": "بازگشت",
"closeButtonTooltip": "بستن",
"nextMonthTooltip": "ماه بعد",
"previousMonthTooltip": "ماه گذشته"
"previousMonthTooltip": "ماه گذشته",
"licensesPageTitle": "مجوز",
"cancelButtonLabel": "لغو",
"closeButtonLabel": "بستن",
"continueButtonLabel": "ادامه دهید",
"copyButtonLabel": "کپی",
"cutButtonLabel": "برش",
"okButtonLabel": "تایید",
"pasteButtonLabel": "چسباندن",
"selectAllButtonLabel": "انتخاب همه",
"viewLicensesButtonLabel": "مشاهده مجوز"
}
\ No newline at end of file
{
"openAppDrawerTooltip": "Ouvrir le menu de navigation",
"backButtonTooltip": "Arrière",
"backButtonTooltip": "Retour",
"closeButtonTooltip": "Fermer",
"nextMonthTooltip": "Mois Suivant",
"previousMonthTooltip": "Le mois précédent"
"previousMonthTooltip": "Mois précédent",
"licensesPageTitle": "Licences",
"cancelButtonLabel": "ANNULER",
"closeButtonLabel": "FERMER",
"continueButtonLabel": "CONTINUER",
"copyButtonLabel": "COPIER",
"cutButtonLabel": "COUPER",
"okButtonLabel": "OK",
"pasteButtonLabel": "COLLER",
"selectAllButtonLabel": "TOUT SÉLECTIONNER",
"viewLicensesButtonLabel": "AFFICHER LES LICENCES"
}
......@@ -3,5 +3,15 @@
"backButtonTooltip": "אחורה",
"closeButtonTooltip": "סגור",
"nextMonthTooltip": "חודש הבא",
"previousMonthTooltip": "חודש שעבר"
"previousMonthTooltip": "חודש שעבר",
"licensesPageTitle": "רישיונות",
"cancelButtonLabel": "ביטול",
"closeButtonLabel": "סגור",
"continueButtonLabel": "לְהַמשִׁיך",
"copyButtonLabel": "קיבלתי!",
"cutButtonLabel": "גזור",
"okButtonLabel": "בסדר",
"pasteButtonLabel": "הדבק",
"selectAllButtonLabel": "בחר הכל",
"viewLicensesButtonLabel": "ראה רישיונות"
}
\ No newline at end of file
......@@ -3,5 +3,15 @@
"backButtonTooltip": "Indietro",
"closeButtonTooltip": "Chiudi",
"nextMonthTooltip": "Il prossimo mese",
"previousMonthTooltip": "Il mese scorso"
"previousMonthTooltip": "Il mese scorso",
"licensesPageTitle": "Licenze",
"cancelButtonLabel": "ANNULLA",
"closeButtonLabel": "CHIUDI",
"continueButtonLabel": "CONTINUA",
"copyButtonLabel": "COPY",
"cutButtonLabel": "TAGLIARE",
"okButtonLabel": "OK",
"pasteButtonLabel": "INCOLLA",
"selectAllButtonLabel": "SELEZIONA TUTTO",
"viewLicensesButtonLabel": "VEDI LE LICENZE"
}
{
"openAppDrawerTooltip": "ナビゲーションメニューを開く",
"backButtonTooltip": "バック",
"backButtonTooltip": "戻る",
"closeButtonTooltip": "閉じる",
"nextMonthTooltip": "来月",
"previousMonthTooltip": "前の月"
"nextMonthTooltip": "前の月へ",
"previousMonthTooltip": "前の月へ",
"licensesPageTitle": "ライセンス",
"cancelButtonLabel": "キャンセル",
"closeButtonLabel": "閉じる",
"continueButtonLabel": "次へ",
"copyButtonLabel": "コピー",
"cutButtonLabel": "カット",
"okButtonLabel": "OK",
"pasteButtonLabel": "貼付け",
"selectAllButtonLabel": "全選択",
"viewLicensesButtonLabel": "ライセンス表記"
}
......@@ -3,5 +3,15 @@
"backButtonTooltip": "شاته",
"closeButtonTooltip": "بنده",
"nextMonthTooltip": "بله میاشت",
"previousMonthTooltip": "تیره میاشت"
"previousMonthTooltip": "تیره میاشت",
"licensesPageTitle": "جوازونه",
"cancelButtonLabel": "لغوه کول",
"closeButtonLabel": "تړل",
"continueButtonLabel": "منځپانګې",
"copyButtonLabel": "کاپی",
"cutButtonLabel": "کم کړئ",
"okButtonLabel": "سمه ده",
"pasteButtonLabel": "پیټ کړئ",
"selectAllButtonLabel": "غوره کړئ",
"viewLicensesButtonLabel": "لیدلس وګورئ"
}
\ No newline at end of file
......@@ -3,5 +3,15 @@
"backButtonTooltip": "Costas",
"closeButtonTooltip": "Fechar",
"nextMonthTooltip": "Próximo mês",
"previousMonthTooltip": "Mês anterior"
"previousMonthTooltip": "Mês anterior",
"licensesPageTitle": "Licenças",
"cancelButtonLabel": "CANCELAR",
"closeButtonLabel": "FECHAR",
"continueButtonLabel": "CONTINUAR",
"copyButtonLabel": "CÓPIA DE",
"cutButtonLabel": "CORTA",
"okButtonLabel": "OK",
"pasteButtonLabel": "COLAR",
"selectAllButtonLabel": "SELECIONAR TUDO",
"viewLicensesButtonLabel": "VER LICENÇAS"
}
......@@ -3,5 +3,15 @@
"backButtonTooltip": "назад",
"closeButtonTooltip": "Закрыть",
"nextMonthTooltip": "В следующем месяце",
"previousMonthTooltip": "Предыдущий месяц"
"previousMonthTooltip": "Предыдущий месяц",
"licensesPageTitle": "Лицензии",
"cancelButtonLabel": "ОТМЕНА",
"closeButtonLabel": "ЗАКРЫТЬ",
"continueButtonLabel": "ПРОДОЛЖАТЬ",
"copyButtonLabel": "копия",
"cutButtonLabel": "порез",
"okButtonLabel": "ОК",
"pasteButtonLabel": "Паст",
"selectAllButtonLabel": "Выбрать все",
"viewLicensesButtonLabel": "ПРОСМОТРЕТЬ ЛИЦЕНЗИИ"
}
......@@ -3,5 +3,15 @@
"backButtonTooltip": "پوئتي",
"closeButtonTooltip": "بند ڪريو",
"nextMonthTooltip": "ايندڙ مهيني",
"previousMonthTooltip": "پويون مهينو"
}
\ No newline at end of file
"previousMonthTooltip": "پويون مهينو",
"licensesPageTitle": "لائسنس",
"cancelButtonLabel": "منسوخ ڪيو",
"closeButtonLabel": "بند ڪريو",
"continueButtonLabel": "جاري رکو",
"copyButtonLabel": "ڪاپي",
"cutButtonLabel": "پٽي",
"okButtonLabel": "ٺيڪ آهي",
"pasteButtonLabel": "پيسٽ ڪريو",
"selectAllButtonLabel": "سڀ چونڊيو",
"viewLicensesButtonLabel": "لائسنس ڏسو"
}
......@@ -3,5 +3,15 @@
"backButtonTooltip": "واپس",
"closeButtonTooltip": "بند کریں",
"nextMonthTooltip": "اگلا مھینہ",
"previousMonthTooltip": "پچھلا مھینہ"
"previousMonthTooltip": "پچھلا مھینہ",
"licensesPageTitle": "لائسنس",
"cancelButtonLabel": "منسوخ کریں",
"closeButtonLabel": "بند کریں",
"continueButtonLabel": "جاری رکھیں",
"copyButtonLabel": "کاپی",
"cutButtonLabel": "کاٹیں",
"okButtonLabel": "ٹھیک ہے",
"pasteButtonLabel": "چسپاں",
"selectAllButtonLabel": "تکاپیمام منتخب کریں",
"viewLicensesButtonLabel": "لائسنس دیکھیں"
}
\ No newline at end of file
{
"openAppDrawerTooltip": "打开导航菜单",
"backButtonTooltip": "背部",
"closeButtonTooltip": "关",
"nextMonthTooltip": "-下月就29了。",
"previousMonthTooltip": "前一个月"
"backButtonTooltip": "返回",
"closeButtonTooltip": "关闭",
"nextMonthTooltip": "下一个月",
"previousMonthTooltip": "上一个月",
"licensesPageTitle": "许可证",
"cancelButtonLabel": "取消",
"continueButtonLabel": "继续",
"closeButtonLabel": "关闭",
"copyButtonLabel": "复制",
"cutButtonLabel": "剪切",
"okButtonLabel": "确定",
"pasteButtonLabel": "粘贴",
"selectAllButtonLabel": "全选",
"viewLicensesButtonLabel": "查看许可证"
}
......@@ -31,6 +31,36 @@ abstract class MaterialLocalizations {
/// The tooltip for the [MonthPicker]'s "previous month" button.
String get previousMonthTooltip;
/// Title for the [LicensePage] widget.
String get licensesPageTitle;
/// Label for "cancel" buttons and menu items.
String get cancelButtonLabel;
/// Label for "close" buttons and menu items.
String get closeButtonLabel;
/// Label for "continue" buttons and menu items.
String get continueButtonLabel;
/// Label for "copy" edit buttons and menu items.
String get copyButtonLabel;
/// Label for "cut" edit buttons and menu items.
String get cutButtonLabel;
/// Label for OK buttons and menu items.
String get okButtonLabel;
/// Label for "paste" edit buttons and menu items.
String get pasteButtonLabel;
/// Label for "select all" edit buttons and menu items.
String get selectAllButtonLabel;
/// Label for the [AboutBox] button that shows the [LicensePage].
String get viewLicensesButtonLabel;
/// The `MaterialLocalizations` from the closest [Localizations] instance
/// that encloses the given context.
///
......@@ -84,6 +114,36 @@ class DefaultMaterialLocalizations implements MaterialLocalizations {
@override
String get previousMonthTooltip => _nameToValue["previousMonthTooltip"];
@override
String get licensesPageTitle => _nameToValue["licensesPageTitle"];
@override
String get cancelButtonLabel => _nameToValue["cancelButtonLabel"];
@override
String get closeButtonLabel => _nameToValue["closeButtonLabel"];
@override
String get continueButtonLabel => _nameToValue["continueButtonLabel"];
@override
String get copyButtonLabel => _nameToValue["copyButtonLabel"];
@override
String get cutButtonLabel => _nameToValue["cutButtonLabel"];
@override
String get okButtonLabel => _nameToValue["okButtonLabel"];
@override
String get pasteButtonLabel => _nameToValue["pasteButtonLabel"];
@override
String get selectAllButtonLabel => _nameToValue["selectAllButtonLabel"];
@override
String get viewLicensesButtonLabel => _nameToValue["viewLicensesButtonLabel"];
/// Creates an object that provides localized resource values for the
/// for the widgets of the material library.
///
......
......@@ -12,6 +12,7 @@ import 'flat_button.dart';
import 'icons.dart';
import 'ink_well.dart';
import 'material.dart';
import 'material_localizations.dart';
import 'theme.dart';
import 'typography.dart';
......@@ -339,6 +340,7 @@ class _StepperState extends State<Stepper> with TickerProviderStateMixin {
assert(cancelColor != null);
final ThemeData themeData = Theme.of(context);
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
return new Container(
margin: const EdgeInsets.only(top: 16.0),
......@@ -351,7 +353,7 @@ class _StepperState extends State<Stepper> with TickerProviderStateMixin {
color: _isDark() ? themeData.backgroundColor : themeData.primaryColor,
textColor: Colors.white,
textTheme: ButtonTextTheme.normal,
child: const Text('CONTINUE'),
child: new Text(localizations.continueButtonLabel),
),
new Container(
margin: const EdgeInsetsDirectional.only(start: 8.0),
......@@ -359,7 +361,7 @@ class _StepperState extends State<Stepper> with TickerProviderStateMixin {
onPressed: widget.onStepCancel,
textColor: cancelColor,
textTheme: ButtonTextTheme.normal,
child: const Text('CANCEL'),
child: new Text(localizations.cancelButtonLabel),
),
),
],
......
......@@ -10,6 +10,7 @@ import 'package:flutter/services.dart';
import 'flat_button.dart';
import 'material.dart';
import 'material_localizations.dart';
import 'theme.dart';
const double _kHandleSize = 22.0;
......@@ -39,20 +40,21 @@ class _TextSelectionToolbar extends StatelessWidget {
@override
Widget build(BuildContext context) {
final List<Widget> items = <Widget>[];
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
if (!value.selection.isCollapsed) {
items.add(new FlatButton(child: const Text('CUT'), onPressed: handleCut));
items.add(new FlatButton(child: const Text('COPY'), onPressed: handleCopy));
items.add(new FlatButton(child: new Text(localizations.cutButtonLabel), onPressed: handleCut));
items.add(new FlatButton(child: new Text(localizations.copyButtonLabel), onPressed: handleCopy));
}
items.add(new FlatButton(
child: const Text('PASTE'),
child: new Text(localizations.pasteButtonLabel),
// TODO(https://github.com/flutter/flutter/issues/11254):
// This should probably be grayed-out if there is nothing to paste.
onPressed: handlePaste,
));
if (value.text.isNotEmpty) {
if (value.selection.isCollapsed)
items.add(new FlatButton(child: const Text('SELECT ALL'), onPressed: handleSelectAll));
items.add(new FlatButton(child: new Text(localizations.selectAllButtonLabel), onPressed: handleSelectAll));
}
return new Material(
......
......@@ -15,6 +15,7 @@ import 'colors.dart';
import 'dialog.dart';
import 'feedback.dart';
import 'flat_button.dart';
import 'material_localizations.dart';
import 'theme.dart';
import 'typography.dart';
......@@ -697,15 +698,16 @@ class _TimePickerDialogState extends State<_TimePickerDialog> {
)
);
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
final Widget actions = new ButtonTheme.bar(
child: new ButtonBar(
children: <Widget>[
new FlatButton(
child: const Text('CANCEL'),
child: new Text(localizations.cancelButtonLabel),
onPressed: _handleCancel
),
new FlatButton(
child: const Text('OK'),
child: new Text(localizations.okButtonLabel),
onPressed: _handleOk
),
]
......
......@@ -23,9 +23,9 @@ Widget buildFrame({
}
void main() {
final Key textKey = new UniqueKey();
testWidgets('sanity check', (WidgetTester tester) async {
final Key textKey = new UniqueKey();
await tester.pumpWidget(
buildFrame(
buildContent: (BuildContext context) {
......@@ -49,4 +49,44 @@ void main() {
await tester.pump();
expect(tester.widget<Text>(find.byKey(textKey)).data, 'Back');
});
testWidgets('translations exist for all materia/i18n languages', (WidgetTester tester) async {
final List<String> languages = <String>[
'ar', // Arabic
'de', // German
'en', // English
'es', // Spanish
'fa', // Farsi (Persian)
'fr', // French
'he', // Hebrew
'it', // Italian
'ja', // Japanese
'ps', // Pashto
'pt', // Portugese
'ru', // Russian
'sd', // Sindhi
'ur', // Urdu
'zh', // Chinese (simplified)
];
for (String language in languages) {
final Locale locale = new Locale(language, '');
final MaterialLocalizations localizations = new DefaultMaterialLocalizations(locale);
expect(localizations.openAppDrawerTooltip, isNotNull);
expect(localizations.backButtonTooltip, isNotNull);
expect(localizations.closeButtonTooltip, isNotNull);
expect(localizations.nextMonthTooltip, isNotNull);
expect(localizations.previousMonthTooltip, isNotNull);
expect(localizations.licensesPageTitle, isNotNull);
expect(localizations.cancelButtonLabel, isNotNull);
expect(localizations.closeButtonLabel, isNotNull);
expect(localizations.continueButtonLabel, isNotNull);
expect(localizations.copyButtonLabel, isNotNull);
expect(localizations.cutButtonLabel, isNotNull);
expect(localizations.okButtonLabel, isNotNull);
expect(localizations.pasteButtonLabel, isNotNull);
expect(localizations.selectAllButtonLabel, isNotNull);
expect(localizations.viewLicensesButtonLabel, isNotNull);
}
});
}
......@@ -27,34 +27,64 @@ class MockClipboard {
}
}
class MaterialLocalizationsDelegate extends LocalizationsDelegate<MaterialLocalizations> {
@override
Future<MaterialLocalizations> load(Locale locale) => DefaultMaterialLocalizations.load(locale);
@override
bool shouldReload(MaterialLocalizationsDelegate old) => false;
}
class WidgetsLocalizationsDelegate extends LocalizationsDelegate<WidgetsLocalizations> {
@override
Future<WidgetsLocalizations> load(Locale locale) => DefaultWidgetsLocalizations.load(locale);
@override
bool shouldReload(WidgetsLocalizationsDelegate old) => false;
}
Widget overlay({ Widget child }) {
return new Directionality(
textDirection: TextDirection.ltr,
child: new MediaQuery(
data: const MediaQueryData(size: const Size(800.0, 600.0)),
child: new Overlay(
initialEntries: <OverlayEntry>[
new OverlayEntry(
builder: (BuildContext context) => new Center(
child: new Material(
child: child,
return new Localizations(
locale: const Locale('en', 'US'),
delegates: <LocalizationsDelegate<dynamic>>[
new WidgetsLocalizationsDelegate(),
new MaterialLocalizationsDelegate(),
],
child: new Directionality(
textDirection: TextDirection.ltr,
child: new MediaQuery(
data: const MediaQueryData(size: const Size(800.0, 600.0)),
child: new Overlay(
initialEntries: <OverlayEntry>[
new OverlayEntry(
builder: (BuildContext context) => new Center(
child: new Material(
child: child,
),
),
),
),
],
],
),
),
),
);
}
Widget boilerplate({ Widget child }) {
return new Directionality(
textDirection: TextDirection.ltr,
child: new MediaQuery(
data: const MediaQueryData(size: const Size(800.0, 600.0)),
child: new Center(
child: new Material(
child: child,
return new Localizations(
locale: const Locale('en', 'US'),
delegates: <LocalizationsDelegate<dynamic>>[
new WidgetsLocalizationsDelegate(),
new MaterialLocalizationsDelegate(),
],
child: new Directionality(
textDirection: TextDirection.ltr,
child: new MediaQuery(
data: const MediaQueryData(size: const Size(800.0, 600.0)),
child: new Center(
child: new Material(
child: child,
),
),
),
),
......
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