Map localization in Carto Mobile SDK

181 views Asked by At

Does anybody know whether it is available to localize captions of the map objects using Carto Mobile SDK? And if it is possible, how can I obtain it?

For example, I would like to see "Kazakhstan" instead of "Казахстан", however caption above the objects depends on country language where object is located. I want make it localized into, let me say, English. Click the link to see screenshot.

Just in case it is useful and can help: I am using Xamarin.iOS platform. Version of Carto Mobile SDK - 4.0.2.

Thank you in advance.

1

There are 1 answers

0
JaakL On BEST ANSWER

CartoVectorTileLayer (both CartoOnlineVectorTileLayer and CartoOfflineVectorTileLayer are subclasses of it) has method setLanguage(String) for it, so e.g.:

layer.setLanguage("en");

will give you English language maps.

In SDK 4.0.2 SDK and nutiteq.osm tile source you can use following languages: local/default (will give Казахстан in your case), en, es, de, fr, it, ru, zh (Chinese), tr (Turkish) and et (Estonian) as language

From CARTO SDK 4.1.0 and new carto.streets source you can use any OSM language. I would suggest to configure map based on device language settings, with something like:

// Android
layer.setLanguage(Locale.getDefault().getLanguage());

// iOs / Xamarin
layer.Language = Foundation.NSLocale.PreferredLanguages[0].Substring(0, 2);

What if specific name is not available in given language? Then the MapView will fallback to 'local' language by default, the map will not be empty. But if the 'local' language is still unreadable, so I'd prefer latin alphabet names? In SDK 4.1.0 you can configure primary and secondary fallback languages, e.g. you set primary language to 'de' for Germans, then to avoid strange alphabets (say Hebrew, Greek, most of Asia) set 'en' as primary fallback; then local is used only if both your primary and English names are missing.