Skip to content

Conversation

@gdebrauwer
Copy link
Contributor

Since #52343, the missing translation key handling is triggered when using the trans_choice method with a translation key that has no translation in the app's current locale but does have a translation in the fallback locale.

// Translation key: "foo.bar" // Translation in English (en): ":count Foo|:count Bar" // Translation in Dutch (nl): Not set! // Fallback Locale is English app()->setLocale('en'); trans_choice('foo.bar', 1); // --> Does not trigger "Lang::handleMissingKeysUsing" closure which is correct app()->setLocale('nl'); trans_choice('foo.bar', 1); // --> Triggers "Lang::handleMissingKeysUsing" closure which is not correct // because a translation in the fallback locale (= 'en') does exist!

This is caused by the fact that it checks the existence of a translation key without a fallback to the fallback locale. To fix this, I changed the has method of the Translator class so that checking the existence of a key does not trigger the Lang::handleMissingKeysUsing closure.

@taylorotwell taylorotwell merged commit f8f0668 into laravel:11.x Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants