/plugins/keyvalue_dictionary
A keyvalue_dictionary can be configured in the locale. The keyvalue_dictionary plugin method will parse the mapview.locale for properties with key/value pairs matching entries in the dictionary. The property value will be replaced with a language lookup in the dictionary or the default value.
"keyvalue_dictionary": [
{
"key": "name",
"value": "OSM",
"default": "OpenStreetMap",
"uk": "Sława OpenStreetMap 🇺🇦"
}
]
Methods
(inner) isArrayObject(item, dictionary) → {boolean}
Checks if an item is an array or an object and recursively applies the parsing logic.
Name | Type | Description |
---|---|---|
item | * | The item to check. |
dictionary | Array | An array of dictionary entries. |
Returns true if the item is an array or an object, false otherwise.
- Type:
- boolean
(inner) keyvalue_dictionary(keyvalue_dictionary, mapview)
Replaces key-value pairs in the mapview locale object with dictionary entries.
Name | Type | Description |
---|---|---|
keyvalue_dictionary | Array | An array of dictionary entries. |
mapview | mapview | The mapview object. |
Name | Type | Description |
---|---|---|
mapview.locale | Object | The locale object of the mapview. |
(inner) parseObject(obj, dictionary)
Parses an object and replaces its string values with dictionary entries.
Name | Type | Description |
---|---|---|
obj | Object | The object to parse. |
dictionary | Array | An array of dictionary entries. |
(inner) replaceKeyValue(obj, key, value, dictionary)
Replaces a key-value pair in an object with a dictionary entry.
Name | Type | Description |
---|---|---|
obj | Object | The object containing the key-value pair. |
key | string | The key of the value to replace. |
value | string | The value to replace. |
dictionary | Array | An array of dictionary entries. |