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

Translated URL ist not stored in translated static page file #91

Open
der-On opened this issue Dec 16, 2024 · 6 comments
Open

Translated URL ist not stored in translated static page file #91

der-On opened this issue Dec 16, 2024 · 6 comments
Assignees

Comments

@der-On
Copy link
Contributor

der-On commented Dec 16, 2024

When setting a translated URL in a static page the url will only be stored in the original static page file as localeUrl[:locale] but not in the translated static page file under url.

Storing it in the translated static page file is however required for menu items to correctly resolve translated static page URLs.

@LukeTowers
Copy link
Member

@mjauvin seeing a lot of people complain about this after 1.2.7

@mjauvin
Copy link
Member

mjauvin commented Dec 19, 2024

I've heard of two so far and I said (on discord) I'd look into it when I get time.

@mjauvin
Copy link
Member

mjauvin commented Dec 20, 2024

@der-On I cannot reproduce this bug.

It is intended that translated URL be stored in the default language page only, and that does not prevent static pages menu items title/URL from being translated.

The only thing stored in the translated static pages is the translated CONTENT.

Titles and URLs are stored in the DEFAULT language static page under the viewBag as localeTitle[xx] / localeUrl[xx]

Note: there was a fix added in Winter.Translate that restored previous behavior as Winter Core 1.2.7 made a change in Event binding that broke translations. So make sure you use latest Winter.Translate plugin (2.1.7) and that you clear the cache (artisan cache:clear).

@mjauvin
Copy link
Member

mjauvin commented Dec 20, 2024

Ok, I was able to reproduce the bug (I had previously changed the bindEventOnce() calls to bindEvent()).

So, as stated before on Discord, the following PR broke things in translate plugin:

wintercms/storm#192

So until I issue a fix for Winter.Translate, please revert above PR in your local install and CLEAR CACHE.

@mjauvin
Copy link
Member

mjauvin commented Dec 20, 2024

@der-On a temporary fix is below for Winter.Translate (without changing Winter Storm):

diff --git a/behaviors/TranslatablePageUrl.php b/behaviors/TranslatablePageUrl.php
index 11fe845..30341df 100644
--- a/behaviors/TranslatablePageUrl.php
+++ b/behaviors/TranslatablePageUrl.php
@@ -48,7 +48,7 @@ class TranslatablePageUrl extends ExtensionBase
     
         $this->initTranslatableContext();
 
-        $this->model->bindEvent('model.afterFetch', function() {
+        $this->model->bindEventOnce('model.afterFetch', function() {
             $this->translatableDefaultUrl = $this->getModelUrl();
 
             if (!App::runningInBackend()) {

@mjauvin
Copy link
Member

mjauvin commented Dec 20, 2024

@der-On @AIC-BV
Please test with latest dev-main of Winter.Translate and make sure to clear the cache after composer update

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

No branches or pull requests

3 participants