Files
wekan/models/lib/addressReportColumns.js
T
Lauri Ojansivu 3d703965c4 Admin Panel / Problems: "IPv6 location" and "Instrumentation" are translated.
The Security report in Finnish read "Sijainti" beside the English "IPv6
location", and the menu row and title bar of the Instrumentation report were
English in every language.

- The IPv6 location column is the translated 'location' with the fixed
  technical suffix " (IPv6)" - "Sijainti (IPv6)" - through a new optional
  labelSuffix on table headers, so no new key is needed.
- instrumentationReportTitle names the report in the menu row and in its
  title bar, which tests/adminUrls.test.cjs requires to say the same words.
  It is translated into all 246 locale files, after instrumentation-other
  in en.i18n.json's key order. French uses "Instrumentation logicielle",
  because the bare word is spelled exactly like the English one.

Low-confidence translations, written from the language's general
vocabulary for "measuring tools" where the technical term has no
established form: ak, ay, bm, bua, chr, cv, ee, ff, fj, gn, gv, ha, haw, ig,
iu, kl, kw, lg, mi, nah, nd, ny, om, qu, rn, rw, sah, se, sm, sn, ss, st,
tig, tlh, to, tpi, ts, ve, vo, wal, wo, zgh.

tests/addressReportColumns.test.cjs checks that every address column header
is translated. The admin-office-location UI spec expects "Location (IPv6)".

Thanks to xet7 !
2026-10-20 10:37:03 +03:00

59 lines
1.9 KiB
JavaScript

'use strict';
const { classifyAddress } = require('./ipAddress');
const { countryFlag, locationLabel } = require('./geoHeaders');
function addressValue(row, family) {
if (!row) return '';
return row[family] || classifyAddress(row.ip)[family] || '';
}
function locationFor(row, family) {
if (!addressValue(row, family)) return null;
return row[`${family}Location`] || row.location || null;
}
function locationText(row, family) {
if (!addressValue(row, family)) return '';
const location = locationFor(row, family);
return location ? locationLabel(location) : row.locationLabel || row.city || '';
}
function locationFlag(row, family) {
if (!addressValue(row, family)) return '';
const location = locationFor(row, family);
return location ? countryFlag(location.country) : row.flag || '';
}
function mapLocation(row, family) {
const location = locationFor(row, family);
if (!location) return null;
return {
latitude: location.latitude,
longitude: location.longitude,
label: locationText(row, family) || addressValue(row, family),
};
}
function addressReportColumns({ map = false } = {}) {
// Both from the translated 'location': the IPv6 one was the English text
// "IPv6 location" in every language (Admin Panel / Problems / Security in
// Finnish read "Sijainti" beside "IPv6 location").
const locationColumn = family => ({
labelKey: 'location',
...(family === 'ipv6' ? { labelSuffix: ' (IPv6)' } : {}),
value: row => locationText(row, family),
flag: row => locationFlag(row, family),
...(map ? { location: row => mapLocation(row, family) } : {}),
});
return [
{ labelKey: 'event-ipv4', value: row => addressValue(row, 'ipv4') },
locationColumn('ipv4'),
{ labelKey: 'event-ipv6', value: row => addressValue(row, 'ipv6') },
locationColumn('ipv6'),
];
}
module.exports = { addressValue, locationFor, locationText, locationFlag,
mapLocation, addressReportColumns };