Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
7245c4a6
Unverified
Commit
7245c4a6
authored
Nov 05, 2018
by
Hans Muller
Committed by
GitHub
Nov 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Warn about supported locales that lack localizations (#23850)
parent
02355d4c
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
70 additions
and
3 deletions
+70
-3
localizations.dart
packages/flutter/lib/src/cupertino/localizations.dart
+3
-0
material_localizations.dart
...ages/flutter/lib/src/material/material_localizations.dart
+3
-0
app.dart
packages/flutter/lib/src/widgets/app.dart
+55
-3
localizations.dart
packages/flutter/lib/src/widgets/localizations.dart
+3
-0
material_localizations.dart
...flutter_localizations/lib/src/material_localizations.dart
+3
-0
widgets_localizations.dart
.../flutter_localizations/lib/src/widgets_localizations.dart
+3
-0
No files found.
packages/flutter/lib/src/cupertino/localizations.dart
View file @
7245c4a6
...
@@ -213,6 +213,9 @@ class _CupertinoLocalizationsDelegate extends LocalizationsDelegate<CupertinoLoc
...
@@ -213,6 +213,9 @@ class _CupertinoLocalizationsDelegate extends LocalizationsDelegate<CupertinoLoc
@override
@override
bool
shouldReload
(
_CupertinoLocalizationsDelegate
old
)
=>
false
;
bool
shouldReload
(
_CupertinoLocalizationsDelegate
old
)
=>
false
;
@override
String
toString
()
=>
'DefaultCupertinoLocalizations.delegate(en_US)'
;
}
}
/// US English strings for the cupertino widgets.
/// US English strings for the cupertino widgets.
...
...
packages/flutter/lib/src/material/material_localizations.dart
View file @
7245c4a6
...
@@ -338,6 +338,9 @@ class _MaterialLocalizationsDelegate extends LocalizationsDelegate<MaterialLocal
...
@@ -338,6 +338,9 @@ class _MaterialLocalizationsDelegate extends LocalizationsDelegate<MaterialLocal
@override
@override
bool
shouldReload
(
_MaterialLocalizationsDelegate
old
)
=>
false
;
bool
shouldReload
(
_MaterialLocalizationsDelegate
old
)
=>
false
;
@override
String
toString
()
=>
'DefaultMaterialLocalizations.delegate(en_US)'
;
}
}
/// US English strings for the material widgets.
/// US English strings for the material widgets.
...
...
packages/flutter/lib/src/widgets/app.dart
View file @
7245c4a6
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
import
'dart:async'
;
import
'dart:async'
;
import
'dart:ui'
as
ui
show
window
;
import
'dart:ui'
as
ui
show
window
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'banner.dart'
;
import
'banner.dart'
;
...
@@ -769,6 +770,53 @@ class _WidgetsAppState extends State<WidgetsApp> implements WidgetsBindingObserv
...
@@ -769,6 +770,53 @@ class _WidgetsAppState extends State<WidgetsApp> implements WidgetsBindingObserv
// BUILDER
// BUILDER
bool
_debugCheckLocalizations
(
Locale
appLocale
)
{
assert
(()
{
final
Set
<
Type
>
unsupportedTypes
=
_localizationsDelegates
.
map
<
Type
>((
LocalizationsDelegate
<
dynamic
>
delegate
)
=>
delegate
.
type
).
toSet
();
for
(
LocalizationsDelegate
<
dynamic
>
delegate
in
_localizationsDelegates
)
{
if
(!
unsupportedTypes
.
contains
(
delegate
.
type
))
continue
;
if
(
delegate
.
isSupported
(
appLocale
))
unsupportedTypes
.
remove
(
delegate
.
type
);
}
if
(
unsupportedTypes
.
isEmpty
)
return
true
;
// Currently the Cupertino library only provides english localizations.
// Remove this when https://github.com/flutter/flutter/issues/23847
// is fixed.
if
(
listEquals
(
unsupportedTypes
.
map
((
Type
type
)
=>
type
.
toString
()).
toList
(),
<
String
>[
'CupertinoLocalizations'
]))
return
true
;
final
StringBuffer
message
=
StringBuffer
();
message
.
writeln
(
'
\
u2550'
*
8
);
message
.
writeln
(
'Warning: This application
\'
s locale,
$appLocale
, is not supported by all of its
\n
'
'localization delegates.'
);
for
(
Type
unsupportedType
in
unsupportedTypes
)
{
// Currently the Cupertino library only provides english localizations.
// Remove this when https://github.com/flutter/flutter/issues/23847
// is fixed.
if
(
unsupportedType
.
toString
()
==
'CupertinoLocalizations'
)
continue
;
message
.
writeln
(
'> A
$unsupportedType
delegate that supports the
$appLocale
locale was not found.'
);
}
message
.
writeln
(
'See https://flutter.io/tutorials/internationalization/ for more
\n
'
'information about configuring an app
\'
s locale, supportedLocales,
\n
'
'and localizationsDelegates parameters.'
);
message
.
writeln
(
'
\
u2550'
*
8
);
debugPrint
(
message
.
toString
());
return
true
;
}());
return
true
;
}
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
Widget
navigator
;
Widget
navigator
;
...
@@ -874,12 +922,16 @@ class _WidgetsAppState extends State<WidgetsApp> implements WidgetsBindingObserv
...
@@ -874,12 +922,16 @@ class _WidgetsAppState extends State<WidgetsApp> implements WidgetsBindingObserv
);
);
}
}
final
Locale
appLocale
=
widget
.
locale
!=
null
?
_resolveLocale
(
widget
.
locale
,
widget
.
supportedLocales
)
:
_locale
;
assert
(
_debugCheckLocalizations
(
appLocale
));
return
MediaQuery
(
return
MediaQuery
(
data:
MediaQueryData
.
fromWindow
(
ui
.
window
),
data:
MediaQueryData
.
fromWindow
(
ui
.
window
),
child:
Localizations
(
child:
Localizations
(
locale:
widget
.
locale
!=
null
locale:
appLocale
,
?
_resolveLocale
(
widget
.
locale
,
widget
.
supportedLocales
)
:
_locale
,
delegates:
_localizationsDelegates
.
toList
(),
delegates:
_localizationsDelegates
.
toList
(),
child:
title
,
child:
title
,
),
),
...
...
packages/flutter/lib/src/widgets/localizations.dart
View file @
7245c4a6
...
@@ -181,6 +181,9 @@ class _WidgetsLocalizationsDelegate extends LocalizationsDelegate<WidgetsLocaliz
...
@@ -181,6 +181,9 @@ class _WidgetsLocalizationsDelegate extends LocalizationsDelegate<WidgetsLocaliz
@override
@override
bool
shouldReload
(
_WidgetsLocalizationsDelegate
old
)
=>
false
;
bool
shouldReload
(
_WidgetsLocalizationsDelegate
old
)
=>
false
;
@override
String
toString
()
=>
'DefaultWidgetsLocalizations.delegate(en_US)'
;
}
}
/// US English localizations for the widgets library.
/// US English localizations for the widgets library.
...
...
packages/flutter_localizations/lib/src/material_localizations.dart
View file @
7245c4a6
...
@@ -641,4 +641,7 @@ class _MaterialLocalizationsDelegate extends LocalizationsDelegate<MaterialLocal
...
@@ -641,4 +641,7 @@ class _MaterialLocalizationsDelegate extends LocalizationsDelegate<MaterialLocal
@override
@override
bool
shouldReload
(
_MaterialLocalizationsDelegate
old
)
=>
false
;
bool
shouldReload
(
_MaterialLocalizationsDelegate
old
)
=>
false
;
@override
String
toString
()
=>
'GlobalMaterialLocalizations.delegate(
${kSupportedLanguages.length}
locales)'
;
}
}
packages/flutter_localizations/lib/src/widgets_localizations.dart
View file @
7245c4a6
...
@@ -74,4 +74,7 @@ class _WidgetsLocalizationsDelegate extends LocalizationsDelegate<WidgetsLocaliz
...
@@ -74,4 +74,7 @@ class _WidgetsLocalizationsDelegate extends LocalizationsDelegate<WidgetsLocaliz
@override
@override
bool
shouldReload
(
_WidgetsLocalizationsDelegate
old
)
=>
false
;
bool
shouldReload
(
_WidgetsLocalizationsDelegate
old
)
=>
false
;
@override
String
toString
()
=>
'GlobalWidgetsLocalizations.delegate(all locales)'
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment