[MGNLUI-5772] Streamline/revisit implementations of I18nAuthoringSupport Created: 26/Mar/20  Updated: 06/Jun/22  Resolved: 04/Apr/22

Status: Closed
Project: Magnolia UI
Component/s: None
Affects Version/s: 6.2
Fix Version/s: 6.2.18, 6.3.0

Type: Improvement Priority: Neutral
Reporter: Aleksandr Pchelintcev Assignee: Adam Siska
Resolution: Fixed Votes: 0
Labels: nucleus
Remaining Estimate: Not Specified
Time Spent: 0.25d
Original Estimate: Not Specified

Issue Links:
Problem/Incident
causes MULTISITE-126 Declare MultiSiteI18nAuthoringSupport... Open
Relates
relates to MGNLUI-5770 Can't edit content in a content-app w... Closed
relates to MGNLUI-5874 Cannot save item in CT created app. V... Closed
supersession
supersedes MAGNOLIA-8330 Move config:server/i18n out of JCR Accepted
Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
[X]* I18n works without the current default impl on the classpath (at least in theory if not possible to test)
Release notes required:
Yes
Date of First Response:
Epic Link: Migrate UI FW internals
Sprint: Nucleus 3, Nucleus 5, Nucleus 7
Story Points: 2
Team: Nucleus

 Description   

See slack thread for a little bit of backstory.

The main concerns we should revisit here include:

  • non-consistent behaviour of the default I18NauthoringSupport (returns a default locale, but without a site configured - returns empty list of available locales, not including the default one).
  • NPE-prone behaviour of the multi-site implementation: in case related site is not resolved for the passed item/node, null is returned for both default locale and available locale list calls.
  • cumbersome #deriveLocalisedName API: for instance always requires to do isDefaultLocale check before (could be done internally in the #deriveLocalisedName).
  • no argument-less API (when we want to access the default i18n confiuration, without any reference item).

To be compatibility module agnostic:

  • create a new default impl in ui-framework
  • create new JCR impl in ui-framework-jcr
  • keep the current impl in compatibility module (might extend the default/JCR impl)

https://git.magnolia-cms.com/projects/PLATFORM/repos/ui/browse/magnolia-ui-framework-compatibility/src/main/java/info/magnolia/ui/framework/i18n/DefaultI18NAuthoringSupport.java#69



 Comments   
Comment by Šimon Demočko [ 19/Feb/21 ]

Return to this when locales for different content will be needed (except for JCR), since MultiSiteI18nAuthoringSupport is pseudo-generic. Also, the DefaultI18NAuthoringSupport is currently in compatibility module

Comment by Roman Kovařík [ 10/Mar/22 ]

For release notes:

These methods of I18nAtuhoringSupport (deprecated since Magnolia 6.0 or longer) were removed:

  • Locale getAuthorLocale();
  • void i18nize(HasComponents fieldContainer, Locale locale);
  • List getAvailableLocales(com.vaadin.v7.data.Item item)
  • Locale getDefaultLocale(Item item) {
  • boolean isDefaultLocale(Locale locale, Item item)
  • String createI18NURI(Node node, Locale locale)

Custom usages of createI18NURI method can be replaced by I18nContentSupport#createI18NURI(Node node, Locale locale) (MAGNOLIA-8311).

The other methods are still implemented by DefaultII18nAuthoringSupport until the ui-framework-compatibility is unbundled (you can cast I18nAtuhoringSupport to DefaultI18nAuthoringSupport and access these methods). 

 

 

Comment by Adam Siska [ 15/Mar/22 ]

Reopened due to failing dx-core int. tests (PR reverted):
it.info.magnolia.eeintegrationtests.uitest.DiffUITest.changeTextImageTitleAndCompareVersionToPrevious
it.info.magnolia.eeintegrationtests.uitest.DiffUITest.changeTextImageTitleAndCompareTwoSpecificVersions
it.info.magnolia.eeintegrationtests.uitest.WorkflowUITest.changeContentsAndRejectWorkflow
https://jenkins.magnolia-cms.com/job/platform/job/dx-core/job/master/1214/
Caused by: java.lang.NoSuchMethodError: info.magnolia.ui.api.i18n.I18NAuthoringSupport.getAvailableLocales(Lcom/vaadin/v7/data/Item;)Ljava/util/List;
at info.magnolia.pages.app.editor.PagesEditorSubApp.getAvailableLocales(PagesEditorSubApp.java:433) ~[magnolia-pages-app-compatibility-6.2.17-SNAPSHOT.jar:?]
at info.magnolia.pages.app.editor.PagesEditorSubApp.access$300(PagesEditorSubApp.java:106) ~[magnolia-pages-app-compatibility-6.2.17-SNAPSHOT.jar:?]
at info.magnolia.pages.app.editor.PagesEditorSubApp$2.onContentChanged(PagesEditorSubApp.java:280) ~[magnolia-pages-app-compatibility-6.2.17-SNAPSHOT.jar:?]

Comment by Roman Kovařík [ 21/Mar/22 ]

Discovery Completed:

pages app needs to be recompiled against these UI changes.

Comment by Adam Siska [ 01/Apr/22 ]

For the record / in progress notes:

We've lost MultiSiteI18nAuthoringSupport config in /server/i18n/authoring/class

(while installing instance you can see:

Magnolia Multisite Module  2.1.3-SNAPSHOT
Property "class" was expected to exist at /server/i18n/authoring with value "info.magnolia.ui.framework.i18n.DefaultI18NAuthoringSupport" but has the value "info.magnolia.ui.framework.i18n.BasicI18NAuthoringSupport" instead.

)

Options:
1) update task in UI (provide update task compatibility module - removed config, revert change in moved bootstrap file add an update task Basic -> Default to the compatibility module, remove type-mapping from jcr module, revert migration-tests update)
2) add type-mapping to multisite
3) add update task to multisite version handler (now it doesn't update the property because awaits the DefaultI18nAuthoringSupport in property not BasicI18n.. one)


DoD: I18n works without the current default impl on the classpath (at least in theory if not possible to test)

BasicI18NAuthoringSupport class needs default (no-argument) constructor to work with ProxyFactory during providing component by GuiceComponentProvider

   /**
     * Default constructor for class to be extendable by proxy class
     * during resolving the component by GuiceComponentProvider.
     */
    BasicI18NAuthoringSupport() {
        this(null, null);
    }
Generated at Mon Feb 12 09:29:53 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.