<br><br><div class="gmail_quote">On 25 April 2010 11:36, Claudius Henrichs <span dir="ltr"><<a href="mailto:claudius.h@gmx.de">claudius.h@gmx.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">



  
  

<div bgcolor="#ffffff" text="#000000">
Am 25.04.2010 11:25, Alexander Sidorov:
<div><div></div><div class="h5"><blockquote type="cite">Hello!<br>
  <br>
Is there any way to implement the following localization strategy:<br>
1. display russian (russian is just for example) name if it exists<br>
2. display english name if russian name doesn't exists<br>
3. display local name otherwise<br>
  <br>
The problem for me is to determine which language is used for some
region by default. I have found <a href="http://wiki.openstreetmap.org/wiki/Talk:Proposed_features/Language_of_this_element" target="_blank">this
discussion</a> but without solution. <br>
</blockquote></div></div>
There's currently no way to determine what language the "name"-tag is
in.<br>
<br>
Your question doesn't seem to be a tagging one though, because as I
understand you want to have different rendered outputs, correct?<br>
Like John Smith explained this has to be done with some clever JOIN SQL
statements.<br>
<br>
Some further readings here [1] and an example of a rendering of the
world map in different languages here [2].<br>
<br>
Claudius<br></div></blockquote></div><br><br>Part of the problem will be solved with the hstore patch I suspect. But else, John is pretty much right, the SQL can be interesting to write. I think a basic SQL statement would start like this. This is not real SQL code since I don't have the name of the table in mind. Also I am keeping in mind more of a simple osmosis schema for a just a russian extraction of name. This is not meant to be used to extract all countries in the world. If I was do that I would then use a slightly different approach:<br>
<br>SELECT ( CASE <br>                     WHEN nt1.v IS NOT NULL THEN nt1.v<br>                     WHEN nt2.v IS NOT NULL THEN nt2.v<br>                     ELSE nt.v<br>               END<br>              ) AS russianName<br>
FROM   node_tags AS nt<br>            LEFT OUTER JOIN<br>            node_tags AS nt1<br>                   ON <a href="http://nt1.id">nt1.id</a> = <a href="http://nt.id">nt.id</a> AND k = 'name:ru'<br>            LEFT OUTER JOIN<br>
            node_tags AS nt2<br>                   ON <a href="http://nt2.id">nt2.id</a> = <a href="http://nt.id">nt.id</a> AND k = 'name:en'<br>WHERE nt.k = 'name'<br><br>Here we go, we have a simple query to do as you asked. However, do keep mind that if the place is in Russia I wouldn't expect name:ru to actually exists since name should be containing the local name anyway. Of course, they are probably better way to do that. Among others things, creating a partial index on k = 'name:ru' and k = 'name:en' would speed up the query quite dramatically. <br>
The other approach would be to retrieve all name elements with a condition nt.k LIKE 'name%' and then perform a subquery on this afterwards. Similarly, creating a view with that information would prove quite useful. It is just down to imagination.<br>
<br>Emilie Laffray<br>