[Marble-devel] Review Request 124744: Placemark localization for (OSM) vector rendering

Dennis Nienhüser dennis at nienhueser.de
Sat Aug 15 13:02:08 UTC 2015


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/124744/
-----------------------------------------------------------

Review request for Marble.


Bugs: 351325
    http://bugs.kde.org/show_bug.cgi?id=351325


Repository: marble


Description
-------

In OpenStreetMap names of places are usually denoted in the local language. Variants of a name translated into other languages can be added. In most situations it is desirable to display the name in the local language of the viewer of the map, not the local language of the placemark.

For example, the following placemark exists in Budapest:
name => Magyar Nemzeti Bank
name:de => Ungarische Nationalbank
name:en => Hungarian National Bank
name:es => Banco Nacional de Hungría
name:fr => Banque nationale hongroise

On a device with a hungarian locale (QLocale::system::uiLanguages() reports some 'hu' variant), the placemark should be displayed as "Magyar Nemzeti Bank". A German system should display "Ungarische Nationalbank". For an italian system a proper translation is missing, but it might be preferrable to display the english variant "Hungarian National Bank" instead of the local one.

To implement this, we need to
- determine the language code of the placemark: Which country do the placemark's coordinates belong to, what is its locale?
- come up with a list of acceptable display locales. This can likely be extracted from QLocale::system::uiLanguages(), which already includes a preference order.
- Choose the best (in order of preference) translation alternative and display that

Re-using the example above and an italian device, this might result in
- language code of the placemark: 'hu'
- acceptable display locales: ('it', 'en', 'es')
- mapping: ('it' => N/A, 'en' => 'Hungarian National Bank', 'es' => 'Banco Nacional de Hungría')
- the displayed name would become 'Hungarian National Bank' as the most preferred variant

If no mapping is found (e.g. for a chinese device that only reports ('zh') as acceptable locales), the original name should be chosen.

This is a proof-of-concept implementation to localize OSM placemarks in vector rendering. It has a hard-coded preference of German placemark names. The patch is not meant to be committed, but instead meant for discussion and to provide a jump-start for whoever wants to implement [task 351325](https://bugs.kde.org/show_bug.cgi?id=351325).


Diffs
-----

  src/lib/marble/PlacemarkLayout.cpp a4a2c40 
  src/lib/marble/VisiblePlacemark.cpp 2fdc8ec 
  src/lib/marble/geodata/data/GeoDataPlacemark.h ad9f434 
  src/lib/marble/geodata/data/GeoDataPlacemark.cpp 9edaa84 

Diff: https://git.reviewboard.kde.org/r/124744/diff/


Testing
-------

The patch can be tested by opening any .osm file with Marble. Download e.g. [Budapest.osm](http://nienhueser.de/marble/Budapest.osm) or [Shanghai.osm](http://nienhueser.de/marble/Shanghai.osm) and open it to see some translated placemarks.


File Attachments
----------------

Hungarian locale rendering
  https://git.reviewboard.kde.org/media/uploaded/files/2015/08/15/52f287fa-481d-4013-b8a8-962eea0a2e7f__marble-budapest-hu.png
German locale rendering
  https://git.reviewboard.kde.org/media/uploaded/files/2015/08/15/23d5ea78-dc3c-48fb-9410-833e7a8c4fca__marble-budapest-de.png


Thanks,

Dennis Nienhüser

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/marble-devel/attachments/20150815/5add075e/attachment.html>


More information about the Marble-devel mailing list