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

[v4] Translate function doesn't work with field values anymore #5185

Closed
Tracked by #12
tobimori opened this issue May 25, 2023 · 13 comments · Fixed by #5207
Closed
Tracked by #12

[v4] Translate function doesn't work with field values anymore #5185

tobimori opened this issue May 25, 2023 · 13 comments · Fixed by #5207
Assignees
Milestone

Comments

@tobimori
Copy link
Contributor

Description

I use the following code to get a translated label for a value from a site field, which worked fine in Kirby 3:

https://github.com/tobimori/kirby-seo/blob/main/blueprints/fields/og-group.yml#L35

    placeholder: "{{ t('default-select') }} {{ t(site.twitterCardType) }}"

Yet, with Kirby 4, I'm missing the output for the translated card type:
CleanShot 2023-05-25 at 12 06 11@2x

When removing the translation helpers, I can see that the data can be accessed correctly.
CleanShot 2023-05-25 at 12 06 38@2x

It works correctly when appending .value to site.twitterCardType:

    placeholder: "{{ t('default-select') }} {{ t(site.twitterCardType.value) }}"
CleanShot 2023-05-25 at 12 07 53@2x

To reproduce

Install my SEO plugin with Kirby 4.0, or test using the code snippets above.

Your setup

Kirby Version 4.0-alpha.1

@distantnative
Copy link
Member

@tobimori if you have any quick way to double check that this isn't already broken in3.9.4, would be helpful. If not, don't worry - just won't get myself on a laptop that soon to do myself and trying to debug via GitHub on my phone 🤣

@afbora
Copy link
Member

afbora commented May 25, 2023

@distantnative I've tested on 3.9.4 and works great.

@tobimori
Copy link
Contributor Author

Yep, works on the sites where this plugin is running with v3.9.4.

@distantnative
Copy link
Member

Does ist work for you when removing declare(strict_types = 1); from src/Query/Query.php?

@distantnative
Copy link
Member

That would be my current hunch - that previously the Field object implicitly got casted to its value and due to this line Kirby now would want you to add .value (which would not be great, we would look into easing this - just trying to find the reason for the bug first).

@afbora
Copy link
Member

afbora commented May 29, 2023

I can't see declare(strict_types = 1); in any files.

@afbora
Copy link
Member

afbora commented May 29, 2023

Also not working with .value (but works in 3.9.x)

@distantnative
Copy link
Member

@afbora https://github.com/getkirby/kirby/blob/v4/main/src/Query/Query.php#L3 - and @tobimori described that it's working with .value

@afbora
Copy link
Member

afbora commented May 29, 2023

@distantnative Sorry, I tested on v4/develop and it hasn't that line.

@afbora
Copy link
Member

afbora commented May 29, 2023

But v4/main still doesn't work for me. With removing strict_types and .value

placeholder: "{{ t('foo') }} {{ t(model.text.value) }}"

@tobimori
Copy link
Contributor Author

tobimori commented May 29, 2023

It doesn't seem to fix it. .value still works.

@distantnative
Copy link
Member

Observation: works on v4/develop but not v4/main

@distantnative
Copy link
Member

Works when removing strict mode from src/Query/Segment.php

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

Successfully merging a pull request may close this issue.

4 participants