Skip to content

Open Infrastructure Map, a view of infrastructure data in OpenStreetMap

Translate some infobox values

Russ Garrettaa77043853a2
diff --git a/web/locales/en/translation.json b/web/locales/en/translation.json
index e9b867c..6ec3eb5 100644
--- a/web/locales/en/translation.json
+++ b/web/locales/en/translation.json
@@ -131,7 +131,15 @@
"water": "Water",
"traction": "Traction (< 50 Hz)"
},
- "underground": "Underground",
+ "location": {
+ "underground": "Underground",
+ "underwater": "Underwater",
+ "overhead": "Overhead",
+ "roof": "Roof",
+ "surface": "Surface",
+ "outdoor": "Outdoor",
+ "indoor": "Indoor"
+ },
"power": {
"source": {
"coal": "Coal",
@@ -139,11 +147,18 @@
"hydro": "Hydroelectric",
"nuclear": "Nuclear",
"oil-gas": "Oil/Gas",
+ "gas": "Gas",
"solar": "Solar",
"wind": "Wind",
"biomass": "Biomass",
"waste": "Waste",
"battery": "Battery"
+ },
+ "substation-type": {
+ "transmission": "Transmission",
+ "distribution": "Distribution",
+ "traction": "Traction",
+ "converter": "DC Converter"
}
},
"other": "Other",
diff --git a/web/src/infopopup.ts b/web/src/infopopup.ts
index c2b4330..6d2254b 100644
--- a/web/src/infopopup.ts
+++ b/web/src/infopopup.ts
@@ -45,6 +45,26 @@ function fieldName(key: string) {
)
}
+function fieldValue(key: string, value: any): any {
+ if (typeof value !== 'string') {
+ return value
+ }
+
+ if (key === 'location') {
+ return t('location.' + value, value)
+ }
+
+ if (key === 'substation') {
+ return t('power.substation-type.' + value, value)
+ }
+
+ if (key === 'source') {
+ return t('power.source.' + value, value)
+ }
+
+ return titleCase(value)
+}
+
function formatVoltage(value: number | number[]): string {
if (!Array.isArray(value)) {
value = [value]
@@ -175,7 +195,7 @@ class InfoPopup {
}
}
- renderKey(key: string, value: any) {
+ renderKey(key: string, value: any): HTMLTableRowElement | null {
if (hidden_keys.includes(key) || key.startsWith('name_') || key.startsWith('voltage') || !value) {
return null
}
@@ -189,20 +209,21 @@ class InfoPopup {
}
if (key == 'frequency' && value == '0') {
- value = t('units.DC', 'DC')
+ value = t('units.DC')
}
+ let prettyKey = key
if (key == 'url') {
- value = el('a', t('info.website', 'Website'), {
+ value = el('a', t('info.website'), {
href: value,
target: '_blank'
})
- key = t('info.website', 'Website')
+ prettyKey = t('info.website')
} else {
- key = fieldName(key)
+ prettyKey = fieldName(key)
}
- return el('tr', el('th', key), el('td', value))
+ return el('tr', el('th', prettyKey), el('td', fieldValue(key, value)))
}
nameTags(feature: MapGeoJSONFeature) {
diff --git a/web/src/key/key.ts b/web/src/key/key.ts
index 8504d7f..12c0821 100644
--- a/web/src/key/key.ts
+++ b/web/src/key/key.ts
@@ -147,7 +147,7 @@ class KeyControl implements IControl {
rows = rows.map((row) => [row[0], svgLine(row[1], line_thickness)])
- rows.push([t('underground', 'Underground'), svgLine('#7A7A85', line_thickness, '3 2')])
+ rows.push([t('location.underground', 'Underground'), svgLine('#7A7A85', line_thickness, '3 2')])
rows.push([t('names.power.line-reference', 'Line reference'), await this.sprite('power_line_ref')])
const table = list('table', Tr)