Types of Languages
The PTV OSM vector format supports localized and native names for location labels (like countries or cities) and street elements, if available.
- Native names represent the default language that is most common for the element in its native language. A town in Germany e.g. will have a native name in German.
- Localized names are the translated variants for different languages of the native name. Also, some non-standard transliterated names are provided by this field, see the next chapter for more details.
Example Tile Data
A typical entry in the tile data for the town name property looks like this (the binary tile data was converted to json to make it readable):
"properties": {
"name": "České Budějovice",
"name_da": "Ceske Budejovice",
"name_nl": "Ceske Budejovice",
"name_en": "Budweis",
"name_fi": "Ceske Budejovice",
"name_fr": "Ceske Budejovice",
"name_de": "Budweis",
"name_el": "Τσέσκε Μπουντεγιόβιτσε",
"name_el_latn": "Tseske Bountegiovitse",
"name_hu": "Ceske Budejovice",
"name_hu_latn": "Ceske Budejovice",
"name_it": "Ceske Budejovice",
"name_no": "Ceske Budejovice",
"name_pl": "Czeskie Budziejowice",
"name_pl_latn": "Czeskie Budziejowice",
"name_pt": "Ceske Budejovice",
"name_ru": "Ческе-Будеёвице",
"name_ru_latn": "Cheske-Budeyovitse",
"name_sk": "České Budejovice",
"name_sk_latn": "Ceske Budejovice",
"name_es": "Ceske Budejovice",
"name_sv": "Ceske Budejovice",
}
- The
name
field holds the native name (in this case in Czech language). This corresponds to the default language of the element. - The localized names are identified through the
name
tag plus an underscore followed by a BCP 47 language tag, e.g. `name_en` for english.
In the map styles only the native name is set. Switching the language must be done manually and will be described later.
Style Labels and Field Names
List of all used name tags and their corresponding style element:
Style label name | Field name | Localized names supported |
---|---|---|
LBL_Country_Big | name | X |
LBL_Country_Medium | name | X |
LBL_Country_Small | name | X |
LBL_State | name | X |
LBL_CityMajorCapital | name | X |
LBL_CityMajorVeryLarge | name | X |
LBL_CityMajorLarge | name | X |
LBL_CityMinorLarge | name | X |
LBL_CityMajorVillage | name | X |
LBL_CityMinorVillage | name | X |
LBL_Road | name | X |
LBL_Water | name | X |
LBL_Water_Linear | name | X |
LBL_WoodlandArea | name | X |
LBL_Park_State | name | X |
LBL_BuiltupArea | name | X |
Not all elements contain a localized name. Please note that localized names are optional for the styles that support them.
Supported Languages
If available we deliver a list of language alternatives for the native field name
:
IETF BCP 47 language tag | Language |
---|---|
bs | Bosnian |
bs-latn | Bosnian, transliterated |
bg | Bulgarian |
bg | Bulgarian, transliterated |
zh | Chinese |
cs | Czech |
cs-latn | Czech, transliterated |
da | Danish |
nl | Dutch |
en | English |
et | Estonian |
et-latn | Estonian, transliterated |
fi | Finnish |
fr | French |
de | German |
ga | Irish |
el | Greek, modern |
el-latn | Greek, modern, transliterated |
hi | Hindi |
hi-latn | Hindi, transliterated |
hu | Hungarian |
hu-latn | Hungarian, transliterated |
id | Indonesian |
it | Italian |
ja | Japanese |
ko | Korean |
ko-latn | Korean, transliterated |
lv | Latvian |
lv-latn | Latvian, transliterated |
lt | Lithuanian |
lt-latn | Lithuanian, transliterated |
no | Norwegian |
pt | Portuguese |
pl | Polish |
pl-latn | Polish, transliterated |
es | Spanish, Castilian |
ro | Romanian |
ro-latn | Romanian, transliterated |
ru | Russian |
ru-latn | Russian, transliterated |
hr | Croatian |
hr-latn | Croatian, transliterated |
sk | Slovak |
sk-latn | Slovak, transliterated |
sl | Slovenian |
sl-latn | Slovenian, transliterated |
sr | Serbian |
sr-latn | Serbian, transliterated |
sv | Swedish |
tr | Turkish |
tr-latn | Turkish, transliterated |
uk | Ukrainian |
uk-lazn | Ukrainian, transliterated |
ur | Urdu |
vi | Vietnamese |
th | Thai |
Switching Languages in MapLibreGL.js
All styles use the native name as default. Switching the native language to another language can be achieved by using the setLayoutProperty()
of MapLibre. The following example uses plain javascript and MapLibre expressions.
Example - Switching the name of the style element LBL_City to english (with fallback to the native name)
map.setLayoutProperty('LBL_CityMajorCapital', 'text-field', ['coalesce',['get','name_en'],['get', 'name']]);
['coalesce',['get','name_en'],['get', 'name']]
is a MapLibre expression. The ['coalesce',...]
statement returns the first element in the parameter list that is not null. So the statement ['get','name_en']
tries to retrieve the name_eng property for an element from the tile. If this property is null, coalesce will return the value of ['get', 'name'] as the native language fallback.