提交 6a1ad20c 编写于 作者: T Todd Volkert

Wire up locale notifications to ios.

Fixes #2282
上级 58adea7f
......@@ -157,6 +157,12 @@ static std::string TracesBasePath() {
selector:@selector(keyboardWillBeHidden:)
name:UIKeyboardWillHideNotification
object:nil];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(onLocaleUpdated:)
name:NSCurrentLocaleDidChangeNotification
object:nil];
}
return self;
}
......@@ -179,6 +185,13 @@ static std::string TracesBasePath() {
_engine->OnViewportMetricsChanged(_viewportMetrics.Clone());
}
- (void)onLocaleUpdated:(NSNotification*)notification {
NSLocale *currentLocale = [NSLocale currentLocale];
NSString *languageCode = [currentLocale objectForKey:NSLocaleLanguageCode];
NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode];
_engine->OnLocaleChanged(languageCode.UTF8String, countryCode.UTF8String);
}
- (void)layoutSubviews {
TRACE_EVENT0("flutter", "layoutSubviews");
[super layoutSubviews];
......@@ -253,6 +266,9 @@ static std::string TracesBasePath() {
services->services_provided_by_embedder = service_provider.Pass();
_engine->SetServices(services.Pass());
// Initialize to current locale
[self onLocaleUpdated:nil];
#if TARGET_IPHONE_SIMULATOR
[self runFromDartSource];
#else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册