Repository navigation
fix(android): keep the route language when the SDK reroutes - #37
Open
alternacrow wants to merge 1 commit into
Open
alternacrow wants to merge 1 commit into
alternacrow wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the SDK reroutes after the user goes off route on Android, the Directions request drops the
languageof the original route and falls back tolanguage=en. Guidance that started in Japanese switches to English mid-trip.Captured from
logcatin an app that requested its route withlanguage: 'ja'andunits: 'metric':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
RNMBXNavigationSessionnever sets aRerouteOptionsAdapter, so the reroute options are whatever the SDK builds, and the originalRouteOptions.language()is not part of them.Fix
Register a
RerouteOptionsAdapterthat 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:
language=jaBuilt 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