From 83489d056388ecb35c86b0b0cf9a8deb92bec327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Tue, 8 Jan 2019 21:07:59 +0100 Subject: [PATCH 01/24] Repository*: pass options to data() --- repo.php | 2 +- src/RepositoryBase.php | 2 +- src/RepositoryDir.php | 4 ++-- src/RepositoryGit.php | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/repo.php b/repo.php index 73c033b9..6d1049d0 100644 --- a/repo.php +++ b/repo.php @@ -67,7 +67,7 @@ if (isset($config['cache'])) { } } -$data = $repo->data(); +$data = $repo->data($_REQUEST); if (!array_key_exists('index', $data['categories'])) { $data['categories']['index'] = array( diff --git a/src/RepositoryBase.php b/src/RepositoryBase.php index f5f666f5..38eaabb0 100644 --- a/src/RepositoryBase.php +++ b/src/RepositoryBase.php @@ -23,7 +23,7 @@ class RepositoryBase { return $ret; } - function data () { + function data ($options) { $data = array( 'categories' => array(), 'templates' => array(), diff --git a/src/RepositoryDir.php b/src/RepositoryDir.php index bab69884..959998fa 100644 --- a/src/RepositoryDir.php +++ b/src/RepositoryDir.php @@ -14,8 +14,8 @@ class RepositoryDir extends RepositoryBase { return $ts; } - function data () { - $data = parent::data(); + function data ($options) { + $data = parent::data($options); $d = opendir($this->path); while ($f = readdir($d)) { diff --git a/src/RepositoryGit.php b/src/RepositoryGit.php index d35ff30b..00b2f343 100644 --- a/src/RepositoryGit.php +++ b/src/RepositoryGit.php @@ -29,8 +29,8 @@ class RepositoryGit extends RepositoryBase { return $ts; } - function data () { - $data = parent::data(); + function data ($options) { + $data = parent::data($options); $d = popen("cd " . escapeShellArg($this->path) . "; git ls-tree {$this->branchEsc}", "r"); while ($r = fgets($d)) { From 30367176c1dbdd6335180618fbbe9b33eeebc1b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Tue, 8 Jan 2019 21:12:06 +0100 Subject: [PATCH 02/24] Read a translation from repository --- repo.php | 3 +++ src/OpenStreetBrowserLoader.js | 1 + src/RepositoryBase.php | 1 + src/RepositoryDir.php | 10 ++++++++++ src/RepositoryGit.php | 10 ++++++++++ 5 files changed, 25 insertions(+) diff --git a/repo.php b/repo.php index 6d1049d0..88aeba27 100644 --- a/repo.php +++ b/repo.php @@ -35,6 +35,9 @@ if (!isset($_REQUEST['repo'])) { $fullRepoId = $_REQUEST['repo']; list($repoId, $branchId) = explode('~', $fullRepoId); +if (array_key_exists('lang', $_REQUEST)) { + $fullRepoId .= '~' . $_REQUEST['lang']; +} if (!array_key_exists($repoId, $allRepositories)) { Header("HTTP/1.1 404 Repository not found"); diff --git a/src/OpenStreetBrowserLoader.js b/src/OpenStreetBrowserLoader.js index cb47e6ee..c4b35cd9 100644 --- a/src/OpenStreetBrowserLoader.js +++ b/src/OpenStreetBrowserLoader.js @@ -112,6 +112,7 @@ OpenStreetBrowserLoader.prototype.getRepo = function (repo, options, callback) { if (repo) { param.push('repo=' + encodeURIComponent(repo)) } + param.push('lang=' + encodeURIComponent(ui_lang)) param.push(config.categoriesRev) param = param.length ? '?' + param.join('&') : '' diff --git a/src/RepositoryBase.php b/src/RepositoryBase.php index 38eaabb0..be639208 100644 --- a/src/RepositoryBase.php +++ b/src/RepositoryBase.php @@ -28,6 +28,7 @@ class RepositoryBase { 'categories' => array(), 'templates' => array(), 'timestamp' => Date(DATE_ISO8601, $this->timestamp()), + 'lang' => array(), ); return $data; diff --git a/src/RepositoryDir.php b/src/RepositoryDir.php index 959998fa..86b82698 100644 --- a/src/RepositoryDir.php +++ b/src/RepositoryDir.php @@ -35,6 +35,16 @@ class RepositoryDir extends RepositoryBase { } closedir($d); + if (array_key_exists('lang', $options) && file_exists("{$this->path}/lang/{$options['lang']}.json")) { + $data['lang'] = json_decode(file_get_contents("{$this->path}/lang/en.json"), true); + $lang = json_decode(file_get_contents("{$this->path}/lang/{$options['lang']}.json"), true); + foreach ($lang as $k => $v) { + if ($v !== null && $v !== '') { + $data['lang'][$k] = $v; + } + } + } + return $data; } diff --git a/src/RepositoryGit.php b/src/RepositoryGit.php index 00b2f343..2040cf78 100644 --- a/src/RepositoryGit.php +++ b/src/RepositoryGit.php @@ -57,6 +57,16 @@ class RepositoryGit extends RepositoryBase { } pclose($d); + if (array_key_exists('lang', $options)) { + $data['lang'] = json_decode(shell_exec("cd " . escapeShellArg($this->path) . "; git show {$this->branchEsc}:lang/en.json 2>/dev/null"), true); + $lang = json_decode(shell_exec("cd " . escapeShellArg($this->path) . "; git show {$this->branchEsc}:lang/" . escapeShellArg("{$options['lang']}.json") . " 2>/dev/null"), true); + foreach ($lang as $k => $v) { + if ($v !== null && $v !== '') { + $data['lang'][$k] = $v; + } + } + } + if (!array_key_exists('branch', $this->def)) { $d = popen("cd " . escapeShellArg($this->path) . "; git for-each-ref --sort=-committerdate refs/heads/", "r"); $data['branch'] = $this->branch; From 03d97f09a545e5045502abd7b31241f70425c1ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Tue, 8 Jan 2019 21:19:13 +0100 Subject: [PATCH 03/24] repoTrans() --- lib/modulekit/form | 2 +- src/OpenStreetBrowserLoader.js | 1 + src/tagTranslations.js | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/modulekit/form b/lib/modulekit/form index 5d39b2f6..50f1ea5e 160000 --- a/lib/modulekit/form +++ b/lib/modulekit/form @@ -1 +1 @@ -Subproject commit 5d39b2f61b7eda9a635414acaeb3c4e0dc524490 +Subproject commit 50f1ea5eb822240876ed89504e3180f9c7dcbc05 diff --git a/src/OpenStreetBrowserLoader.js b/src/OpenStreetBrowserLoader.js index c4b35cd9..660365e7 100644 --- a/src/OpenStreetBrowserLoader.js +++ b/src/OpenStreetBrowserLoader.js @@ -58,6 +58,7 @@ OpenStreetBrowserLoader.prototype.getCategory = function (id, options, callback) this.getCategoryFromData(ids.id, opt, repoData.categories[ids.entityId], function (err, category) { if (category) { category.setMap(this.map) + category.lang = repoData.lang } callback(err, category) diff --git a/src/tagTranslations.js b/src/tagTranslations.js index 706da10d..9f46a828 100644 --- a/src/tagTranslations.js +++ b/src/tagTranslations.js @@ -25,6 +25,10 @@ OverpassLayer.twig.extendFunction('trans', function () { OverpassLayer.twig.extendFunction('isTranslated', function (str) { return tagTranslationsIsTranslated(str) }) +OverpassLayer.twig.extendFunction('repoTrans', function (str) { + let lang = global.currentCategory.lang + return str in lang ? lang[str] : str +}) function tagTranslationsIsTranslated (str) { return !(str in lang_non_translated) && (str in lang_str) From c00d0a40ebf5085a0dd021c5ab9ab569337fd23f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Wed, 9 Jan 2019 16:11:26 +0100 Subject: [PATCH 04/24] Repository*: first load language strings --- src/RepositoryDir.php | 20 ++++++++++---------- src/RepositoryGit.php | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/RepositoryDir.php b/src/RepositoryDir.php index 86b82698..0b2b33d9 100644 --- a/src/RepositoryDir.php +++ b/src/RepositoryDir.php @@ -17,6 +17,16 @@ class RepositoryDir extends RepositoryBase { function data ($options) { $data = parent::data($options); + if (array_key_exists('lang', $options) && file_exists("{$this->path}/lang/{$options['lang']}.json")) { + $data['lang'] = json_decode(file_get_contents("{$this->path}/lang/en.json"), true); + $lang = json_decode(file_get_contents("{$this->path}/lang/{$options['lang']}.json"), true); + foreach ($lang as $k => $v) { + if ($v !== null && $v !== '') { + $data['lang'][$k] = $v; + } + } + } + $d = opendir($this->path); while ($f = readdir($d)) { if (preg_match("/^([0-9a-zA-Z_\-]+)\.json$/", $f, $m) && $f !== 'package.json') { @@ -35,16 +45,6 @@ class RepositoryDir extends RepositoryBase { } closedir($d); - if (array_key_exists('lang', $options) && file_exists("{$this->path}/lang/{$options['lang']}.json")) { - $data['lang'] = json_decode(file_get_contents("{$this->path}/lang/en.json"), true); - $lang = json_decode(file_get_contents("{$this->path}/lang/{$options['lang']}.json"), true); - foreach ($lang as $k => $v) { - if ($v !== null && $v !== '') { - $data['lang'][$k] = $v; - } - } - } - return $data; } diff --git a/src/RepositoryGit.php b/src/RepositoryGit.php index 2040cf78..32d3bbed 100644 --- a/src/RepositoryGit.php +++ b/src/RepositoryGit.php @@ -32,6 +32,16 @@ class RepositoryGit extends RepositoryBase { function data ($options) { $data = parent::data($options); + if (array_key_exists('lang', $options)) { + $data['lang'] = json_decode(shell_exec("cd " . escapeShellArg($this->path) . "; git show {$this->branchEsc}:lang/en.json 2>/dev/null"), true); + $lang = json_decode(shell_exec("cd " . escapeShellArg($this->path) . "; git show {$this->branchEsc}:lang/" . escapeShellArg("{$options['lang']}.json") . " 2>/dev/null"), true); + foreach ($lang as $k => $v) { + if ($v !== null && $v !== '') { + $data['lang'][$k] = $v; + } + } + } + $d = popen("cd " . escapeShellArg($this->path) . "; git ls-tree {$this->branchEsc}", "r"); while ($r = fgets($d)) { if (preg_match("/^[0-9]{6} blob [0-9a-f]{40}\t(([0-9a-zA-Z_\-]+)\.json)$/", $r, $m)) { @@ -57,16 +67,6 @@ class RepositoryGit extends RepositoryBase { } pclose($d); - if (array_key_exists('lang', $options)) { - $data['lang'] = json_decode(shell_exec("cd " . escapeShellArg($this->path) . "; git show {$this->branchEsc}:lang/en.json 2>/dev/null"), true); - $lang = json_decode(shell_exec("cd " . escapeShellArg($this->path) . "; git show {$this->branchEsc}:lang/" . escapeShellArg("{$options['lang']}.json") . " 2>/dev/null"), true); - foreach ($lang as $k => $v) { - if ($v !== null && $v !== '') { - $data['lang'][$k] = $v; - } - } - } - if (!array_key_exists('branch', $this->def)) { $d = popen("cd " . escapeShellArg($this->path) . "; git for-each-ref --sort=-committerdate refs/heads/", "r"); $data['branch'] = $this->branch; From c7773581f5c446ac86103a83c43a16cb93add253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Wed, 9 Jan 2019 16:35:07 +0100 Subject: [PATCH 05/24] Repository*: if no lang specified, load 'en' --- src/RepositoryDir.php | 4 +++- src/RepositoryGit.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/RepositoryDir.php b/src/RepositoryDir.php index 0b2b33d9..b367b548 100644 --- a/src/RepositoryDir.php +++ b/src/RepositoryDir.php @@ -17,7 +17,9 @@ class RepositoryDir extends RepositoryBase { function data ($options) { $data = parent::data($options); - if (array_key_exists('lang', $options) && file_exists("{$this->path}/lang/{$options['lang']}.json")) { + $lang = array_key_exists('lang', $options) ? $options['lang'] : 'en'; + + if (file_exists("{$this->path}/lang/{$lang}.json")) { $data['lang'] = json_decode(file_get_contents("{$this->path}/lang/en.json"), true); $lang = json_decode(file_get_contents("{$this->path}/lang/{$options['lang']}.json"), true); foreach ($lang as $k => $v) { diff --git a/src/RepositoryGit.php b/src/RepositoryGit.php index 32d3bbed..a5f66e9d 100644 --- a/src/RepositoryGit.php +++ b/src/RepositoryGit.php @@ -32,7 +32,9 @@ class RepositoryGit extends RepositoryBase { function data ($options) { $data = parent::data($options); - if (array_key_exists('lang', $options)) { + $lang = array_key_exists('lang', $options) ? $options['lang'] : 'en'; + + if (true) { $data['lang'] = json_decode(shell_exec("cd " . escapeShellArg($this->path) . "; git show {$this->branchEsc}:lang/en.json 2>/dev/null"), true); $lang = json_decode(shell_exec("cd " . escapeShellArg($this->path) . "; git show {$this->branchEsc}:lang/" . escapeShellArg("{$options['lang']}.json") . " 2>/dev/null"), true); foreach ($lang as $k => $v) { From 78a244bddcfae46f37eae0a4e432cec8d1646ffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Wed, 9 Jan 2019 16:57:03 +0100 Subject: [PATCH 06/24] Repository*: load category names from lang files; include only current name in category --- repo.php | 2 ++ src/RepositoryBase.php | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/repo.php b/repo.php index 88aeba27..191ca1fd 100644 --- a/repo.php +++ b/repo.php @@ -72,6 +72,8 @@ if (isset($config['cache'])) { $data = $repo->data($_REQUEST); +$repo->updateLang($data, $_REQUEST); + if (!array_key_exists('index', $data['categories'])) { $data['categories']['index'] = array( 'type' => 'index', diff --git a/src/RepositoryBase.php b/src/RepositoryBase.php index be639208..df0736bf 100644 --- a/src/RepositoryBase.php +++ b/src/RepositoryBase.php @@ -34,6 +34,42 @@ class RepositoryBase { return $data; } + function updateLang (&$data, $options) { + $lang = array_key_exists('lang', $options) ? $options['lang'] : 'en'; + + if (!is_array($data['lang'])) { + $data['lang'] = array(); + } + + foreach ($data['categories'] as $id => $category) { + $name = null; + if (array_key_exists("category:{$id}", $data['lang'])) { + $name = $data['lang']["category:{$id}"]; + + if ($name !== '' && $name !== null) { + $data['categories'][$id]['name'] = array( + $lang => $data['lang']["category:{$id}"], + ); + } + } + elseif (array_key_exists('name', $category)) { + if (array_key_exists($lang, $category['name'])) { + $name = $category['name'][$lang]; + } + elseif (array_key_exists('en', $category['name'])) { + $name = $category['name']['en']; + } + elseif (sizeof($category['name'])) { + $name = $category['name'][array_keys($category['name'])[0]]; + } + + $data['lang']["category:{$id}"] = $name; + + $data['categories'][$id]['name'] = array($lang => $name); + } + } + } + function isCategory ($data) { if (!array_key_exists('type', $data)) { return false; From 01c57be85d3a165ccf4f0d412e1349d10c051dcf Mon Sep 17 00:00:00 2001 From: Igor Eliezer Date: Thu, 10 Jan 2019 00:21:35 -0200 Subject: [PATCH 07/24] Update --- lang/pt-br.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lang/pt-br.json b/lang/pt-br.json index 26fecf3b..7846e2fe 100644 --- a/lang/pt-br.json +++ b/lang/pt-br.json @@ -1,7 +1,7 @@ { - "available_branches": "", + "available_branches": "Redes disponíveis", "back": "voltar", - "categories": "", + "categories": "Categorias", "category-info-tooltip": "Info & Legenda", "closed": "fechado", "default": "padrão", @@ -22,11 +22,11 @@ "images": "Imagens", "loading": "Carregando...", "main:options": "Opções", - "main:permalink": "", + "main:permalink": "Link permanente", "more": "mais", "more_categories": "Mais categorias", "more_categories_gitea": "Criar & melhorar categorias você mesmo!", - "more_results": "", + "more_results": "Exibir mais resultados", "open": "abrir", "options:data_lang": "Língua dos dados", "options:data_lang:desc": "Muitos elementos do mapa possuem seus nomes (e outras etiquetas) traduzidas para línguas diferentes (p.ex. com 'name:en', 'name:de'). Especificar qual língua deve ser usada para exibição, ou 'Língua local' de forma que sempre os valores não tranduzidos (p.ex. 'name') sejam usados.", @@ -35,8 +35,8 @@ "options:preferredBaseMap": "Mapa-base preferido", "options:ui_lang": "Língua da interface", "other": "Outro", - "repo-use-as-base": "", - "repositories": "", + "repo-use-as-base": "Usar este repositório como repositório base", + "repositories": "Repositórios", "save": "Salvar", "show details": "mostrar detalhes", "toggle_fullscreen": "Alternar modo tela cheia", @@ -44,5 +44,5 @@ "unnamed": "sem nome", "wikipedia:no-url-parse": "Não se pôde analisar URL da Wikipédia", "zoom_in_appear": "aproxime para elementos do mapa aparecer", - "zoom_in_more": "aproxime para mais elementos do mapa" + "zoom_in_more": "aproxime para mais elementos no mapa" } From 42d208693235806582cdd7cb41cf562e4888ff05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Thu, 10 Jan 2019 14:06:20 +0100 Subject: [PATCH 08/24] Categories: by default hide details of map keys --- src/category.css | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/category.css b/src/category.css index 3d16f6a5..93ef0d8f 100644 --- a/src/category.css +++ b/src/category.css @@ -152,3 +152,12 @@ .overpass-layer-icon div.sign { font-size: 15px; } +.info .details { + display: none; +} +.info .infoShowDetails .details { + display: initial; +} +.info .infoShowDetails .summary { + display: none; +} From ca47e81f4be50211f3166b213a8180bde7779098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Sun, 13 Jan 2019 09:48:08 +0100 Subject: [PATCH 09/24] New twig function osmFormatDate, create locale dist files --- index.php | 1 + locales/ast.js | 7 +++++++ locales/ca.js | 7 +++++++ locales/cs.js | 7 +++++++ locales/da.js | 7 +++++++ locales/de.js | 7 +++++++ locales/el.js | 7 +++++++ locales/en.js | 5 +++++ locales/es.js | 7 +++++++ locales/et.js | 7 +++++++ locales/fr.js | 7 +++++++ locales/hu.js | 7 +++++++ locales/it.js | 7 +++++++ locales/ja.js | 7 +++++++ locales/nl.js | 7 +++++++ locales/pl.js | 7 +++++++ locales/pt-br.js | 7 +++++++ locales/pt.js | 7 +++++++ locales/ro.js | 7 +++++++ locales/ru.js | 7 +++++++ locales/sr.js | 7 +++++++ locales/uk.js | 7 +++++++ package.json | 4 +++- src/twigFunctions.js | 4 ++++ 24 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 locales/ast.js create mode 100644 locales/ca.js create mode 100644 locales/cs.js create mode 100644 locales/da.js create mode 100644 locales/de.js create mode 100644 locales/el.js create mode 100644 locales/en.js create mode 100644 locales/es.js create mode 100644 locales/et.js create mode 100644 locales/fr.js create mode 100644 locales/hu.js create mode 100644 locales/it.js create mode 100644 locales/ja.js create mode 100644 locales/nl.js create mode 100644 locales/pl.js create mode 100644 locales/pt-br.js create mode 100644 locales/pt.js create mode 100644 locales/ro.js create mode 100644 locales/ru.js create mode 100644 locales/sr.js create mode 100644 locales/uk.js diff --git a/index.php b/index.php index 7a1d6c18..a3c41338 100644 --- a/index.php +++ b/index.php @@ -55,6 +55,7 @@ html_export_var(array( + diff --git a/locales/ast.js b/locales/ast.js new file mode 100644 index 00000000..5a4c4713 --- /dev/null +++ b/locales/ast.js @@ -0,0 +1,7 @@ +global.locale = { + id: 'ast', + moment: require('moment'), + osmDateFormatTemplates: require('openstreetmap-date-format/templates/en') +} + +//require('moment/locale/ast') diff --git a/locales/ca.js b/locales/ca.js new file mode 100644 index 00000000..c706ab5e --- /dev/null +++ b/locales/ca.js @@ -0,0 +1,7 @@ +global.locale = { + id: 'ca', + moment: require('moment'), + osmDateFormatTemplates: require('openstreetmap-date-format/templates/de') +} + +require('moment/locale/ca') diff --git a/locales/cs.js b/locales/cs.js new file mode 100644 index 00000000..756d0422 --- /dev/null +++ b/locales/cs.js @@ -0,0 +1,7 @@ +global.locale = { + id: 'cs', + moment: require('moment'), + osmDateFormatTemplates: require('openstreetmap-date-format/templates/en') +} + +require('moment/locale/cs') diff --git a/locales/da.js b/locales/da.js new file mode 100644 index 00000000..ebaaae87 --- /dev/null +++ b/locales/da.js @@ -0,0 +1,7 @@ +global.locale = { + id: 'da', + moment: require('moment'), + osmDateFormatTemplates: require('openstreetmap-date-format/templates/en') +} + +require('moment/locale/da') diff --git a/locales/de.js b/locales/de.js new file mode 100644 index 00000000..e0a1f1a4 --- /dev/null +++ b/locales/de.js @@ -0,0 +1,7 @@ +global.locale = { + id: 'de', + moment: require('moment'), + osmDateFormatTemplates: require('openstreetmap-date-format/templates/de') +} + +require('moment/locale/de') diff --git a/locales/el.js b/locales/el.js new file mode 100644 index 00000000..11f30501 --- /dev/null +++ b/locales/el.js @@ -0,0 +1,7 @@ +global.locale = { + id: 'el', + moment: require('moment'), + osmDateFormatTemplates: require('openstreetmap-date-format/templates/en') +} + +require('moment/locale/el') diff --git a/locales/en.js b/locales/en.js new file mode 100644 index 00000000..d97b4a4f --- /dev/null +++ b/locales/en.js @@ -0,0 +1,5 @@ +global.locale = { + id: 'en', + moment: require('moment'), + osmDateFormatTemplates: require('openstreetmap-date-format/templates/en') +} diff --git a/locales/es.js b/locales/es.js new file mode 100644 index 00000000..b0ea3a88 --- /dev/null +++ b/locales/es.js @@ -0,0 +1,7 @@ +global.locale = { + id: 'es', + moment: require('moment'), + osmDateFormatTemplates: require('openstreetmap-date-format/templates/en') +} + +require('moment/locale/es') diff --git a/locales/et.js b/locales/et.js new file mode 100644 index 00000000..e49bd4d2 --- /dev/null +++ b/locales/et.js @@ -0,0 +1,7 @@ +global.locale = { + id: 'et', + moment: require('moment'), + osmDateFormatTemplates: require('openstreetmap-date-format/templates/en') +} + +require('moment/locale/et') diff --git a/locales/fr.js b/locales/fr.js new file mode 100644 index 00000000..de412df6 --- /dev/null +++ b/locales/fr.js @@ -0,0 +1,7 @@ +global.locale = { + id: 'fr', + moment: require('moment'), + osmDateFormatTemplates: require('openstreetmap-date-format/templates/en') +} + +require('moment/locale/fr') diff --git a/locales/hu.js b/locales/hu.js new file mode 100644 index 00000000..72c69419 --- /dev/null +++ b/locales/hu.js @@ -0,0 +1,7 @@ +global.locale = { + id: 'hu', + moment: require('moment'), + osmDateFormatTemplates: require('openstreetmap-date-format/templates/en') +} + +require('moment/locale/hu') diff --git a/locales/it.js b/locales/it.js new file mode 100644 index 00000000..9a10335b --- /dev/null +++ b/locales/it.js @@ -0,0 +1,7 @@ +global.locale = { + id: 'it', + moment: require('moment'), + osmDateFormatTemplates: require('openstreetmap-date-format/templates/en') +} + +require('moment/locale/it') diff --git a/locales/ja.js b/locales/ja.js new file mode 100644 index 00000000..b91a1d1b --- /dev/null +++ b/locales/ja.js @@ -0,0 +1,7 @@ +global.locale = { + id: 'ja', + moment: require('moment'), + osmDateFormatTemplates: require('openstreetmap-date-format/templates/en') +} + +require('moment/locale/ja') diff --git a/locales/nl.js b/locales/nl.js new file mode 100644 index 00000000..dec0f6b8 --- /dev/null +++ b/locales/nl.js @@ -0,0 +1,7 @@ +global.locale = { + id: 'nl', + moment: require('moment'), + osmDateFormatTemplates: require('openstreetmap-date-format/templates/en') +} + +require('moment/locale/nl') diff --git a/locales/pl.js b/locales/pl.js new file mode 100644 index 00000000..53196da7 --- /dev/null +++ b/locales/pl.js @@ -0,0 +1,7 @@ +global.locale = { + id: 'pl', + moment: require('moment'), + osmDateFormatTemplates: require('openstreetmap-date-format/templates/en') +} + +require('moment/locale/pl') diff --git a/locales/pt-br.js b/locales/pt-br.js new file mode 100644 index 00000000..7a227e2b --- /dev/null +++ b/locales/pt-br.js @@ -0,0 +1,7 @@ +global.locale = { + id: 'pt-br', + moment: require('moment'), + osmDateFormatTemplates: require('openstreetmap-date-format/templates/en') +} + +require('moment/locale/pt-br') diff --git a/locales/pt.js b/locales/pt.js new file mode 100644 index 00000000..080dfc8d --- /dev/null +++ b/locales/pt.js @@ -0,0 +1,7 @@ +global.locale = { + id: 'pt', + moment: require('moment'), + osmDateFormatTemplates: require('openstreetmap-date-format/templates/en') +} + +require('moment/locale/pt') diff --git a/locales/ro.js b/locales/ro.js new file mode 100644 index 00000000..2b3c784b --- /dev/null +++ b/locales/ro.js @@ -0,0 +1,7 @@ +global.locale = { + id: 'ro', + moment: require('moment'), + osmDateFormatTemplates: require('openstreetmap-date-format/templates/en') +} + +require('moment/locale/ro') diff --git a/locales/ru.js b/locales/ru.js new file mode 100644 index 00000000..f1ff6add --- /dev/null +++ b/locales/ru.js @@ -0,0 +1,7 @@ +global.locale = { + id: 'ru', + moment: require('moment'), + osmDateFormatTemplates: require('openstreetmap-date-format/templates/en') +} + +require('moment/locale/ru') diff --git a/locales/sr.js b/locales/sr.js new file mode 100644 index 00000000..775fc74e --- /dev/null +++ b/locales/sr.js @@ -0,0 +1,7 @@ +global.locale = { + id: 'sr', + moment: require('moment'), + osmDateFormatTemplates: require('openstreetmap-date-format/templates/en') +} + +require('moment/locale/sr') diff --git a/locales/uk.js b/locales/uk.js new file mode 100644 index 00000000..58e3ae7d --- /dev/null +++ b/locales/uk.js @@ -0,0 +1,7 @@ +global.locale = { + id: 'uk', + moment: require('moment'), + osmDateFormatTemplates: require('openstreetmap-date-format/templates/en') +} + +require('moment/locale/uk') diff --git a/package.json b/package.json index 0992b57a..4a5847e2 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "natsort": "^1.0.6", "opening_hours": "^3.5.0", "openstreetbrowser-categories-main": "https://github.com/plepe/openstreetbrowser-categories-main", + "openstreetmap-date-format": "^0.1.0", "openstreetmap-date-parser": "^0.1.0", "openstreetmap-tag-translations": "https://github.com/plepe/openstreetmap-tag-translations", "overpass-layer": "^2.0.0", @@ -68,7 +69,8 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "build": "browserify -g browserify-css src/index.js -o dist/tmp1.js && babel --presets env dist/tmp1.js > dist/tmp2.js && mv dist/tmp2.js dist/openstreetbrowser.js && rm dist/tmp1.js", - "watch": "watchify --debug -g browserify-css src/index.js -o dist/openstreetbrowser.js -v", + "build-locales": "for i in `ls locales/` ; do browserify locales/$i -o dist/locale-$i ; done", + "watch": "npm run build-locales && watchify --debug -g browserify-css src/index.js -o dist/openstreetbrowser.js -v", "prepublish": "npm run build", "lint": "standard src/*.js" }, diff --git a/src/twigFunctions.js b/src/twigFunctions.js index 8b211a07..312120fb 100644 --- a/src/twigFunctions.js +++ b/src/twigFunctions.js @@ -2,6 +2,7 @@ var OverpassLayer = require('overpass-layer') var OpeningHours = require('opening_hours') var colorInterpolate = require('color-interpolate') var osmParseDate = require('openstreetmap-date-parser') +var osmFormatDate = require('openstreetmap-date-format') const natsort = require('natsort') const md5 = require('md5') @@ -66,6 +67,9 @@ OverpassLayer.twig.extendFunction('colorInterpolate', function (map, value) { OverpassLayer.twig.extendFilter('osmParseDate', function (value) { return osmParseDate(value) }) +OverpassLayer.twig.extendFilter('osmFormatDate', function (value) { + return osmFormatDate(value) +}) OverpassLayer.twig.extendFilter('md5', function (value) { if (!(value in md5cache)) { md5cache[value] = md5(value) From 9d47c585b81df34479d17b83779d7a878b31582c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Mon, 14 Jan 2019 10:29:03 +0100 Subject: [PATCH 10/24] Change lang str templates to '' (if they are null) --- lang/ast.json | 2 +- lang/ca.json | 2 +- lang/cs.json | 2 +- lang/da.json | 2 +- lang/de.json | 4 ++-- lang/el.json | 2 +- lang/es.json | 2 +- lang/et.json | 2 +- lang/hu.json | 2 +- lang/it.json | 2 +- lang/ja.json | 2 +- lang/nl.json | 2 +- lang/pl.json | 2 +- lang/pt.json | 2 +- lang/ro.json | 2 +- lang/ru.json | 2 +- lang/sr.json | 2 +- lang/template.json | 2 +- lang/uk.json | 2 +- 19 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lang/ast.json b/lang/ast.json index 92ab783e..d8ccf98a 100644 --- a/lang/ast.json +++ b/lang/ast.json @@ -11,7 +11,7 @@ "export-prepare": "", "export:GeoJSON": "", "export:OSMJSON": "", - "export:OSMXML": null, + "export:OSMXML": "", "facilities": "", "header:attributes": "", "header:export": "", diff --git a/lang/ca.json b/lang/ca.json index bd8ed25c..29b3fa24 100644 --- a/lang/ca.json +++ b/lang/ca.json @@ -11,7 +11,7 @@ "export-prepare": "", "export:GeoJSON": "", "export:OSMJSON": "", - "export:OSMXML": null, + "export:OSMXML": "", "facilities": "", "header:attributes": "", "header:export": "", diff --git a/lang/cs.json b/lang/cs.json index d498d933..8f9785a8 100644 --- a/lang/cs.json +++ b/lang/cs.json @@ -11,7 +11,7 @@ "export-prepare": "", "export:GeoJSON": "", "export:OSMJSON": "", - "export:OSMXML": null, + "export:OSMXML": "", "facilities": "", "header:attributes": "", "header:export": "", diff --git a/lang/da.json b/lang/da.json index 00ddf730..490ae447 100644 --- a/lang/da.json +++ b/lang/da.json @@ -11,7 +11,7 @@ "export-prepare": "", "export:GeoJSON": "", "export:OSMJSON": "", - "export:OSMXML": null, + "export:OSMXML": "", "facilities": "", "header:attributes": "", "header:export": "", diff --git a/lang/de.json b/lang/de.json index 4584dd53..a65e188f 100644 --- a/lang/de.json +++ b/lang/de.json @@ -14,7 +14,7 @@ "export-prepare": "", "export:GeoJSON": "Als GeoJSON runterladen", "export:OSMJSON": "", - "export:OSMXML": null, + "export:OSMXML": "", "facilities": "Einrichtungen", "header:attributes": "Attribute", "header:export": "Export", @@ -29,7 +29,7 @@ "more_results": "", "open": "geöffnet", "options:data_lang": "Datensprache", - "options:data_lang:desc": null, + "options:data_lang:desc": "", "options:data_lang:local": "Lokale Sprache", "options:overpassUrl": "OverpassAPI Adresse", "options:preferredBaseMap": "Bevorzugte Hintergrundkarte", diff --git a/lang/el.json b/lang/el.json index df6fb441..1527f424 100644 --- a/lang/el.json +++ b/lang/el.json @@ -11,7 +11,7 @@ "export-prepare": "", "export:GeoJSON": "", "export:OSMJSON": "", - "export:OSMXML": null, + "export:OSMXML": "", "facilities": "", "header:attributes": "", "header:export": "", diff --git a/lang/es.json b/lang/es.json index 2ecbd1ea..172b0396 100644 --- a/lang/es.json +++ b/lang/es.json @@ -11,7 +11,7 @@ "export-prepare": "", "export:GeoJSON": "", "export:OSMJSON": "", - "export:OSMXML": null, + "export:OSMXML": "", "facilities": "", "header:attributes": "", "header:export": "", diff --git a/lang/et.json b/lang/et.json index ed4e98e6..8cbe87ee 100644 --- a/lang/et.json +++ b/lang/et.json @@ -11,7 +11,7 @@ "export-prepare": "", "export:GeoJSON": "", "export:OSMJSON": "", - "export:OSMXML": null, + "export:OSMXML": "", "facilities": "", "header:attributes": "", "header:export": "", diff --git a/lang/hu.json b/lang/hu.json index 70432f29..3a83030e 100644 --- a/lang/hu.json +++ b/lang/hu.json @@ -11,7 +11,7 @@ "export-prepare": "", "export:GeoJSON": "Letöltés GeoJSON formátumban", "export:OSMJSON": "", - "export:OSMXML": null, + "export:OSMXML": "", "facilities": "Létesítmények", "header:attributes": "Tulajdonságok", "header:export": "Exportálás", diff --git a/lang/it.json b/lang/it.json index 67316501..94d020dd 100644 --- a/lang/it.json +++ b/lang/it.json @@ -11,7 +11,7 @@ "export-prepare": "", "export:GeoJSON": "", "export:OSMJSON": "", - "export:OSMXML": null, + "export:OSMXML": "", "facilities": "", "header:attributes": "", "header:export": "", diff --git a/lang/ja.json b/lang/ja.json index 0117028c..d4ee22e1 100644 --- a/lang/ja.json +++ b/lang/ja.json @@ -11,7 +11,7 @@ "export-prepare": "", "export:GeoJSON": "", "export:OSMJSON": "", - "export:OSMXML": null, + "export:OSMXML": "", "facilities": "", "header:attributes": "", "header:export": "", diff --git a/lang/nl.json b/lang/nl.json index 65f2c2b2..05d558a9 100644 --- a/lang/nl.json +++ b/lang/nl.json @@ -11,7 +11,7 @@ "export-prepare": "", "export:GeoJSON": "", "export:OSMJSON": "", - "export:OSMXML": null, + "export:OSMXML": "", "facilities": "", "header:attributes": "", "header:export": "", diff --git a/lang/pl.json b/lang/pl.json index e4bf5142..7ca1673d 100644 --- a/lang/pl.json +++ b/lang/pl.json @@ -11,7 +11,7 @@ "export-prepare": "", "export:GeoJSON": "", "export:OSMJSON": "", - "export:OSMXML": null, + "export:OSMXML": "", "facilities": "", "header:attributes": "", "header:export": "", diff --git a/lang/pt.json b/lang/pt.json index a6eb1881..acbf00b5 100644 --- a/lang/pt.json +++ b/lang/pt.json @@ -14,7 +14,7 @@ "export-prepare": "", "export:GeoJSON": "Descarregar como GeoJSON", "export:OSMJSON": "", - "export:OSMXML": null, + "export:OSMXML": "", "facilities": "Instalações", "header:attributes": "Atributos", "header:export": "Exportar", diff --git a/lang/ro.json b/lang/ro.json index 98b3d7ca..56ac6dc7 100644 --- a/lang/ro.json +++ b/lang/ro.json @@ -11,7 +11,7 @@ "export-prepare": "", "export:GeoJSON": "", "export:OSMJSON": "", - "export:OSMXML": null, + "export:OSMXML": "", "facilities": "", "header:attributes": "", "header:export": "", diff --git a/lang/ru.json b/lang/ru.json index cb557569..39001793 100644 --- a/lang/ru.json +++ b/lang/ru.json @@ -11,7 +11,7 @@ "export-prepare": "", "export:GeoJSON": "", "export:OSMJSON": "", - "export:OSMXML": null, + "export:OSMXML": "", "facilities": "", "header:attributes": "", "header:export": "", diff --git a/lang/sr.json b/lang/sr.json index 409be7aa..89c9d5ee 100644 --- a/lang/sr.json +++ b/lang/sr.json @@ -11,7 +11,7 @@ "export-prepare": "", "export:GeoJSON": "", "export:OSMJSON": "", - "export:OSMXML": null, + "export:OSMXML": "", "facilities": "", "header:attributes": "", "header:export": "", diff --git a/lang/template.json b/lang/template.json index 943a418d..5c4a587d 100644 --- a/lang/template.json +++ b/lang/template.json @@ -11,7 +11,7 @@ "export-prepare": "", "export:GeoJSON": "", "export:OSMJSON": "", - "export:OSMXML": null, + "export:OSMXML": "", "facilities": "", "header:attributes": "", "header:export": "", diff --git a/lang/uk.json b/lang/uk.json index 58d5a1e7..841ae6ec 100644 --- a/lang/uk.json +++ b/lang/uk.json @@ -11,7 +11,7 @@ "export-prepare": "", "export:GeoJSON": "", "export:OSMJSON": "", - "export:OSMXML": null, + "export:OSMXML": "", "facilities": "", "header:attributes": "", "header:export": "", From 917d863cef7ba83a1cd84e63aaa4281611f2fcf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Mon, 14 Jan 2019 16:36:01 +0100 Subject: [PATCH 11/24] Details: show popupDescription if available instead of description --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 65350567..0e7692d2 100644 --- a/src/index.js +++ b/src/index.js @@ -277,7 +277,7 @@ window.showDetails = function (data, category) { div = document.createElement('div') div.className = 'description' - div.innerHTML = data.data.description || '' + div.innerHTML = data.data.popupDescription || data.data.description || '' dom.appendChild(div) data.sublayer.updateAssets(div, data) From 2720cfdac3992b4837f5dab2cc20203503cfdc67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Mon, 14 Jan 2019 16:36:29 +0100 Subject: [PATCH 12/24] twigFunctions/osmFormatDate(): pass options --- src/twigFunctions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/twigFunctions.js b/src/twigFunctions.js index 312120fb..1bde15a3 100644 --- a/src/twigFunctions.js +++ b/src/twigFunctions.js @@ -67,8 +67,8 @@ OverpassLayer.twig.extendFunction('colorInterpolate', function (map, value) { OverpassLayer.twig.extendFilter('osmParseDate', function (value) { return osmParseDate(value) }) -OverpassLayer.twig.extendFilter('osmFormatDate', function (value) { - return osmFormatDate(value) +OverpassLayer.twig.extendFilter('osmFormatDate', function (value, param) { + return osmFormatDate(value, param.length ? param[0] : {}) }) OverpassLayer.twig.extendFilter('md5', function (value) { if (!(value in md5cache)) { From ea154b039ce8459da69ac6d582efc54394d268dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Sun, 6 Jan 2019 07:09:54 +0100 Subject: [PATCH 13/24] CategoryOverpass: expose user options in twigData with user prefix --- src/CategoryOverpass.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/CategoryOverpass.js b/src/CategoryOverpass.js index 7725dcd7..06640fd3 100644 --- a/src/CategoryOverpass.js +++ b/src/CategoryOverpass.js @@ -107,6 +107,11 @@ function CategoryOverpass (options, data) { this.layer.on('add', (ob, data) => this.emit('add', ob, data)) this.layer.on('remove', (ob, data) => this.emit('remove', ob, data)) this.layer.on('zoomChange', (ob, data) => this.emit('remove', ob, data)) + this.layer.on('twigData', + (ob, data, result) => { + result.user = global.options + } + ) p = document.createElement('div') p.className = 'loadingIndicator' From 60c7160ab949af20d7f8cf429d714f344581972d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Tue, 15 Jan 2019 15:40:33 +0100 Subject: [PATCH 14/24] CategoryOverpass: set global currentCategory for twigData() --- src/CategoryOverpass.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CategoryOverpass.js b/src/CategoryOverpass.js index 06640fd3..0fcd60c7 100644 --- a/src/CategoryOverpass.js +++ b/src/CategoryOverpass.js @@ -110,6 +110,7 @@ function CategoryOverpass (options, data) { this.layer.on('twigData', (ob, data, result) => { result.user = global.options + global.currentCategory = this } ) From ec51b908c9472fbbda9f79e771d4a2b17e2cd6d2 Mon Sep 17 00:00:00 2001 From: Piotr Strebski Date: Sun, 30 Dec 2018 10:17:31 +0100 Subject: [PATCH 15/24] Update pl.json Added most important strings in Polish language (to be continued) --- lang/pl.json | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/lang/pl.json b/lang/pl.json index 7ca1673d..639582ac 100644 --- a/lang/pl.json +++ b/lang/pl.json @@ -1,12 +1,12 @@ { "available_branches": "", - "back": "", - "categories": "", + "back": "Wstecz", + "categories": "Kategorie", "category-info-tooltip": "", - "closed": "", - "default": "", - "edit": "", - "error": "", + "closed": "Zamknięte", + "default": "Domyślne", + "edit": "Edycja", + "error": "Błąd", "export-all": "", "export-prepare": "", "export:GeoJSON": "", @@ -14,32 +14,32 @@ "export:OSMXML": "", "facilities": "", "header:attributes": "", - "header:export": "", + "header:export": "Eksport", "header:osm_meta": "", - "images": "", - "loading": "", + "images": "Obrazy", + "loading": "Wczytywanie", "main:options": "Opcje", "main:permalink": "", - "more": "więcej", + "more": "Więcej", "more_categories": "Więcej kategorii", "more_categories_gitea": "", - "more_results": "", - "open": "", + "more_results": "Więcej wyników", + "open": "Otwórz", "options:data_lang": "Język danych", - "options:data_lang:desc": "", + "options:data_lang:desc": "Opis", "options:data_lang:local": "Język lokalny", "options:overpassUrl": "", "options:preferredBaseMap": "", "options:ui_lang": "Język interfejsu", - "other": "", + "other": "Inne", "repo-use-as-base": "", - "repositories": "", + "repositories": "Repozytoria", "save": "Zapisz", - "show details": "", - "toggle_fullscreen": "", - "unknown": "", - "unnamed": "nienazwane", + "show details": "Pokaż szczegóły", + "toggle_fullscreen": "Przełącz pełny ekran", + "unknown": "Nieznane", + "unnamed": "Nienazwane", "wikipedia:no-url-parse": "", - "zoom_in_appear": "", - "zoom_in_more": "" + "zoom_in_appear": "Powiększ widoczność", + "zoom_in_more": "Powiększ bardziej" } From ef46214846a18b98bb38474dbc14616cbf033a5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Thu, 17 Jan 2019 09:24:47 +0100 Subject: [PATCH 16/24] Update submodule modulekit-form --- lib/modulekit/form | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/modulekit/form b/lib/modulekit/form index 5d39b2f6..50f1ea5e 160000 --- a/lib/modulekit/form +++ b/lib/modulekit/form @@ -1 +1 @@ -Subproject commit 5d39b2f61b7eda9a635414acaeb3c4e0dc524490 +Subproject commit 50f1ea5eb822240876ed89504e3180f9c7dcbc05 From 470bd2baf558ef055d2398aca8da88da0d46fdca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Thu, 17 Jan 2019 09:25:25 +0100 Subject: [PATCH 17/24] Bump to version 4.3.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0992b57a..f8874eb7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openstreetbrowser", - "version": "4.3.2", + "version": "4.3.3", "description": "A re-make of the famous OpenStreetBrowser (pure JS, using Overpass API)", "main": "src/export.js", "repository": "https://github.com/plepe/openstreetbrowser", From 617610787440a754c953206c72f2906bd5e1fe64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Thu, 17 Jan 2019 09:32:07 +0100 Subject: [PATCH 18/24] Document twig changes - function 'repoTrans' - properties 'user.*' --- doc/TwigJS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/TwigJS.md b/doc/TwigJS.md index 68eb03c5..bc7fe2aa 100644 --- a/doc/TwigJS.md +++ b/doc/TwigJS.md @@ -45,6 +45,7 @@ When rendering map features, the following properties are available: * `meta.uid` (UID of the user, who changed the object last) * `map.zoom` (Current zoom level) * `const.*` (Values from the 'const' option) +* `user.*` (Values from the user's options, e.g. `user.ui_lang`, `user.data_lang`, ...) For the info-section of a category the following properties are available: * `layer_id` (the id of the category) @@ -57,6 +58,7 @@ There are several extra functions defined for the TwigJS language: * function `tagTransList`: 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). +* function `repoTrans`: translate strings from this repositories' language file (located in `lang/xy.json`, where `xy` stands for the current locale). * function `tagsPrefix(tags, prefix)`: return all tags with the specified prefix. The result will be an array with `{ "en": "name:en", "de": "name:de" }` (for the input `{ "name": "foo", "name:en": "english foo", "name:de": "german foo" }` and the prefix "name:"). * function openingHoursState(opening_hours_definition): returns state of object as string: 'closed', 'open' or 'unknown'. * function colorInterpolate(map, value): interpolates between two or more colors. E.g. `colorInterpolate([ 'red', 'yellow', 'green' ], 0.75)`. From cd894501e391b9bca25a33c690bb87d1be077ca8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Thu, 17 Jan 2019 09:42:39 +0100 Subject: [PATCH 19/24] Document twig filter 'osmDateFormat' --- doc/TwigJS.md | 1 + lib/modulekit/form | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/TwigJS.md b/doc/TwigJS.md index 68eb03c5..fe09ed1a 100644 --- a/doc/TwigJS.md +++ b/doc/TwigJS.md @@ -65,6 +65,7 @@ Extra filters: * filter websiteUrl: return a valid http link. Example: `{{ "www.google.com"|websiteUrl }}` -> "http://www.google.com"; `{{ "https://google.com"|websiteUrl }}` -> "https://google.com" * filter `matches`: regular expression match. e.g. `{{ "test"|matches("e(st)$") }}` returns `[ "est", "st" ]`. Returns null if it does not match. * filter `osmDateParse`: returns an array with the lower and upper boundary of the year of a `start_date` tag. See [https://github.com/plepe/openstreetmap-date-parser](openstreetmap-date-parser) for details. +* filter `osmDateFormat`: returns the date as localized strings. Accept an object for options, e.g. `{{ tags.start_date|osmDateFormat({ format: 'short' }) }}`. See [https://github.com/plepe/openstreetmap-date-format](openstreetmap-date-format) for details. * filter `natsort`: Sort an array naturally, see [https://www.npmjs.com/package/natsort](natsort) for details. * filter `unique`: Remove duplicate elements from an array. * filter `md5`: calculate md5 hash of a string. diff --git a/lib/modulekit/form b/lib/modulekit/form index 5d39b2f6..50f1ea5e 160000 --- a/lib/modulekit/form +++ b/lib/modulekit/form @@ -1 +1 @@ -Subproject commit 5d39b2f61b7eda9a635414acaeb3c4e0dc524490 +Subproject commit 50f1ea5eb822240876ed89504e3180f9c7dcbc05 From 4e9fb65113b7546c9c7b916ce88b2e2136bfa115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Thu, 17 Jan 2019 09:47:13 +0100 Subject: [PATCH 20/24] Require overpass-layer 2.3.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0992b57a..c9ff4f03 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "openstreetbrowser-categories-main": "https://github.com/plepe/openstreetbrowser-categories-main", "openstreetmap-date-parser": "^0.1.0", "openstreetmap-tag-translations": "https://github.com/plepe/openstreetmap-tag-translations", - "overpass-layer": "^2.0.0", + "overpass-layer": "^2.3.0", "query-string": "^5.0.0", "sheet-router": "^4.2.3", "temaki": "^1.0.0", From efb0a16981c7d205fa4a0dbc4c5196d1c3d9457d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Thu, 17 Jan 2019 09:53:43 +0100 Subject: [PATCH 21/24] Fix polish translation (pl) --- lang/pl.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/pl.json b/lang/pl.json index 639582ac..4503ea9a 100644 --- a/lang/pl.json +++ b/lang/pl.json @@ -26,7 +26,7 @@ "more_results": "Więcej wyników", "open": "Otwórz", "options:data_lang": "Język danych", - "options:data_lang:desc": "Opis", + "options:data_lang:desc": "", "options:data_lang:local": "Język lokalny", "options:overpassUrl": "", "options:preferredBaseMap": "", From 21f154a16c0cc2c84d4ad38d6a6ae210bea646b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Thu, 17 Jan 2019 11:28:36 +0100 Subject: [PATCH 22/24] script 'build': also build locales --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ba0c8612..91433d36 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build": "browserify -g browserify-css src/index.js -o dist/tmp1.js && babel --presets env dist/tmp1.js > dist/tmp2.js && mv dist/tmp2.js dist/openstreetbrowser.js && rm dist/tmp1.js", + "build": "npm run build-locales && browserify -g browserify-css src/index.js -o dist/tmp1.js && babel --presets env dist/tmp1.js > dist/tmp2.js && mv dist/tmp2.js dist/openstreetbrowser.js && rm dist/tmp1.js", "build-locales": "for i in `ls locales/` ; do browserify locales/$i -o dist/locale-$i ; done", "watch": "npm run build-locales && watchify --debug -g browserify-css src/index.js -o dist/openstreetbrowser.js -v", "prepublish": "npm run build", From 907eb033ed04c4312eeb5d722fb505b3e9d97e7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Thu, 17 Jan 2019 11:25:40 +0100 Subject: [PATCH 23/24] Bump to version 4.4.0 --- modulekit.php | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modulekit.php b/modulekit.php index 486465cd..e83f5650 100644 --- a/modulekit.php +++ b/modulekit.php @@ -25,4 +25,4 @@ $include = array( 'style.css', ), ); -$version = "4.3"; +$version = "4.4"; diff --git a/package.json b/package.json index 91433d36..8de5605e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openstreetbrowser", - "version": "4.3.3", + "version": "4.4.0", "description": "A re-make of the famous OpenStreetBrowser (pure JS, using Overpass API)", "main": "src/export.js", "repository": "https://github.com/plepe/openstreetbrowser", From 9e98f39734349bfff6094874c1e0d3307d8eb49e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Thu, 17 Jan 2019 17:03:49 +0100 Subject: [PATCH 24/24] CategoryOverpass: accept '_' in maki/temaki icon names --- src/CategoryOverpass.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CategoryOverpass.js b/src/CategoryOverpass.js index 0fcd60c7..44904388 100644 --- a/src/CategoryOverpass.js +++ b/src/CategoryOverpass.js @@ -168,7 +168,7 @@ CategoryOverpass.prototype.updateAssets = function (div) { var src = img.getAttribute('src') || img.getAttribute('data-src') if (src === null) { } else if (src.match(/^(maki|temaki):.*/)) { - let m = src.match(/^(maki|temaki):([a-z0-9-]*)(?:\?(.*))?$/) + let m = src.match(/^(maki|temaki):([a-z0-9-_]*)(?:\?(.*))?$/) if (m) { let span = document.createElement('span') img.parentNode.insertBefore(span, img)