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

Translate doesn't revert to default locale when passing empty string as locale #135

Closed
kersysgediminas opened this issue Sep 10, 2024 · 2 comments · Fixed by #136
Closed
Assignees
Labels
Milestone

Comments

@kersysgediminas
Copy link
Contributor

BC Break Report

Q A
Version 2.27.0

Summary

Passing empty string used to be the same as passing null as locale to \Laminas\I18n\Translator\Translator::translate() but the behavior changed.

@@ -345,7 +345,7 @@ public function getPluginManager()
     */
    public function translate($message, $textDomain = 'default', $locale = null)
    {
-       $locale      = $locale ?: $this->getLocale();
+       $locale      = $locale ?? $this->getLocale();
        $translation = $this->getTranslatedMessage($message, $locale, $textDomain);

https://github.com/laminas/laminas-i18n/pull/117/files#diff-617dd26fad700da3ee06fad2afafa9652a82a157416b914efbada1998c38d478L348

Previous behavior

\Laminas\I18n\Translator\Translator::translate() returns translated message using default locale when empty string is passed as locale

Current behavior

\Laminas\I18n\Translator\Translator::translate() returns untranslated message when empty string is passed as locale.

How to reproduce

pass empty string as locale to \Laminas\I18n\Translator\Translator::translate()

@froschdesign
Copy link
Member

@gsteel
Can you take a look at this? Thanks in advance! 👍🏻

gsteel added a commit to kersysgediminas/laminas-i18n that referenced this issue Sep 10, 2024
gsteel added a commit to kersysgediminas/laminas-i18n that referenced this issue Sep 10, 2024
@gsteel gsteel linked a pull request Sep 10, 2024 that will close this issue
@gsteel gsteel self-assigned this Sep 10, 2024
@gsteel gsteel added this to the 2.28.1 milestone Sep 10, 2024
@gsteel
Copy link
Member

gsteel commented Sep 10, 2024

Closed via #136

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

Successfully merging a pull request may close this issue.

3 participants