NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

Hi,

I've successfully installed an OSM tileserver following the switch2osm tutorial and using the OSM-Bright style. All the labels are in the country original language, but I need my server to be able to serve tiles in differents languages, depending of the current user locale, falling back to English or country language if the name is not found in his locale.

How do I do that? I've seen some posts relative to internationalization, talking about a "name:en" column in the planet_osm_point table, but I don't have it in my db (although I used the --hstore option with osm2pgsql). Is that normal?

Thanks!

asked 11 Jul '18, 14:31

voharunado's gravatar image

voharunado
665510
accept rate: 0%

I have successfully installed an OSM tile server using ubuntu Image. but I would like to render tiles in three languages. any pointers will be helpful.

(31 Jul '19, 17:14) singhy

@singhi: I've converted your question into a comment since it is not an answer to the original question.

It would probably best if you started a new question and explained where you still need help after reading all the hints on this page and the linked ones. I mean all the answers and comments here talk about setting up rendering of tiles for multiple languages and you still ask for pointers.

(31 Jul '19, 21:39) TZorn

Hi TZorn, I have also setup a tile server for a default language. I am looking for a similar solution as voharunado however I would like to have language name in the URL so user can select the language of choice. and the application render the language specific tiles.

(01 Aug '19, 08:37) singhy

You have the names in your tags column if you used the --hstore option.

It is therefore possible to change your SELECT statements from something like e.g.

SELECT name, highway, way FROM planet_osm_line

to

SELECT COALESCE(tags->'name:fi', tags->'name:en', tags->'int_name', name) as name, highway, ...

which would then, in this example, prefer a Finnish name if set, then the English name, then the international name, an then the local name.

You have to make separate copies of your style for every language you wish to support, and set up separate URLs. Since you are producing raster tiles where labels are inseparatable from other content, you will need separate tile caches for each style, and you will want to pre-render each style on low zoom levels too.

This is only practicable if you are supporting a small number of languages.

If you want to be able to support "any language", you will have to change your approach altogether and use a vector tile based solution.

permanent link

answered 11 Jul '18, 15:53

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

Thanks Frederik. It works, I was trying to access it with the column name "name:fr"... I didn't understand this thing at all.

I need to support 6 languages (including english) but it could increase in the future. If vector tiles is not a lot more complicated, I'll probably go for that if it allows me to have a more evolutive server. But is the osm-bright style compatible with vector tiles? And do you have a link to a tutorial like switch2osm to learn how to use vector tiles please?

(11 Jul '18, 17:03) voharunado
1

A vector tiles setup is decidedly more complicated. The OSM Bright you have is not a vector tile style, but free vector tile styles exist that look similar. Most toolchains that produce vector tiles use an awful lot of Javascript-based components. Check out openmaptiles.org. You also need to decide whether you will serve vector tiles to the client and have them rendered there (requires even more Javascript on the client side) or whether you want to convert to raster tiles on the fly server-side. There's no tutorial I know of, but the makers of switch2osm would surely welcome a write-up once you've conquered the topic ;)

(11 Jul '18, 18:16) Frederik Ramm ♦

We've considered openmaptiles.org but we are looking for a less expensive solution, that's why we're making our own server. I'm not sure I'll be able to write any tutorial about the subject, it looks really more complicated to setup and I'll probably don't have the time to do this :) If 6 languages is ok to serve with raster tiles, I think it's better if we stay with that.

Thanks again!

(12 Jul '18, 09:54) voharunado

The whole openmaptiles.org stack is available as Open Source and you can install it yourselves like the raster tile stack.

(12 Jul '18, 09:57) Frederik Ramm ♦

Oh yes, what I've tried is the very easy setup docker image available on openmaptiles.org, which required a subscription to get fresh data. So if I don't want to use this service, I need to setup my own tileserver-gl with a way to generate vector tiles? You just said it was more complicated and you didn't know any tutorial, but there is tutorials on openmaptiles.org and it seems very easy... So I think there is obviously something I don't understand...

(12 Jul '18, 10:35) voharunado

Using COALESCE give me some strange results : I'm requesting some Paris tiles in french, so for that I'm doing COALESCE(tags->'name:fr', tags->'name:en', tags->'int_name', name). But as you can see on the picture below, it sometimes shows both english and french names (like "Paris 18e Arrondissement" is the french name, and "18th Arrondissement" the english name).

alt text

Why? I suppose it is because there is two differents labels for the same thing, but one with no french name... How do I prevent that? Is there a way to use directly the "name" attribute if the requested language is the language of the place we are looking at? (seems a bit tricky when writing this...)

Thanks!

permanent link

answered 12 Jul '18, 11:55

voharunado's gravatar image

voharunado
665510
accept rate: 0%

1

Most likely you have a place=suburb node with a French name and boundary=adminsitrative polygon without, or vice versa. The doubling of place names can be a problem even when you're not playing with languages. It is possible to analyse the situation in SQL and decide not to render a label in certain cases, but not easy and makes rendering slower. Yes it is possible to have different rendering rules depending on where in the world you are but this, also, slows down rendering a bit. See e.g. this SELECT statement in the old MapQuest style: https://github.com/MapQuest/MapQuest-Mapnik-Style/blob/updates2/mapquest_inc/layer-streetnames-eu.xml.inc#L569-L587 - combine this with an SQL CASE statement and you could do something that prefers name over name:en in France, but name:en over name in China.

(12 Jul '18, 12:35) Frederik Ramm ♦

Thanks again Frederik! I don't really need that much info on my map, so I will disable the display of one of them and see what happens, it will probably be faster

(12 Jul '18, 13:23) voharunado

Actually the problem is bigger than expected, some of the Paris suburbs have a name:fr, some other have not. So even if I keep only these ones, I still have a problem because the names aren't always in the same language.

I've looked at the link you gave me, but I don't understand what this statement does. I don't have a "country_polygon_detail" table so I don't understand what I need to do to get the current country code...

(12 Jul '18, 15:24) voharunado
2

The link was meant as an illustration of how you have to do it basically, not something you can just copy and it works. Basically you need a table that contains the outlines of areas for which you want to have special casing, and then you need to join the OSM feature table with that table on geometry to find out which of your areas of interest the feature is in. You could generate that area-of-interest table from your existing planet_osm_polygon by picking out the requisite admin_level=2 boundaries but you should definitely apply simplification to keep perfomance acceptable.

(12 Jul '18, 15:33) Frederik Ramm ♦

Actually all area are of interest for us, we need to display the best name possible for all of our clients, depending on their language. It definitely looks a bit tricky so I'll probably look for another way to get over this issue. Thanks for your help!

(12 Jul '18, 15:50) voharunado
1

Actually the problem is bigger than expected, some of the Paris suburbs have a name:fr, some other have not.

You can always pre-process the data so that (for example) within the area of France "name:fr" is always populated with something (from "name "if "name:fr" was blank).

As an example, this script is part of the process to create the maps behind this map, and on there "name:cy", "name:en" or "name:gd" will be used as "name" depending on location. You may actually want to do the reverse of that (set "name" to "name:fr" in a defined area) but the principle is the same.

(12 Jul '18, 17:38) SomeoneElse ♦

Thanks SomeoneElse it looks great, I'll try that!

(13 Jul '18, 09:07) voharunado
showing 5 of 7 show 2 more comments

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×204
×72
×16

question asked: 11 Jul '18, 14:31

question was seen: 4,581 times

last updated: 01 Aug '19, 08:37

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum