From 66ea17f51829e610d84a2eff22ea391986e1e194 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Wed, 26 Jul 2017 09:13:56 +0200 Subject: [PATCH] Twig filter 'keyTrans()' --- README.md | 3 ++- src/tagTranslations.js | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9082004e..fe81e853 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,8 @@ The following properties are available: * const.* (Values from the 'const' option) There are several extra functions defined for the TwigJS language: -* function `tagTrans`: return the translation of the given tag. Parameters: key (required, e.g. 'amenity'), value (optional, e.g. 'bar'), count (optional, default 1). If no value is set, the translation of the key will be returned. +* function `keyTrans`: return the translation of the given key. Parameters: key (required, e.g. 'amenity'). +* function `tagTrans`: return the translation of the given tag. Parameters: key (required, e.g. 'amenity'), value (required, e.g. 'bar'), count (optional, default 1). * function `tagTranList`: return the translations of the given tag for tags with multiple values separated by ';' (e.g. 'cuisine'). Parameters: key (required, e.g. 'cuisine'), value (required, e.g. 'kebab' or 'kebab;pizza;noodles;burger'). * function `localizedTag`: return a localized tag if available (e.g. 'name:de' for the german translation of the tag). Parameters: tags (the tags property), key prefix (e.g. 'name'). Which language will be returned depends on the "data language" which can be set via Options. If no localized tag is available, the tag value itself will be returned (e.g. value of 'name'). * function `trans`: return the translation of the given string (e.g. 'save', 'unknown', 'unnamed', ...). Parameters: string (the string to translate). diff --git a/src/tagTranslations.js b/src/tagTranslations.js index 419b0022..16c97666 100644 --- a/src/tagTranslations.js +++ b/src/tagTranslations.js @@ -2,6 +2,9 @@ var OverpassLayer = require('overpass-layer') var translations = null var tagLang = null +OverpassLayer.twig.extendFunction('keyTrans', function () { + return tagTranslationsTrans.apply(this, arguments) +}) OverpassLayer.twig.extendFunction('tagTrans', function () { return tagTranslationsTrans.apply(this, arguments) })