Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_34031325
engine
提交
3002e25e
E
engine
项目概览
qq_34031325
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
3002e25e
编写于
4月 02, 2020
作者:
D
Dan Field
提交者:
GitHub
4月 02, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Initialize locale from FlutterEngine (#17473)
* Initialize locale from FlutterEngine
上级
8166a91b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
49 addition
and
48 deletion
+49
-48
shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
+48
-0
shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
...form/darwin/ios/framework/Source/FlutterViewController.mm
+0
-48
testing/scenario_app/lib/main.dart
testing/scenario_app/lib/main.dart
+1
-0
未找到文件。
shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
浏览文件 @
3002e25e
...
...
@@ -122,6 +122,11 @@ NSString* const FlutterDefaultDartEntrypoint = nil;
name:
UIApplicationWillResignActiveNotification
object:
nil
];
[
center
addObserver
:
self
selector:
@selector
(
onLocaleUpdated
:)
name:
NSCurrentLocaleDidChangeNotification
object:
nil
];
return
self
;
}
...
...
@@ -494,6 +499,7 @@ NSString* const FlutterDefaultDartEntrypoint = nil;
<<
entrypoint
.
UTF8String
;
}
else
{
[
self
setupChannels
];
[
self
onLocaleUpdated
:
nil
];
if
(
!
_platformViewsController
)
{
_platformViewsController
.
reset
(
new
flutter
::
FlutterPlatformViewsController
());
}
...
...
@@ -710,6 +716,48 @@ NSString* const FlutterDefaultDartEntrypoint = nil;
_isGpuDisabled
=
value
;
}
#pragma mark - Locale updates
-
(
void
)
onLocaleUpdated
:(
NSNotification
*
)
notification
{
NSArray
<
NSString
*>*
preferredLocales
=
[
NSLocale
preferredLanguages
];
NSMutableArray
<
NSString
*>*
data
=
[[
NSMutableArray
new
]
autorelease
];
// Force prepend the [NSLocale currentLocale] to the front of the list
// to ensure we are including the full default locale. preferredLocales
// is not guaranteed to include anything beyond the languageCode.
NSLocale
*
currentLocale
=
[
NSLocale
currentLocale
];
NSString
*
languageCode
=
[
currentLocale
objectForKey
:
NSLocaleLanguageCode
];
NSString
*
countryCode
=
[
currentLocale
objectForKey
:
NSLocaleCountryCode
];
NSString
*
scriptCode
=
[
currentLocale
objectForKey
:
NSLocaleScriptCode
];
NSString
*
variantCode
=
[
currentLocale
objectForKey
:
NSLocaleVariantCode
];
if
(
languageCode
)
{
[
data
addObject
:
languageCode
];
[
data
addObject
:(
countryCode
?
countryCode
:
@""
)];
[
data
addObject
:(
scriptCode
?
scriptCode
:
@""
)];
[
data
addObject
:(
variantCode
?
variantCode
:
@""
)];
}
// Add any secondary locales/languages to the list.
for
(
NSString
*
localeID
in
preferredLocales
)
{
NSLocale
*
currentLocale
=
[[[
NSLocale
alloc
]
initWithLocaleIdentifier
:
localeID
]
autorelease
];
NSString
*
languageCode
=
[
currentLocale
objectForKey
:
NSLocaleLanguageCode
];
NSString
*
countryCode
=
[
currentLocale
objectForKey
:
NSLocaleCountryCode
];
NSString
*
scriptCode
=
[
currentLocale
objectForKey
:
NSLocaleScriptCode
];
NSString
*
variantCode
=
[
currentLocale
objectForKey
:
NSLocaleVariantCode
];
if
(
!
languageCode
)
{
continue
;
}
[
data
addObject
:
languageCode
];
[
data
addObject
:(
countryCode
?
countryCode
:
@""
)];
[
data
addObject
:(
scriptCode
?
scriptCode
:
@""
)];
[
data
addObject
:(
variantCode
?
variantCode
:
@""
)];
}
if
(
data
.
count
==
0
)
{
return
;
}
[
self
.
localizationChannel
invokeMethod
:
@"setLocale"
arguments
:
data
];
}
@end
@implementation
FlutterEngineRegistrar
{
...
...
shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
浏览文件 @
3002e25e
...
...
@@ -279,11 +279,6 @@ typedef enum UIAccessibilityContrast : NSInteger {
name:
UIKeyboardWillHideNotification
object:
nil
];
[
center
addObserver
:
self
selector:
@selector
(
onLocaleUpdated
:)
name:
NSCurrentLocaleDidChangeNotification
object:
nil
];
[
center
addObserver
:
self
selector:
@selector
(
onAccessibilityStatusChanged
:)
name:
UIAccessibilityVoiceOverStatusChanged
...
...
@@ -595,7 +590,6 @@ static void sendFakeTouchEvent(FlutterEngine* engine,
-
(
void
)
viewDidAppear
:(
BOOL
)
animated
{
TRACE_EVENT0
(
"flutter"
,
"viewDidAppear"
);
[
self
onLocaleUpdated
:
nil
];
[
self
onUserSettingsChanged
:
nil
];
[
self
onAccessibilityStatusChanged
:
nil
];
[[
_engine
.
get
()
lifecycleChannel
]
sendMessage
:
@"AppLifecycleState.resumed"
];
...
...
@@ -1054,48 +1048,6 @@ static flutter::PointerData::DeviceKind DeviceKindFromTouchType(UITouch* touch)
#endif
}
#pragma mark - Locale updates
-
(
void
)
onLocaleUpdated
:(
NSNotification
*
)
notification
{
NSArray
<
NSString
*>*
preferredLocales
=
[
NSLocale
preferredLanguages
];
NSMutableArray
<
NSString
*>*
data
=
[[
NSMutableArray
new
]
autorelease
];
// Force prepend the [NSLocale currentLocale] to the front of the list
// to ensure we are including the full default locale. preferredLocales
// is not guaranteed to include anything beyond the languageCode.
NSLocale
*
currentLocale
=
[
NSLocale
currentLocale
];
NSString
*
languageCode
=
[
currentLocale
objectForKey
:
NSLocaleLanguageCode
];
NSString
*
countryCode
=
[
currentLocale
objectForKey
:
NSLocaleCountryCode
];
NSString
*
scriptCode
=
[
currentLocale
objectForKey
:
NSLocaleScriptCode
];
NSString
*
variantCode
=
[
currentLocale
objectForKey
:
NSLocaleVariantCode
];
if
(
languageCode
)
{
[
data
addObject
:
languageCode
];
[
data
addObject
:(
countryCode
?
countryCode
:
@""
)];
[
data
addObject
:(
scriptCode
?
scriptCode
:
@""
)];
[
data
addObject
:(
variantCode
?
variantCode
:
@""
)];
}
// Add any secondary locales/languages to the list.
for
(
NSString
*
localeID
in
preferredLocales
)
{
NSLocale
*
currentLocale
=
[[[
NSLocale
alloc
]
initWithLocaleIdentifier
:
localeID
]
autorelease
];
NSString
*
languageCode
=
[
currentLocale
objectForKey
:
NSLocaleLanguageCode
];
NSString
*
countryCode
=
[
currentLocale
objectForKey
:
NSLocaleCountryCode
];
NSString
*
scriptCode
=
[
currentLocale
objectForKey
:
NSLocaleScriptCode
];
NSString
*
variantCode
=
[
currentLocale
objectForKey
:
NSLocaleVariantCode
];
if
(
!
languageCode
)
{
continue
;
}
[
data
addObject
:
languageCode
];
[
data
addObject
:(
countryCode
?
countryCode
:
@""
)];
[
data
addObject
:(
scriptCode
?
scriptCode
:
@""
)];
[
data
addObject
:(
variantCode
?
variantCode
:
@""
)];
}
if
(
data
.
count
==
0
)
{
return
;
}
[[
_engine
.
get
()
localizationChannel
]
invokeMethod
:
@"setLocale"
arguments
:
data
];
}
#pragma mark - Set user settings
-
(
void
)
traitCollectionDidChange
:(
UITraitCollection
*
)
previousTraitCollection
{
...
...
testing/scenario_app/lib/main.dart
浏览文件 @
3002e25e
...
...
@@ -43,6 +43,7 @@ Map<String, Scenario> _scenarios = <String, Scenario>{
Scenario
_currentScenario
=
_scenarios
[
'animated_color_square'
];
void
main
(
)
{
assert
(
window
.
locale
!=
null
);
window
..
onPlatformMessage
=
_handlePlatformMessage
..
onBeginFrame
=
_onBeginFrame
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录