Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

iOS can set application locale before view controller is set#176592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
chunhtai wants to merge3 commits intoflutter:master
base:master
Choose a base branch
Loading
fromchunhtai:issues/176478
Open
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
update
  • Loading branch information
@chunhtai
chunhtai committedOct 6, 2025
commit2433717b97b961f881496f3b5752d510b77e6c13
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -141,6 +141,7 @@ class PlatformViewIOS final : public PlatformView {
AccessibilityBridge* GetAccessibilityBridge() { return accessibility_bridge_.get(); }

private:
void ApplyLocaleToOwnerController();
/// Smart pointer for use with objective-c observers.
/// This guarantees we remove the observer.
class ScopedObserver {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,8 +66,7 @@ new PlatformMessageHandlerIos(task_runners.GetPlatformTaskRunner())) {}
accessibility_bridge_.reset();
}
owner_controller_ = owner_controller;
owner_controller_.applicationLocale =
application_locale_.empty() ? nil : @(application_locale_.data());
ApplyLocaleToOwnerController();

// Add an observer that will clear out the owner_controller_ ivar and
// the accessibility_bridge_ in case the view controller is deleted.
Expand DownExpand Up@@ -164,10 +163,7 @@ new PlatformMessageHandlerIos(task_runners.GetPlatformTaskRunner())) {}
// |PlatformView|
void PlatformViewIOS::SetApplicationLocale(std::string locale) {
application_locale_ = std::move(locale);
if (owner_controller_) {
owner_controller_.applicationLocale =
application_locale_.empty() ? nil : @(application_locale_.data());
}
ApplyLocaleToOwnerController();
}

// |PlatformView|
Expand All@@ -189,6 +185,7 @@ new PlatformMessageHandlerIos(task_runners.GetPlatformTaskRunner())) {}
return std::make_unique<VsyncWaiterIOS>(task_runners_);
}

// |PlatformView|
void PlatformViewIOS::OnPreEngineRestart() const {
if (accessibility_bridge_) {
accessibility_bridge_.get()->clearState();
Expand All@@ -201,6 +198,7 @@ new PlatformMessageHandlerIos(task_runners.GetPlatformTaskRunner())) {}
[owner_controller_.textInputPlugin reset];
}

// |PlatformView|
std::unique_ptr<std::vector<std::string>> PlatformViewIOS::ComputePlatformResolvedLocales(
const std::vector<std::string>& supported_locale_data) {
size_t localeDataLength = 3;
Expand DownExpand Up@@ -235,6 +233,13 @@ new PlatformMessageHandlerIos(task_runners.GetPlatformTaskRunner())) {}
return out;
}

void PlatformViewIOS::ApplyLocaleToOwnerController() {
if (owner_controller_) {
owner_controller_.applicationLocale =
application_locale_.empty() ? nil : @(application_locale_.data());
}
}

PlatformViewIOS::ScopedObserver::ScopedObserver() {}

PlatformViewIOS::ScopedObserver::~ScopedObserver() {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -132,7 +132,8 @@ - (void)testLocaleCanBeSetWithoutViewController {
std::string locale = "en-US";
platform_view->SetApplicationLocale(locale);
platform_view->SetOwnerViewController(flutterViewController);
OCMVerify([flutterViewController setApplicationLocale:@"en-US"]) latch.Signal();
OCMVerify([flutterViewController setApplicationLocale:@"en-US"]);
latch.Signal();
});
latch.Wait();

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp