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

CMS pages title translation broken #1271

Open
mjauvin opened this issue Dec 8, 2024 · 4 comments
Open

CMS pages title translation broken #1271

mjauvin opened this issue Dec 8, 2024 · 4 comments
Assignees
Labels
accepted Issues that have been accepted by the maintainers for inclusion
Milestone

Comments

@mjauvin
Copy link
Member

mjauvin commented Dec 8, 2024

Discussed in https://github.com/orgs/wintercms/discussions/1270

Originally posted by oim37 December 8, 2024
Hello,

I update winter to 1.2.7 with composer update and see that title, meta title, meta description allways whowing only on default language. when switching languages, they are always displayed in the default language and do not change according to the one specified in the admin panel. Thus, the search engine will calculate еhese pages are duplicates. I think this is a bug.

@mjauvin mjauvin added the accepted Issues that have been accepted by the maintainers for inclusion label Dec 8, 2024
@mjauvin mjauvin added this to the 1.2.8 milestone Dec 8, 2024
@mjauvin mjauvin self-assigned this Dec 8, 2024
@mjauvin
Copy link
Member Author

mjauvin commented Dec 8, 2024

@bennothommo any chance fb88e6f would create such an issue?

@bennothommo
Copy link
Member

@mjauvin if it were that commit, you'd be seeing exceptions thrown.

@mjauvin
Copy link
Member Author

mjauvin commented Dec 8, 2024

Looks like wintercms/storm@626409c broke Cms Page attributes translation.
( specifically the Halcyon/Model.php change to bindEventOnce() )

But if I look into Winter.Translate, I found this code block that makes no sense to me:

if ($locale != $this->translatableDefault) {
    $translated = $this->getAttributeTranslated($attr, $locale);
    $localeAttr = ($translated ?: $this->translatableUseFallback) ? $localeAttr : null;
}

ref. https://github.com/wintercms/wn-translate-plugin/blob/main/behaviors/TranslatablePage.php#L72-L86

It should be like this:

public function rewriteTranslatablePageAttributes($locale = null)
{   
    $locale = $locale ?: $this->translatableContext;

    foreach ($this->model->translatable as $attr) {
        $localeAttr = $this->translatableOriginals[$attr];
    
        if ($locale != $this->translatableDefault) {
            $translated = $this->getAttributeTranslated($attr, $locale);
            if ($translated) {
                $localeAttr = $translated;
            } elseif (!$this->translatableUseFallback) {
                $localeAttr = null;
            }
        }
        
        $this->model[$attr] = $localeAttr;
    }   
}   

I have NO IDEA how that could have worked before, but it did.

@mjauvin
Copy link
Member Author

mjauvin commented Dec 8, 2024

wintercms/wn-translate-plugin@db7f1ba resolves the issue, but I'd like to understand two things:

  • Why did that work before
  • what impact does the bindEventOnce() really has

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Issues that have been accepted by the maintainers for inclusion
Projects
None yet
Development

No branches or pull requests

2 participants