-
Notifications
You must be signed in to change notification settings - Fork 29
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add device localization on ios #532
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a few comments inline. As they may impact parts of the implementation I'll be taking another look once you respond to the comments
|
||
type LocaleWithDescription = { localeIdentifier: Locale; Description: string }; | ||
|
||
export function DeviceLocalizationView() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The filename is missing "n" packages/vscode-extension/src/webview/views/DeviceLocalizatioView.tsx
@@ -0,0 +1,318 @@ | |||
[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed? If so explain why in the PR. We can perhaps use some library or built-in localization APi for this, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the best solution I could think of there are libraries that do this kind of work but none is doing exactly what I need.
this one maps from country to codes not from language.
this one wasn't updated for a long time
and libraries responsible for localization management add unnecessary complexity.
I got the list in the pull request by taking a product of codes available on iOS and on android.
return ( | ||
<div className="localization-container"> | ||
<div className="search-bar"> | ||
<input |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we autofocus this when the modal is shown?
public async restart( | ||
forceCleanBuild: boolean, | ||
onlyReloadJSWhenPossible: boolean = true, | ||
restartDevice?: boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be cleaner if this had a default value like the previous paameter, in this case if it was set to false
it'd work the same way it does now but the type would be strict
if (await this.device.checkLocale(deviceSettings.locale)) { | ||
await this.device.changeLocale(deviceSettings.locale); | ||
await this.device.resetDevice(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like this is implementation detail for a given device, shouldn't it be a part of changeSetting implementation that's specific to device rather than being handled in a generic way?
deviceSetLocation, | ||
"spawn", | ||
this.deviceUDID, | ||
"defaults", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we could simplify the process and avoid restarts if we use the same method for updating defaults as we do for things like schemeapproval list (see below)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately no, we could change the way we modify relavent, plist but we still have no way to modify what operating system keeps in memory at runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, but we could still update that before the boot. Now we boot the device to only update this setting and the reboot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you were right I was able to avoid reset on on boot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving a couple more comments inline
return ( | ||
<div className="localization-container"> | ||
<div className="search-bar"> | ||
<input |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we automatically focus search field when the modal is open?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I already did that, there is a bug in the frontend that persist focus on deviceSettingsDropdown after it was closed, but it is outside of scope for this PR so I'll look into it in another one
here is an example of how the component works when deviceSettingsDropdown is not focused:
https://github.com/user-attachments/assets/b31fd863-c4c6-4062-8913-b20004683d00
|
||
if (await this.shouldUpdateLocale(deviceSettings.locale)) { | ||
await this.changeLocale(deviceSettings.locale); | ||
await this.resetDevice(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given we call internalBootDevice
as a result of this call here, would it make sense to do that before the previous call to inernalBootDevice
? This way we can avoid booting it twice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is neccesery to boot it twice i added a coment explaining that, in short we use adb shell to change locale so device needs to be booted. The solution you provided (-change-locale
) unfortunately has the same short comings as just using adb shell setprop persist.sys.locale
and moreover boots device twice anyway (performs cold boot after changing locale).
// but if the user has more then languages set up then a setting in settings_system are created | ||
// in such a case we need to change them too. It seems that if the setting exists in | ||
// settings_system it is persistent even if the number of locales drops back to one. | ||
await exec(ADB_PATH, ["-s", this.serial!, "shell", "setprop", "persist.sys.locale", locale]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately, this approach won't work because it does the same thing as adb shell setprop persist.sys.locale ${locale}
witch means it works only as long as locales are not set in /data/system/users/0/settings_system.xml
(system settings) witch will override the persist.sys.locale prop. Moreover the approach with emulator cli tool does not provide significant benefits as it still turns on the device before reseting it agin to load changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The easiest way to reproduce this problem is to on device go to settings>system>languages and add more then one language that will ensure that /data/system/users/0/settings_system.xml
has system_locales field
baf62da
to
a75b756
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added small comment about wording in the popup dialog. Otherwise looks good 👍
<h2 className="localization-change-title"> | ||
Are you sure you want to change the localization to <i>{locale.Description}</i>? | ||
</h2> | ||
<p className="localization-change-subtitle">This action will reset the device.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"reset" is a wrong wording here. This may indicate we want to clear the device settings or something while we only want to reboot the device. I'd rather state it
"Changing localization requires rebooting the simulator"
This PR introduces a functionality for changing device localization on ios.
Screen.Recording.2024-09-10.at.17.51.32.mov