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

[Panel] Empty label, placeholder etc. translations when language is not defined #1876

Closed
texnixe opened this issue Jun 23, 2019 · 3 comments

Comments

@texnixe
Copy link
Contributor

commented Jun 23, 2019

Describe the bug
When defining translation for field labels, info field text, info section text for multiple languages and the user selects a language that is not defined, the property either remains empty (label, placeholder, info section text) or throws an error (info field text)

Info field:

        fields:
          info:
            type: info
            label:
              de: Super wichtige Info
              en: Super important info
            text:
              de: Hier Info text
              en: Here info text

If the logged in user doesn't use one of the defined languages, this throws the following
error:

Return value of Kirby\Cms\ModelWithContent::toString() must be of the type string, null returned

(the toString() method was introduced in 3.2, the error could be prevented by making the required string return value optional, but it would still result in an empty field).

If we use an info section instead of an info field in the example above, there is no error message but the info section remains empty.

Similar behaviour happens in case of translated labels, placeholders and probably other properties I haven't tested. The result seems to be always null in those cases. For example, without a label set, Kirby usually falls back to the field key. However, once you define translations and the user selected translation does not exist, Kirby just returns null, not even falling back to the field key.

To Reproduce
Steps to reproduce the behavior:

  1. Create the above field (or an info section) in a blueprint, e.g. site.yml
  2. Visit the site in Panel.
  3. See error

Expected behavior
One solution could be to always require an English translation in the blueprint and then fall back to English (this was required in Kirby 2).

A second option would be to always fall back to the first defined language.

In case of field labels, falling back to the field key could also be an option.

Screenshots
If applicable, add screenshots to help explain your problem.

Kirby Version
3.2.0-rc4.

Additional context
Add any other context about the problem here.

@bastianallgeier

This comment has been minimized.

Copy link
Contributor

commented Jun 24, 2019

I cannot reproduce the string error. In my case, with your blueprint setup, I only get empty labels. I will move it to 3.2.1

@bastianallgeier bastianallgeier added this to the 3.2.1 milestone Jun 24, 2019
@texnixe

This comment has been minimized.

Copy link
Contributor Author

commented Jun 24, 2019

Hm, strange, today I can't reproduce the error either, can't even find this toString() method anymore.. Maybe it was a cache thing after all. I edited the issue headline.
Anyway, the empty labels etc. could do with some sort of fix.

@texnixe texnixe changed the title [Panel] Inconsistent property translation behaviour when language is not defined [Panel] Empty label, placeholder etc. translations when language is not defined Jun 24, 2019
@bastianallgeier bastianallgeier modified the milestones: 3.2.1, 3.2.2 Jul 2, 2019
@bastianallgeier bastianallgeier modified the milestones: 3.2.2, 3.2.3 Jul 10, 2019
@distantnative distantnative self-assigned this Jul 18, 2019
@bastianallgeier bastianallgeier removed this from the 3.2.3 milestone Jul 30, 2019
distantnative added a commit that referenced this issue Aug 23, 2019
@distantnative distantnative added this to the 3.2.5 milestone Aug 23, 2019
bastianallgeier added a commit that referenced this issue Sep 5, 2019
bastianallgeier added a commit that referenced this issue Sep 5, 2019
bastianallgeier added a commit that referenced this issue Sep 5, 2019
@bastianallgeier

This comment has been minimized.

Copy link
Contributor

commented Sep 5, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.