Skip to content

fix(android): keep the route language when the SDK reroutes - #37

Open
alternacrow wants to merge 1 commit into
rnmapbox:mainfrom
alternacrow:fix/reroute-language
Open

alternacrow wants to merge 1 commit into
rnmapbox:mainfrom
alternacrow:fix/reroute-language

Conversation

@alternacrow

Copy link
Copy Markdown

Problem

When the SDK reroutes after the user goes off route on Android, the Directions request drops the language of the original route and falls back to language=en. Guidance that started in Japanese switches to English mid-trip.

Captured from logcat in an app that requested its route with language: 'ja' and units: 'metric':

api.mapbox.com/directions/v5/mapbox/driving-traffic/...
  context=reroute & reason=deviation
  language=en          <- dropped
  voice_units=metric   <- carried over

The maneuver banner changes from 「左方向です」 to "Turn left" at that point. iOS keeps the language across a reroute under the same steps, so this is Android-only.

Cause

RNMBXNavigationSession never sets a RerouteOptionsAdapter, so the reroute options are whatever the SDK builds, and the original RouteOptions.language() is not part of them.

Fix

Register a RerouteOptionsAdapter that copies the language of the route guidance is currently following into the reroute options. Routes requested without a language are returned unchanged, so this is a no-op for apps that never set one.

Verification

Same app and steps, with the patch applied and the app rebuilt:

  • reroute request now carries language=ja
  • the maneuver banner stays Japanese across the reroute (「左方向です」「その先 西仲通り」)

Built with Expo SDK 58 / React Native 0.88, NDK 27.1.12297006, @rnmapbox/navigation@0.1.2, Mapbox Navigation SDK v3.33.0.

🤖 Generated with Claude Code

The Android SDK does not carry the original route's `language` into the
reroute request, so after going off route the Directions request falls
back to `language=en` and guidance switches to English mid-trip.
`voice_units` is carried over, `language` is not.

Register a `RerouteOptionsAdapter` that copies the language of the route
guidance is following into the reroute options. Routes requested without
a language are unaffected.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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