< Osmarender

Osmarender/LocalizedMaps

How to

To add ability of selecting particular language to render labels in. You need to make next changes to osmarender.xsl:

Add line

<xsl:variable name="preferredLanguage" select="/rules/@preferredLanguage" />

before

 <xsl:template match="/rules">

In template renderText

 <xsl:template name="renderText">

add line

 <xsl:variable name="preferredText" select="concat($instruction/@k, ':', $preferredLanguage)" />

after other parameters declaration replace

 <xsl:value-of select="tag[@k=$instruction/@k]/@v"/>

with

 <xsl:choose>
    <xsl:when test="tag[@k=$preferredText]">
        <xsl:value-of select="tag[@k=$preferredText]/@v"/>
     </xsl:when>
     <xsl:otherwise>
         <xsl:value-of select="tag[@k=$instruction/@k]/@v"/>
     </xsl:otherwise>
  </xsl:choose>

In template textPath

 <xsl:template match="way" mode="textPath">

add

 <xsl:variable name="preferredText" select="concat($instruction/@k, ':', $preferredLanguage)" />

after specification of parameters replace

 <xsl:value-of select='tag[@k=$instruction/@k]/@v'/>

with

<xsl:choose>
    <xsl:when test="tag[@k=$preferredText]">
        <xsl:value-of select="tag[@k=$preferredText]/@v"/>
    </xsl:when>
    <xsl:otherwise>
        <xsl:value-of select='tag[@k=$instruction/@k]/@v'/>
    </xsl:otherwise>
 </xsl:choose>

after this you can to specify preferred language in your rules file as attribute to rules tag

<rules preferredLanguage="be">

Question

I'd like to include this in standard version of osmarender, but I don't know is it ok. This code does not change anything if language is not specifiied. Also it shows default text if text with this language is absent.--LEAn 12:29, 6 June 2008 (UTC)


Alternative method

An alternative but less sophisticated method can be seen at Localized maps with Osmarender‎.

This article is issued from Openstreetmap. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.