mapbox / locale-utils

0 stars 2 forks source link

Fallback from Arabic to Modern Standard Arabic #9

Open 1ec5 opened 4 years ago

1ec5 commented 4 years ago

The Mapbox Navigation SDKs for Android and iOS claim to support spoken instructions in Arabic and automatically request Arabic instructions if the application is being presented to the user in Arabic.

Every operating system including Android and iOS uses ISO 639’s inclusive code ar (or ara) to represent Arabic, and so does OSRM Text Instructions. Unfortunately, the Mapbox Voice API (via Amazon Polly) uses the more specific code arb, which technically represents only Modern Standard Arabic. This discrepancy reflects Polly’s focus on spoken language varieties versus OSRMTI’s focus on written varieties.

As with #7, there may need to be fallbacks in both directions to ensure interoperability.

/cc @mapbox/navigation-ios @mapbox/navigation-android @mapbox/language @danpaz

browndp08 commented 2 years ago

@1ec5 does the following test capture what you would expect to see as a fix for this issue?

t.equal(locale.bestMatchingLocale('ar', valhalla_language_codes), 'ar-AE')
t.equal(locale.bestMatchingLocale('ar', polly_language_codes), 'arb')

As I understand it, these would also need to be added to api-valhalla.

Note: valhalla ar-AE Polly arb

1ec5 commented 2 years ago

The first fallback already works, assuming valhalla_language_codes contains ar-AE but not ar or any other ar-*. (This package is written generically so that it can’t assume the UAE is the default region for Arabic.)

The second fallback is what’s tracked by this issue.