Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localized field hidden despite nonempty subkeys #10323

Closed
1ec5 opened this issue Jul 13, 2024 · 1 comment · Fixed by #10333
Closed

Localized field hidden despite nonempty subkeys #10323

1ec5 opened this issue Jul 13, 2024 · 1 comment · Fixed by #10333
Labels
bug A bug - let's fix this! field An issue with a field in the user interface good first issue Best for first-time contributors. No experience necessary! localization Adapting iD across languages, regions, and cultures

Comments

@1ec5
Copy link
Collaborator

1ec5 commented Jul 13, 2024

The Name field is a localized field that displays not only name=* but also a very large number of potential name:xyz=* subkeys. The Name field is universal, so it’s enabled for every preset. However, some presets don’t display it by default. For these presets, the field stays hidden even if the feature has name:xyz=* set.

Steps to reproduce

To reproduce this issue, create a Windpump (man_made=windpump) and manually tag it with name:es=El Gran Molino. Observe that the Name field doesn’t appear.

No Name field despite name:es being set

Impact

In general, it’s incorrect to set name:xyz=* without setting name=*. However, this is a subject of debate for some very international features, such as oceans and seas. Even if it’s a tagging error, the field should automatically show because it isn’t empty. This will be a bigger problem for the name fields being added in openstreetmap/id-tagging-schema#215. Those fields are universal but aren’t included by default in any preset, because the local language isn’t guaranteed to need them all, even as some other language may need one of them.

Diagnosis

The logic for showing a field needs a special case for fields of type localized that tests for any key beginning with the field’s key and a colon:

iD/modules/ui/field.js

Lines 90 to 102 in aaa1441

function tagsContainFieldKey() {
return allKeys().some(function(key) {
if (field.type === 'multiCombo') {
for (var tagKey in _tags) {
if (tagKey.indexOf(key) === 0) {
return true;
}
}
return false;
}
return _tags[key] !== undefined;
});
}

We should use the same regular expression added in #9124 to test whether the field would show the subkey:

// matches for field:<code>, where <code> 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]) {

@1ec5 1ec5 added bug A bug - let's fix this! localization Adapting iD across languages, regions, and cultures field An issue with a field in the user interface labels Jul 13, 2024
@1ec5 1ec5 added the good first issue Best for first-time contributors. No experience necessary! label Jul 13, 2024
@samhoooo
Copy link

Hi @1ec5, I created a fix for the above issue.

This is my first time to contribute here, so would be really appreciate if you could give some comments. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug - let's fix this! field An issue with a field in the user interface good first issue Best for first-time contributors. No experience necessary! localization Adapting iD across languages, regions, and cultures
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants