[gnome-maps/wip/mlundblad/localized-names-from-overpass: 1/2] WIP: Add module with utility functions for localized OSM names
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/localized-names-from-overpass: 1/2] WIP: Add module with utility functions for localized OSM names
- Date: Fri, 9 Oct 2020 20:41:51 +0000 (UTC)
commit fcd1de2ddd55206f0e50267bb962436197719891
Author: Marcus Lundblad <ml update uu se>
Date: Fri Oct 9 22:39:26 2020 +0200
WIP: Add module with utility functions for localized OSM names
src/org.gnome.Maps.src.gresource.xml | 1 +
src/osmNames.js | 40 ++++++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+)
---
diff --git a/src/org.gnome.Maps.src.gresource.xml b/src/org.gnome.Maps.src.gresource.xml
index ab2e12f0..8c455163 100644
--- a/src/org.gnome.Maps.src.gresource.xml
+++ b/src/org.gnome.Maps.src.gresource.xml
@@ -45,6 +45,7 @@
<file>osmConnection.js</file>
<file>osmEdit.js</file>
<file>osmEditDialog.js</file>
+ <file>osmNames.js</file>
<file>osmTypeSearchEntry.js</file>
<file>osmTypeListRow.js</file>
<file>osmTypePopover.js</file>
diff --git a/src/osmNames.js b/src/osmNames.js
new file mode 100644
index 00000000..4b2a9fa6
--- /dev/null
+++ b/src/osmNames.js
@@ -0,0 +1,40 @@
+/* -*- Mode: JS2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- */
+/* vim: set et ts=4 sw=4: */
+/*
+ * Copyright (c) 2020 Marcus Lundblad
+ *
+ * GNOME Maps is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * GNOME Maps is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with GNOME Maps; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Marcus Lundblad <ml update uu se>
+ */
+
+/**
+ * Utility functions for getting localized names of OSM objects.
+ */
+
+function getNameForLanguage(tags, language) {
+ let localizedName = tags['name:' + language];
+
+ if (!localizedName && (language === 'nb' || language === 'nn'))
+ localizedName = tags['name:no'];
+
+ return localizedName;
+}
+
+function getFallbackNameForLanguage(tags, place, language) {
+ /* TODO: determine fallback name variant depending on location-dependent
+ * rules
+ */
+ return tags.name;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]