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

deriveLabelForUISchemaElement() return undefined if no translation was found and no label defined #2290

Open
davewwww opened this issue Feb 19, 2024 · 3 comments
Labels

Comments

@davewwww
Copy link
Contributor

Describe the bug

While working on #2270 (review), it was discovered that the translation was not working properly.

In the example https://deploy-preview-2270--jsonforms-examples.netlify.app/vue-vanilla/#categorization the second tab "address" is empty. In uischema there is only an "i18n" key defined and no label.

"type": "Category",
"i18n": "address",
"elements": []

Expected behavior

the expected behavior is that at least the key "address" will be returned, even if it cannot be translated.

Steps to reproduce the issue

  1. Go to https://deploy-preview-2270--jsonforms-examples.netlify.app/vue-vanilla/#categorization
  2. second tab is empty, but should be labeled with "address"

Screenshots

No response

Which Version of JSON Forms are you using?

v3.2.1

Framework

Vue

RendererSet

Vanilla

Additional context

No response

@lucas-koehler
Copy link
Contributor

Hi @davewwww , thanks for reporting this issue. I agree that it is unexpected and possibly hard to properly detect in the UI when just undefined is returned.
I think we should either return the i18n key as is or return the key with a prefix. E.g. for an unknown key foo something like: MISSING_I18N:foo.
@sdirix what do you think?

@sdirix
Copy link
Member

sdirix commented Feb 21, 2024

I'm not sure. If you have a category without i18n and without a label it will also not render any label. To use the i18n value as a fallback, all the user needs to do is to add it as a label too, e.g.

"type": "Category",
"i18n": "address",
"label": "address",
"elements": []

@davewwww
Copy link
Contributor Author

But in deriveLabelForUISchemaElement() you have this check:

  if (
    (uischema.label === undefined ||
      uischema.label === null ||
      uischema.label === true) &&
    !isInternationalized(uischema)
  ) {
    return undefined;
  }

it says that if you have no label and no i18n, then return undefined. this means that if no label exists but an i18n does, then this check does not apply. so either this check is wrong or the following code ignores the fact that you don't need a label if i18n is set.

so what is the intended behavior of you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants