komoot / leaflet.photon

Apache License 2.0
50 stars 13 forks source link

Providing a translation for the given osm values #5

Open Haves1001 opened 9 years ago

Haves1001 commented 9 years ago

I did use this plugin to implement a search on my leaflet map. I'm not totally sure if I should post this here or on the "main" photon github page.

As you can see on the following picture I am trying to display the information of the search result in german (and any other language the user wants to). Unfortunately all key which start with "osm_" (http://photon.komoot.de/api/?q=berlin&lang=de) won't be "translated". image

I guess this is because they come directly from osm? I don't know what is the best approach to translate those values, but I definitely would like to use them in the search result, as the information that the shown result is a city might be essential for the user. If you see a way how this could be resolved best, I would be glad to help/support with it.

christophlingg commented 9 years ago

I can give you a hand on the implementation, but I will give @yohanboniface some time to answer, he did all the work on this leaflet plugin. For some weeks we also have a new information at the search results: state. I would also add it. Probably it is quite easy when you are changing it anyway.

Haves1001 commented 9 years ago

So you agree that it would be best to change leaflet.photon and not the output of photon itself? Maybe it is possible to (re)use localised strings from other projects like iD, as it would be best to provide as many translations as possible.

christophlingg commented 9 years ago

Hm, that's difficult. On the one hand it would make sense to modify the output of photon, because the other features are translated too, like name, city, country ...

On the other hand these classifications are immutable information similar to the osm_id. Imagine you want to display a house icon if osm_key is house, you don't want to translate osm_keys back to english.

So I would do it in the leaflet plugin.

Haves1001 commented 9 years ago

Ok that is good. That were the exactly same thoughts as I had.

Do you maybe know an already established service for translating these key-value combinations?

christophlingg commented 9 years ago

ok, this is not making our lives easier: I checked all possible osm key / value pairs that exist in nominatim, there are more than 30 thousands combinations:

https://gist.github.com/christophlingg/c5abfda1019ea0eb35ce

lonvia commented 9 years ago

The osm website has a long list of translated descriptions for key/value pairs in their localization files. (e.g English version starts here, other languages are in the same directory).

I'd love to see this part of the localizations move to their own project one day, so that it is easier to use them in other projects (and also to remove myself as a bottleneck in including new key/value pairs to be translated). There is an related issue here: https://github.com/openstreetmap/openstreetmap-website/issues/80

lonvia commented 9 years ago

@christophlingg Indeed, but with around 2000 of them most of the data is covered. The long tail are typos and oddities.

lonvia commented 9 years ago

To add to that: there are very few keys, so any key/value combinations that are unknown can be mapped to a general description for that key, e.g. amenity=blue_sky is sufficiently described by 'Amenity'.

yohanboniface commented 9 years ago

@Haves1001 if I get your correctly, I think the best approach is to provide a formatType option, as explained in the README. This should be a function that takes the raw value as input and provide the translated string as output.

I'm not sure this kind of feature as to be in the Leaflet.Photon itself (in the sense that every one will have its own translation needs), as soon as the plugin gives you a way to take control of it.

Haves1001 commented 9 years ago

Mhh this really seems to be harder than expected. And I would agree @yohanboniface that the whole translation thing could be an overkill for the leaflet photon plugin itself.

@lonvia , @christophlingg : Maybe the best approach would be to create some kind of new repository where you would use the localisation files from openstreetmap-website/.../locales to create some kind of library (Javascript, PHP ...)?