diff --git a/modules/ui/fields/localized.js b/modules/ui/fields/localized.js index 547eed76b1..b59a55aa02 100644 --- a/modules/ui/fields/localized.js +++ b/modules/ui/fields/localized.js @@ -122,7 +122,10 @@ 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. + 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)) {