mobile-sdk icon indicating copy to clipboard operation
mobile-sdk copied to clipboard

Add no-translate-tilemask to setLanguage

Open jaakla opened this issue 6 years ago • 1 comments

Current basemap layer language selection of SDK allows to set 2 parameters: "language" and "fallbackLanguage", where you set language code (e.g. "es" for Spanish) to either of them, and it will try to use name:es instead of name then. Different configurations how to use them:

  1. Default in style, happens if no language is set in app: language: en. fallbackLanguage:en. Tries to provide maximum English map globally, if name is found in en, then this is used, if not then "name" tag is used. The problem is that in local level city names, and sometimes even street names will be shown everywhere in English. This is how CARTO web basemaps work.
  2. Localized, with fallback in local language: language:es fallbackLanguage:'' (none). It gets Spanish map, but the issue is that strange placenames in Asia, Arabic countries etc will have local names mostly in local scripts, unless someone has provided Spanish name with name:es, with proper translation or some kind of romanization. Local asian names (Chinese, Japanese, Korean, Taiwanese etc) are quite unreadable and useless for most travellers. In the same time many strange Asian scripts are already translated or romanized as English name, as name:en tag, so why the map could not use these names?
  3. Localized, with fallback in English: language:es fallbackLanguage:en. Now this gives Spanish names where Spanish names are available (e.g. country names), and if instead English is available, then this is used. This gives nice results in Asia, but it will have issues in Spain, where some placenames (especially city names) are often translated to English, but not to Spanish, now these will be shown in English, not in Spanish, and this is probably even bigger issue than option 2. above. Remember that in OSM name tagging schema it is assumed that default "name" tag content is anyway in local language, and name:es is obsolete and is generally not used as duplicate.

So there is no perfect configuration in current SDK: local app wants to set preferred local language, and it will not be translated to English locally, but is translated to English in other countries.

Solution proposal: add optional parameter noTranslateTilemask to setLanguage method in SDK (renderer). This tilemask would define specific map area (polygon) where names are not translated, and default "name" tag is used. In the sample of Spanish, this would define all Spanish-speaking countries. Then the preferred configuration would be setLanguage("es",tilemaskOfSpanishWorld) and setFallbackLanguage("en"). This will give 1. "name" values in Spanish countries 2. English name outside this as fallback language 3. if name:en is not available then local name also outside. So in Spain map is in Spanish, and only outside in English in general.

Alternative option would be to set suitable languages for names during vector tile generation, so current "es"+"en" combination would just work: i.e. Spanish names in Spanish countries should have always 2 tags: name and name:es with same content. This way this feature would not be needed. But this preparation is complex in data management point of view, and increases data size.

Customer ticket related to this: https://cartodb.supportbee.com/tickets/16662455

jaakla avatar Apr 12 '18 12:04 jaakla

Note that for web raster basemaps we'd need anyway vector tile transformation to have good multi-language support: https://github.com/CartoDB/mobile-tileserver-mbtiles/issues/22 . So if this will be implemented, then no change is needed in SDK at all.

jaakla avatar Apr 12 '18 12:04 jaakla