From 3cd2acb887c3fc447755541da90816149cb86377 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Wed, 18 Jan 2023 15:19:12 -0500 Subject: [PATCH] Add multilingual field exceptions (closes #693, re: https://github.com/openstreetmap/iD/pull/9124) --- modules/ui/fields/localized.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/ui/fields/localized.js b/modules/ui/fields/localized.js index e7b509b730..7ca12a5e8b 100644 --- a/modules/ui/fields/localized.js +++ b/modules/ui/fields/localized.js @@ -123,7 +123,11 @@ export function uiFieldLocalized(field, context) { var existingLangs = new Set(existingLangsOrdered.filter(Boolean)); for (var k in tags) { - var m = k.match(/^(.*):(.*)$/); + // matches for field:, where is a BCP 47 locale code + // motivation is to avoid matching on similarly formatted tags that are + // not for languages, e.g. name:left, name:source, etc. + // https://github.com/openstreetmap/iD/pull/9124 + var m = k.match(/^(.*):([a-z]{2,3}(?:-[A-Z][a-z]{3})?(?:-[A-Z]{2})?)$/); if (m && m[1] === field.key && m[2]) { var item = { lang: m[2], value: tags[k] }; if (existingLangs.has(item.lang)) {