Skip to content

feat: support locale when launching apps#181

Merged
gmegidish merged 1 commit intomainfrom
feat-support-locale
Mar 3, 2026
Merged

feat: support locale when launching apps#181
gmegidish merged 1 commit intomainfrom
feat-support-locale

Conversation

@gmegidish
Copy link
Member

No description provided.

@coderabbitai
Copy link

coderabbitai bot commented Mar 3, 2026

Walkthrough

This pull request adds locale support for app launches across the CLI and device implementations. A new --locale CLI flag is introduced to accept comma-separated BCP 47 locale tags. These locales are parsed, propagated through the AppRequest struct, and passed to the device's LaunchApp method. The ControllableDevice interface is updated to include a locales parameter. Each device implementation handles locales differently: Android validates and applies them via adb shell commands, iOS and Simulator pass them as launch arguments, and Remote includes them in RPC payloads.

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No description was provided by the author, making it impossible to assess whether the description relates to the changeset. Add a pull request description explaining the purpose of adding locale support for app launches and any relevant implementation details or context.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: support locale when launching apps' directly and clearly describes the main change: adding locale support to app launch functionality across multiple device implementations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-support-locale

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@devices/android.go`:
- Around line 268-280: LaunchApp attempts to call "cmd locale set-app-locales"
without checking Android API level; add an API-level check in
AndroidDevice.LaunchApp before calling d.runAdbCommand to ensure the device SDK
>= 33, and if not either skip setting locales gracefully or return a clear error
stating the command requires Android 13/API 33+. Implement this by querying the
device SDK (e.g., via adb:
d.runAdbCommand("shell","getprop","ro.build.version.sdk") or an existing helper
like a GetAPILevel/GetSdk method), parse the integer, compare against 33, and
only call set-app-locales when the check passes; keep the existing locale
validation (validLocaleTag) and preserve the original error formatting when the
adb call is performed.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between ac7930b and ba3359d.

📒 Files selected for processing (8)
  • cli/apps.go
  • cli/flags.go
  • commands/apps.go
  • devices/android.go
  • devices/common.go
  • devices/ios.go
  • devices/remote.go
  • devices/simulator.go

Comment on lines +268 to +280
func (d *AndroidDevice) LaunchApp(bundleID string, locales []string) error {
if len(locales) > 0 {
for _, l := range locales {
if !validLocaleTag.MatchString(l) {
return fmt.Errorf("invalid locale tag: %q", l)
}
}
localeArg := strings.Join(locales, ",")
output, err := d.runAdbCommand("shell", "cmd", "locale", "set-app-locales", bundleID, "--locales", localeArg)
if err != nil {
return fmt.Errorf("failed to set app locales for %s: %v\nOutput: %s", bundleID, err, string(output))
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check for version handling in android.go and devices/
echo "=== Checking for version/API level handling ==="
rg -n "getprop.*version|API|api.*level|android.*13|android.*33" devices/android.go
echo ""
echo "=== Broader search in devices directory ==="
rg -n "API|api.*level|version.*check" devices/ -A 2 -B 2

Repository: mobile-next/mobilecli

Length of output: 2509


🌐 Web query:

Android cmd locale set-app-locales minimum API level requirement

💡 Result:

adb shell cmd locale set-app-locales ... requires Android 13 (API level 33) or higher, because it’s implemented by the platform LocaleManager service/API (added in API 33). On Android 12L / 12 / earlier (API ≤ 32), the command isn’t available. [1], [2]

If you need similar behavior on older versions, you must use the AndroidX/AppCompat per-app language APIs (backport) instead. [3]

Sources: [1], [2], [3]


🏁 Script executed:

#!/bin/bash
# Get full context around LaunchApp function
sed -n '260,290p' devices/android.go

Repository: mobile-next/mobilecli

Length of output: 1095


Add Android API level check before calling set-app-locales command.

The cmd locale set-app-locales command requires Android 13 (API level 33) or higher. The current implementation will fail silently on older Android versions with an unclear error message from adb. Add a version check before executing this command, either to skip locale setting gracefully or provide a more informative error message explaining the Android version requirement.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@devices/android.go` around lines 268 - 280, LaunchApp attempts to call "cmd
locale set-app-locales" without checking Android API level; add an API-level
check in AndroidDevice.LaunchApp before calling d.runAdbCommand to ensure the
device SDK >= 33, and if not either skip setting locales gracefully or return a
clear error stating the command requires Android 13/API 33+. Implement this by
querying the device SDK (e.g., via adb:
d.runAdbCommand("shell","getprop","ro.build.version.sdk") or an existing helper
like a GetAPILevel/GetSdk method), parse the integer, compare against 33, and
only call set-app-locales when the check passes; keep the existing locale
validation (validLocaleTag) and preserve the original error formatting when the
adb call is performed.

@gmegidish gmegidish merged commit 9b5cb7e into main Mar 3, 2026
15 checks passed
@gmegidish gmegidish deleted the feat-support-locale branch March 3, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant