mapbox / mapbox-navigation-ios

Turn-by-turn navigation logic and UI in Swift on iOS
https://docs.mapbox.com/ios/navigation/
Other
863 stars 313 forks source link

Can't set custom locale and distanceMeasurementSystem in route options #2783

Open JanetKao opened 3 years ago

JanetKao commented 3 years ago
  1. Setting Langeage Chinese ,it always speaks English. routeOptions.includesSteps = true routeOptions.includesSpokenInstructions = true routeOptions.locale = Locale(identifier: "zh-Hans") 2.If I set langeage , unit can't change KM and MILE. routeOptions.includesSpokenInstructions = true routeOptions.includesSteps = true routeOptions.distanceMeasurementSystem = usesMetric ? .metric : .imperial
stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

S2Ler commented 3 years ago

This is probably due to https://github.com/mapbox/mapbox-navigation-ios/blob/19b637deac80f9240dd846e7ccb8b517e88e0fa5/MapboxCoreNavigation/NavigationRouteOptions.swift#L135-L136

I'm trying to find out the reason for this code.

1ec5 commented 3 years ago

I don’t think that code is at issue. It only gets called in the initializer of NavigationRouteOptions, but it looks like the code above is setting the measurement system after initialization.

1ec5 commented 3 years ago

Setting Langeage Chinese ,it always speaks English.

The problem is that zh-Hans is a written locale (Simplified Chinese) while the Voice API expects a spoken locale of cmn-CN (Mandarin in Mainland China). The Directions API doesn’t realize that Simplified Chinese text can be used for Mandarin text-to-speech, so it returns English instructions. mapbox/locale-utils#7 tracks adding a fallback from Mandarin to Chinese to fix this issue on the server side.