[MAGNOLIA-8917] Consistent Language in Content App Created: 26/May/23  Updated: 04/Jul/23

Status: Open
Project: Magnolia
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Marta Kobus Assignee: Quach Hao Thien
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: 5.5h
Original Estimate: Not Specified

Issue Links:
Relates
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Epic Link: Support
Team: Nucleus

 Description   

Steps to reproduce

  1. Open app with multilanguage support / multiple languages enabled in magnolia
  2. Do some work in non-default language (not english in our case) in the app and save or open preview
  3. Language will change back to default language (english)

Expected results

Language should stay the same after save and when the preview is opened.

Actual results

Language will change back to default language (english)

Development notes

App itselfs works as expected, but editors get confused by change of language on save or when opening the preview. We are looking for a solution/workaround to force the language back to the one the editor used previously.

Initial Investigation:

shows that this might be the culprit

class: info.magnolia.pages.app.detail.extension.LanguageSelectorViewDefinition


 Comments   
Comment by Roman Kovařík [ 29/May/23 ]

Customers can implement this e.g. by having an app scope component like:

@Data
@Singleton
public class AppScopedLocaleContext {
    private Locale locale;
} 
<components>
  <id>app</id>
  <component>
    <type>info.magnolia.ui.editor.AppScopedLocaleContext</type>
    <implementation>info.magnolia.ui.editor.AppScopedLocaleContext</implementation>
  </component>
</components> 

And the subApps doing:

MySubapp extends ContentDetailSubApp/PageDetailSubApp {

  @Override
  public View start(Location location) {
    View view = super.start();
    if (appScopedLocaleContext.getLocale() != null) {
      localeContext.current().set(appScopedLocaleContext.getLocale());
    }
    localeContext.current().observe(locale ->    locale.ifPresent(appScopedLocaleContext::setLocale)); 
    return view;
  }
}

SUPPORT-16473 already has a custom NodePreviewDetailDescriptor so nothing should prevent implementing the above. cc rgaona 

Generated at Mon Feb 12 04:36:57 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.