Open Infrastructure Map, a view of infrastructure data in OpenStreetMap
Translate HTML in menu
Russ Garrett285a395ca56a
diff --git a/web/.prettierrc b/web/.prettierrcindex cd9e6e6..e639db2 100644--- a/web/.prettierrc+++ b/web/.prettierrc@@ -2,5 +2,6 @@"semi": false,"trailingComma": "none","singleQuote": true,- "printWidth": 110+ "printWidth": 110,+ "htmlWhitespaceSensitivity": "strict"}diff --git a/web/index.html b/web/index.htmlindex b903b60..e16024e 100644--- a/web/index.html+++ b/web/index.html@@ -26,9 +26,16 @@<h1>Open Infrastructure Map</h1><nav><ul>- <li><a href="/about">about</a></li>- <li><a href="/stats">stats</a></li>- <li><a href="https://www.infrageomatics.com/products/osm-export" target="_blank">exports</a></li>+ <li><a href="/about" data-i18n="nav.about">about</a></li>+ <li><a href="/stats" data-i18n="nav.stats">stats</a></li>+ <li+ ><a+ href="https://www.infrageomatics.com/products/osm-export"+ target="_blank"+ data-i18n="nav.exports"+ >exports</a+ >+ </li></ul></nav></header>diff --git a/web/locales/en/translation.json b/web/locales/en/translation.jsonindex a53e959..fc969ce 100644--- a/web/locales/en/translation.json+++ b/web/locales/en/translation.json@@ -1,4 +1,9 @@{+ "nav": {+ "about": "about",+ "stats": "stats",+ "exports": "exports"+ },"edit": {"edit": "Edit","remote": "Edit with remote control (JOSM, etc)",diff --git a/web/src/index.ts b/web/src/index.tsindex af656d8..c4d8645 100644--- a/web/src/index.ts+++ b/web/src/index.ts@@ -11,6 +11,14 @@ await i18next.use(LanguageDetector).init({debug: import.meta.env.DEV})+// Translate HTML elements.+document.querySelectorAll('[data-i18n]').forEach((element) => {+ const key = element.getAttribute('data-i18n')+ if (key) {+ ;(element as HTMLElement).innerText = i18next.t(key)+ }+})+import OpenInfraMap from './openinframap'export const openinframap = new OpenInfraMap()