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

Wrong type of parameter of $forceLocale in Models/Block::translatedInput() #2309

Closed
pvdbroek opened this issue Jul 25, 2023 · 3 comments · Fixed by #2315
Closed

Wrong type of parameter of $forceLocale in Models/Block::translatedInput() #2309

pvdbroek opened this issue Jul 25, 2023 · 3 comments · Fixed by #2315

Comments

@pvdbroek
Copy link
Contributor

Description

I believe that when adding types in V3, the wrong type is set in this function in Models/Block:


public function translatedInput(string $name, bool $forceLocale = null): mixed
    {
        $value = $this->content[$name] ?? null;

        $locale = $forceLocale ?? (
        config('translatable.use_property_fallback', false) && (! array_key_exists(
            app()->getLocale(),
            array_filter($value ?? []) ?? []
        ))
            ? config('translatable.fallback_locale')
            : app()->getLocale()
        );

        return $value[$locale] ?? null;
    }

$forceLocale is defined to a bool, whereas this should be a string, e.g. "nl_NL". With this new code $locale will be a bool as well, and $value[1] is not set. $value["nl_NL"] however is.

Versions

Twill version: 3.x

@pvdbroek
Copy link
Contributor Author

pvdbroek commented Aug 1, 2023

Any change to get this bug fixed soon? It's really a very minor fix imho :)

As always, thanks for your time & efforts on this great product!

@ifox
Copy link
Member

ifox commented Aug 1, 2023

Hi @pvdbroek thanks for your kind words. Contributions are open. Since your humble opinion is that it is very minor, why don't you submit a pull request to fix it?

@pvdbroek
Copy link
Contributor Author

pvdbroek commented Aug 2, 2023

Hey @ifox thanks for the suggestion. I've created a pull request: #2315

I had actually never done that before for another repo, so I hope I have done it properly :)

@ifox ifox closed this as completed in #2315 Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants