Skip to main content

Localization and internationalization

The Navigation SDK enables you to customize the language and units of measurement used by both text and voice instructions.

There are several default behaviors built into the Navigation SDK:

  • Language: The SDK will use the language defined in the device settings if it is available (see Supported languages below) for both the user interface and spoken instructions. Instructions are announced in English if they're not available in the user interface language.
  • Distance: The SDK gives distances in the predominant measurement system of the device system's region, which might not necessarily be the same region in which the device is traveling.
  • Time: The SDK will express units of time in the predominant system (either twelve or twenty-four-hour based) of the device system's region, which might not necessarily be the same region in which the device is traveling.
  • Local place names: The upcoming road or ramp destination is named according to the local or national language. In some regions, the SDK may give the name multiple languages.

You can override these defaults in the Navigation SDK, including:

  • Manually setting the language used in text and voice instructions.
  • Changing the units of distance used.
  • Changing how units of time are formatted.

If no language is specified, the Navigation SDK receives the defaults described above. To customize the language or units of measurement used in text and voice instructions, use the NavigationRoute.Builder class.

Supported languages

The following table lists the languages that are supported for user interface elements and spoken instructions.

LanguageUser interfaceSpoken instructionsMore info
ArabicDepends on the device; might require third-party text-to-speech
Bengali
BurmeseDepends on the device; might require third-party text-to-speech
Chinese-
Mandarin
Depends on the device; might require third-party text-to-speech
Czech-
Danish
English
EsperantoDepends on the device; might require third-party text-to-speech
FinnishDepends on the device; might require third-party text-to-speech
French
Galician
German
HebrewDepends on the device; might require third-party text-to-speech
HungarianDepends on the device; might require third-party text-to-speech
IndonesianDepends on the device; might require third-party text-to-speech
Italian
Japanese
Korean
Norwegian
Polish
Portuguese
Romanian
Russian
SlovenianDepends on the device; might require third-party text-to-speech
Spanish
Swedish
Turkish
UkrainianDepends on the device; might require third-party text-to-speech
VietnameseDepends on the device; might require third-party text-to-speech
YorubaDepends on the device; might require third-party text-to-speech
Speech engine
For languages marked with Depends on the device; might require third-party text-to-speech, instructions are provided by the Navigation SDK, but it's not guaranteed that the given device will have the appropriate TextToSpeech speech engine installed to pronounce these instructions correctly.

Add a localization

Read the Navigation SDK's contributing guide for detailed instructions on adding a new localization or improving an existing localization.

Voice instruction sources

Turn-by-turn instructions are primarily designed to be announced by either the Mapbox Voice API or by the Android system's TextToSpeech. By default, the Navigation SDK uses the Mapbox Voice API, which requires an internet connection at various points along the route. If the Voice API lacks support for the turn-by-turn instruction language or there is no internet connection, the TextToSpeech system announces the instructions instead.

Customization

You can override the default language, units of distance, and time format used in instructions when building your route request.

Set text instructions language

To retrieve text instructions in a language other than the device's user interface language, pass the desired language through the RouteOptions.builder()'s RouteOptions builder as you request routes.

If you set a custom language, true must be passed though the steps() method. This true ensures that the Directions API response includes turn-by-turn instructions.

Set the text instructions language:

mapboxNavigation.requestRoutes(
RouteOptions.builder()
.accessToken(mapboxAccessToken)
.coordinates(coordinateList)
.profile(directionsProfile)
.steps(true)
.language(languageCode)
.build()
)

Set voice instruction units of measurement

To override the measurement system used in spoken instructions, pass the desired language through the RouteOptions.builder()'s voiceUnits() method when you request routes.

The units can either be DirectionsCriteria.IMPERIAL (the Navigation SDK's default) or DirectionsCriteria.METRIC.

If you set a desired unit, true must be passed through both the steps() and voiceInstructions() methods.

Set the units to imperial:

mapboxNavigation.requestRoutes(
RouteOptions.builder()
.applyDefaultNavigationOptions()
.applyLanguageAndVoiceUnitOptions(this)

Format time

The NavigationOptions's builder has a .timeFormatType() method, which defines the format for the remaining trip time. The method takes either the TWELVE_HOURS (11.00PM), TWENTY_FOUR_HOURS (23.00), or NONE_SPECIFIED constant. NONE_SPECIFIED means the format will be defined by the device's current settings independent from your project. The Navigation SDK uses NONE_SPECIFIED if no format is passed through .timeFormatType().

Set the format:

val navigationOptions = NavigationOptions.Builder()
.timeFormatType(TWENTY_FOUR_HOURS)
.build()

Then use the NavigationOptions object when you initialize the MapboxNavigation object.

Was this page helpful?