dotCMS / core

Headless/Hybrid Content Management System for Enterprises
http://dotcms.com
Other
852 stars 467 forks source link

The rules setup is not triggering the language change #30112

Open Millertaker opened 1 week ago

Millertaker commented 1 week ago

Parent Issue

No response

Problem Statement

The rules rewrite is not triggering the language change in the page.

Captura de pantalla 2024-09-23 a la(s) 10 10 36 a  m

Steps to Reproduce

Lang 1

Captura de pantalla 2024-09-23 a la(s) 10 14 43 a  m

Lang 2

Captura de pantalla 2024-09-23 a la(s) 10 14 35 a  m

Acceptance Criteria

dotCMS Version

24.08.27

Proposed Objective

Core Features

Proposed Priority

Priority 3 - Average

External Links... Slack Conversations, Support Tickets, Figma Designs, etc.

No response

Assumptions & Initiation Needs

No response

Quality Assurance Notes & Workarounds

No response

Sub-Tasks & Estimates

No response

john-thomas-dotcms commented 1 week ago

@Millertaker there's a couple things missing from this bug report that a dev will need to try and reproduce the behavior:

  1. The config of the language variables you're using.
  2. The code you're using in the page.
    • I assume you're using the $text viewtool, but we can't tell from this report.
wezell commented 1 week ago

This works if you fire the rules on all requests AND set the language as a request.attribute

Screenshot 2024-09-24 at 10 03 38 AM
Millertaker commented 1 week ago

@wezell @john-thomas-dotcms

Here's the code give for the page i'm showing

<html>
    <header>
        <title>My Custom Template</title>
    </header>
    <body>
        <div>
            <p>Current language ID: $request.getSession().getAttribute("com.dotmarketing.htmlpage.language")</p> 
            <p>Language Variable 'customvar sitename': $text.get("sitename")</p>
        </div>
    </body>
    <ul>
        <li><a href="index_copy?lang=en">English version</a></li>
        <li><a href="index_copy?lang=fr">French version</a></li>
    </ul>
</html>

I changed the rules to every request and have the same behavior.

Captura de pantalla 2024-09-24 a la(s) 9 11 07 a  m

here is the language variable that it's being pulled by the $text viewtool

Captura de pantalla 2024-09-24 a la(s) 9 14 32 a  m Captura de pantalla 2024-09-24 a la(s) 9 14 39 a  m

by the way, the language ID it's not changing in $request.getSession().getAttribute("com.dotmarketing.htmlpage.language") with the rule setup

wezell commented 1 week ago

Trying to set this on a page is not going to work because the page language version to render has already be selected higher up in the request stack, before any html or velocity has been rendered.

Millertaker commented 1 week ago

@wezell i'm not following you completely, are you referring to this line?

<p>Current language ID: $request.getSession().getAttribute("com.dotmarketing.htmlpage.language")</p>

i'm not setting the language attribute there just trying to read it from getAttribute.